Skip to content

feat(client): add a maximum MCP protocol version - #1977

Open
Coding-Professional wants to merge 1 commit into
modelcontextprotocol:mainfrom
Coding-Professional:feat/1868-protocol-version-ceiling
Open

Coding-Professional wants to merge 1 commit into
modelcontextprotocol:mainfrom
Coding-Professional:feat/1868-protocol-version-ceiling

Conversation

@Coding-Professional

Copy link
Copy Markdown
Contributor

Summary

Add McpClientOptions.MaximumProtocolVersion so clients can choose an upper protocol bound while accepting an older mutually supported revision. This is useful for MCP hosts and gateways that have validated a limited range of protocol revisions.

Fixes #1868.

Behavior

  • Validate the ceiling against SDK-supported revisions and reject configuration that also sets the existing exact ProtocolVersion pin before opening a transport.
  • A ceiling on an initialize-handshake revision requests that revision directly and accepts an older supported response. A 2026-07-28 ceiling retains discovery and fallback, filtering advertised versions before selecting one.
  • Reject malformed/newer initialize responses and advertised version sets with no compatible revision. Resumed sessions cannot exceed the configured ceiling.
  • Leave connection behavior unchanged when the new option is unset. Document the difference between an exact pin and a ceiling.

Verification

  • Focused protocol negotiation tests: 58 passed on Windows net10.0 and net8.0. These cover ceiling match, downgrade, discovery fallback, no overlap, invalid response, conflicting options, and resume.
  • dotnet build src/ModelContextProtocol.Core/ModelContextProtocol.Core.csproj --no-restore: passed for netstandard2.0, net8.0, net9.0, and net10.0 with no warnings or errors.
  • git diff --check: passed.
  • dotnet format whitespace --verify-no-changes --include ... reports existing whitespace violations on untouched lines in McpClient.Methods.cs and McpClientImpl.cs; this PR does not reformat those unrelated sections.

AI assistance was used to investigate and draft this change; I reviewed the implementation and ran the tests above.

Copilot AI balanced review requested due to automatic review settings October 30, 2026 11:45

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants