Skip to content

Add prior discovery client connections#1697

Open
halter73 wants to merge 1 commit into
mainfrom
halter73-sdk-protocol-support-eval
Open

Add prior discovery client connections#1697
halter73 wants to merge 1 commit into
mainfrom
halter73-sdk-protocol-support-eval

Conversation

@halter73

@halter73 halter73 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add McpClientOptions.PriorDiscoverResult so trusted modern discovery snapshots can skip the server/discover probe.
  • Add McpClient.GetDiscoverResult() for reusable discovery snapshots, including cache hints.
  • Validate prior discovery compatibility, preserve pinned-version semantics, and keep 2026-07-28 request metadata emission intact.
  • Document the prior-knowledge reconnect path.

Closes #1696

Adds an opt-in PriorDiscoverResult client option for trusted modern discovery snapshots, exposes McpClient.GetDiscoverResult(), and reuses the discovery adoption path so clients can skip server/discover when reconnecting with prior knowledge.

Adds tests for zero-probe prior discovery, pinned-version validation, invalid legacy combinations, reusable snapshots, and 2026-07-28 per-request metadata emission.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

Pull request overview

Adds an opt-in “prior knowledge” connection path for modern (2026-07-28+) MCP clients, allowing callers to skip the server/discover probe when they already have a trusted discovery snapshot, while preserving existing protocol pinning and fallback semantics.

Changes:

  • Introduces McpClientOptions.PriorDiscoverResult to adopt a trusted DiscoverResult and bypass server/discover.
  • Adds McpClient.GetDiscoverResult() (and an override in McpClientImpl) to provide reusable discovery snapshots including cache hints.
  • Updates stateless protocol documentation and adds tests for the new connection + required _meta emission behavior.
Show a summary per file
File Description
tests/ModelContextProtocol.Tests/Client/July2026ProtocolListMetaEmissionTests.cs Adds coverage to ensure required _meta is emitted when connecting via prior discovery.
tests/ModelContextProtocol.Tests/Client/July2026ProtocolConnectionTests.cs Adds prior-discovery connection tests (skip discover, pin semantics, invalid prior cases, snapshot cloning).
src/ModelContextProtocol.Core/Client/McpClientOptions.cs Adds PriorDiscoverResult option with XML docs describing behavior and constraints.
src/ModelContextProtocol.Core/Client/McpClientImpl.cs Implements adopting prior discovery, cloning/storing discover results, and overriding GetDiscoverResult().
src/ModelContextProtocol.Core/Client/McpClient.cs Adds public virtual GetDiscoverResult() API and documentation.
docs/concepts/stateless/stateless.md Documents the prior-knowledge reconnect path and example usage.

Review details

  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment on lines +72 to +74
/// The default implementation returns a minimal discovery result containing only the negotiated
/// protocol version. Concrete clients may override this to preserve the full <c>server/discover</c>
/// response, including every server-supported version and caching hints.
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.

Add prior-knowledge connection path for modern protocol clients

2 participants