Skip to content

Commit ac9c637

Browse files
authored
fix: conformance tests for tools_call and auth/scope-step-up (#1022)
1 parent 8803d39 commit ac9c637

3 files changed

Lines changed: 22 additions & 35 deletions

File tree

.github/workflows/conformance.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ jobs:
9191
--url http://127.0.0.1:8002/mcp \
9292
--suite all \
9393
--spec-version 2026-07-28 \
94-
--expected-failures conformance/expected-failures-2026-07-28.yaml \
9594
-o conformance-results
9695
9796
# Extension scenarios are excluded by the --spec-version filter and
@@ -165,7 +164,6 @@ jobs:
165164
--command "$(pwd)/target/debug/conformance-client" \
166165
--suite all \
167166
--spec-version 2026-07-28 \
168-
--expected-failures conformance/expected-failures-2026-07-28.yaml \
169167
-o conformance-client-results/draft
170168
171169
- name: Run extension client suite (informational)

conformance/expected-failures-2026-07-28.yaml

Lines changed: 0 additions & 25 deletions
This file was deleted.

conformance/src/bin/client.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ impl ClientHandler for FullClientHandler {
189189

190190
const CIMD_CLIENT_METADATA_URL: &str = "https://conformance-test.local/client-metadata.json";
191191
const REDIRECT_URI: &str = "http://localhost:3000/callback";
192+
const SCOPE_STEP_UP_INITIAL_SCOPES: &[&str] = &["mcp:basic"];
192193
const SCOPE_STEP_UP_ESCALATED_SCOPES: &[&str] = &["mcp:basic", "mcp:write"];
193194

194195
/// Perform the headless OAuth authorization-code flow.
@@ -320,11 +321,10 @@ async fn run_auth_scope_step_up_client(
320321
server_url: &str,
321322
_ctx: &ConformanceContext,
322323
) -> anyhow::Result<()> {
323-
// First auth
324324
let mut oauth = OAuthState::new(server_url, None).await?;
325325
oauth
326326
.start_authorization_with_metadata_url(
327-
&[],
327+
SCOPE_STEP_UP_INITIAL_SCOPES,
328328
REDIRECT_URI,
329329
Some("conformance-client"),
330330
Some(CIMD_CLIENT_METADATA_URL),
@@ -351,7 +351,9 @@ async fn run_auth_scope_step_up_client(
351351
StreamableHttpClientTransportConfig::with_uri(server_url),
352352
);
353353

354-
let client = BasicClientHandler.serve(transport).await?;
354+
let client = BasicClientHandler
355+
.serve_with_lifecycle(transport, conformance_lifecycle())
356+
.await?;
355357

356358
let tools = client.list_tools(Default::default()).await?;
357359
tracing::debug!("Listed {} tools", tools.tools.len());
@@ -398,10 +400,12 @@ async fn run_auth_scope_step_up_client(
398400
auth_client2,
399401
StreamableHttpClientTransportConfig::with_uri(server_url),
400402
);
401-
let client2 = BasicClientHandler.serve(transport2).await?;
402-
let _ = client2
403+
let client2 = BasicClientHandler
404+
.serve_with_lifecycle(transport2, conformance_lifecycle())
405+
.await?;
406+
client2
403407
.call_tool(call_tool_params(tool.name.clone(), args))
404-
.await;
408+
.await?;
405409
client2.cancel().await.ok();
406410
return Ok(());
407411
}
@@ -859,7 +863,7 @@ async fn run_basic_client(server_url: &str) -> anyhow::Result<()> {
859863
}
860864

861865
async fn run_tools_call_client(server_url: &str, ctx: &ConformanceContext) -> anyhow::Result<()> {
862-
run_tools_call_client_with_lifecycle(server_url, ctx, ClientLifecycleMode::Initialize).await
866+
run_tools_call_client_with_lifecycle(server_url, ctx, conformance_lifecycle()).await
863867
}
864868

865869
async fn run_discover_tools_call_client(
@@ -930,7 +934,17 @@ fn conformance_protocol_version() -> ProtocolVersion {
930934
std::env::var("MCP_CONFORMANCE_PROTOCOL_VERSION")
931935
.ok()
932936
.and_then(|version| serde_json::from_value(Value::String(version)).ok())
933-
.unwrap_or(ProtocolVersion::V_2026_07_28)
937+
.unwrap_or(ProtocolVersion::V_2025_11_25)
938+
}
939+
940+
fn conformance_lifecycle() -> ClientLifecycleMode {
941+
if conformance_protocol_version().as_str() >= ProtocolVersion::V_2026_07_28.as_str() {
942+
ClientLifecycleMode::Discover {
943+
preferred_versions: preferred_protocol_versions(),
944+
}
945+
} else {
946+
ClientLifecycleMode::Initialize
947+
}
934948
}
935949

936950
/// Preferred protocol versions for discover-lifecycle negotiation: the

0 commit comments

Comments
 (0)