Skip to content

Apply the test discovery timeouts to Sampling_Stdio - #1950

Merged
tarekgh merged 1 commit into
modelcontextprotocol:mainfrom
girishkvs:test_server_discover_timeout
Oct 22, 2026
Merged

tarekgh merged 1 commit into
modelcontextprotocol:mainfrom
girishkvs:test_server_discover_timeout

Conversation

@girishkvs

@girishkvs girishkvs commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This is a test-only follow-up to #1943 and #1946. Both give stdio test_server clients the test discovery timeouts only when a test passes no client options: ClientIntegrationTestFixture now uses TestMcpClient.CreateOptions() for them, and options a test passes stay unchanged. Sampling_Stdio passes options for its sampling handler without pinning a protocol version, so on main its test_server case still uses the default 5-second server/discover probe. When the TestServer starts slowly, the client falls back to initialize while the discover answer is still on its way, and the server, which has already selected 2026-07-28, rejects it:

McpProtocolException: Request failed (remote): Method 'initialize' is not available on protocol version '2026-07-28'.

  • Sampling_Stdio now starts its test_server options from TestMcpClient.CreateOptions() and then sets its sampling handler, as CONTRIBUTING.md asks since Prevent discovery probe timeouts in controlled test connections #1946. The everything server keeps the default probe, as in the fixture.
  • No helper or fixture changes: explicitly supplied options still stay unchanged.
  • The other ClientIntegrationTests call sites that pass options pin 2025-11-25, so they never probe. SDK behavior is unchanged; this does not fix the underlying fallback race.

CI evidence

Validation

  • Reproduced on main with Prevent discovery probe timeouts in controlled test connections #1946 by holding the TestServer's server/discover answer for 7 seconds, a local-only change that is not in this PR. ClientIntegrationTests on .NET 8 had one failure, Sampling_Stdio(clientId: "test_server"), with the CI message (58 passed, 2 skipped). With this change, all passed (59 passed, 2 skipped).
  • Without the delay, ClientIntegrationTests and July2026ProtocolFallbackTests (91 tests): 20 runs on .NET 8 and one run each on .NET 10 and .NET Framework 4.7.2, with zero failures. Each run had 89 passed and the 2 OpenAI-key skips.

@girishkvs girishkvs mentioned this pull request Oct 22, 2026
5 tasks done
modelcontextprotocol#1943 and modelcontextprotocol#1946 give stdio test_server clients an unbounded server/discover
probe when a test passes no options, and leave options a test passes
unchanged. Sampling_Stdio passes options for its sampling handler without
pinning a protocol version, so its test_server case still used the
5-second probe and could fall back to initialize while the discover answer
was on its way; the server then rejects initialize. Start its test_server
options from TestMcpClient.CreateOptions(), as CONTRIBUTING.md asks; the
everything server keeps the default probe.
@girishkvs
girishkvs force-pushed the test_server_discover_timeout branch from a35062c to 69eb00b Compare October 22, 2026 21:55
@girishkvs girishkvs changed the title Apply the test-only discovery timeout to test_server clients that pass options Apply the test discovery timeouts to Sampling_Stdio Oct 22, 2026
@tarekgh
tarekgh requested a balanced review from Copilot October 22, 2026 22:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The localized test change follows the established helper pattern while preserving sampling behavior and legacy-server defaults.

No open issues 🎉

What changed in this PR

This test-only follow-up to #1943 and #1946 applies the shared discovery timeout configuration to Sampling_Stdio, reducing slow-startup failures without changing SDK behavior.

Changes:

  • Initialize test_server client options with TestMcpClient.CreateOptions() before assigning the sampling handler.
  • Preserve the everything server’s default probe timeout and existing sampling behavior.
File Description
tests/​ModelContextProtocol.Tests/​ClientIntegrationTests.cs Apply test discovery timeouts to the controlled-server sampling test.

Review effort: Balanced

@tarekgh tarekgh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @girishkvs

@tarekgh
tarekgh merged commit 52d1fec into modelcontextprotocol:main Oct 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants