Skip to content

Add prior-knowledge connection path for modern protocol clients #1696

Description

@halter73

Summary

Add a C# client API for 2026-07-28+ connections that lets callers skip the server/discover round trip when they already have trusted prior knowledge about the server. This should be distinct from McpClientOptions.ProtocolVersion, so exact version pinning can continue to mean "require this version / disable fallback" rather than "skip discovery."

Motivation

Today, setting McpClientOptions.ProtocolVersion = "2026-07-28" disables legacy fallback, but the client still sends server/discover before adopting the modern protocol. That is safe, but it leaves no zero-round-trip path for known modern servers or for clients that have cached a previous DiscoverResult.

A separate prior-knowledge API would improve startup latency and align C# with the stronger ergonomics in the other Tier 1 SDKs while preserving C#'s current safe defaults.

Current C# behavior

  • ProtocolVersion = null: default modern auto path; sends server/discover and falls back to legacy initialize when appropriate.
  • ProtocolVersion = "2026-07-28": sends server/discover and requires a modern result; does not fall back to legacy.
  • Legacy exact versions such as "2025-11-25": skip server/discover and use legacy initialize.
  • No public API was found for providing a cached DiscoverResult or directly adopting a known modern protocol version.

Relevant C# files:

  • src/ModelContextProtocol.Core/Client/McpClientOptions.cs
  • src/ModelContextProtocol.Core/Client/McpClientImpl.cs
  • src/ModelContextProtocol.Core/Protocol/DiscoverResult.cs

Tier 1 SDK references

TypeScript SDK

TypeScript exposes the strongest explicit prior-knowledge shape:

  • ConnectOptions.prior?: DiscoverResult lets callers provide a previously obtained discovery result.
  • _connectFromPrior(...) bypasses version negotiation and server/discover, adopts capabilities/server info/instructions, and sets the negotiated protocol version.
  • getDiscoverResult() returns a reusable DiscoverResult.

References:

Python SDK

Python supports both an explicit cached-discovery path and a simple direct-modern mode:

  • Client(mode="auto") probes with server/discover and falls back.
  • Client(mode="2026-07-28") adopts the modern protocol directly without sending server/discover.
  • prior_discover can provide a cached DiscoverResult.
  • ClientSession.adopt() installs an InitializeResult or DiscoverResult without wire traffic.
  • ClientSession.discover_result exposes the round-trippable discovery result for reuse.

References:

Go SDK

Go has solid 2026-07-28 plumbing but does not appear to expose a public prior-knowledge client API:

  • Client.Connect defaults to latest 2026-07-28, sends server/discover, negotiates, and falls back to legacy initialize when needed.
  • ClientSessionOptions.protocolVersion is unexported and documented as a testing override.
  • Server discover advertises transport-filtered supported versions.
  • Go also implements modern per-request _meta, standard HTTP headers, subscriptions/listen, multi-round-trip helpers, and TTL caches for modern list/read results.

References:

Proposed C# API direction

Add a distinct opt-in prior-knowledge path, for example:

  • McpClientOptions.KnownDiscoverResult or McpClientOptions.PriorDiscoverResult: adopt a trusted discovery result and skip server/discover.
  • Optionally, a direct-modern option such as AssumeProtocolVersion = "2026-07-28" for callers that only know the protocol version but do not have server info/capabilities yet.
  • Keep ProtocolVersion semantics unchanged: exact modern version should still probe and require a compatible result unless the new prior-knowledge option is used.

Acceptance criteria

  • A caller can connect to a known 2026-07-28+ server without sending server/discover.
  • A caller can retrieve or construct the prior-knowledge payload needed for a later zero-round-trip connection.
  • Existing default auto-negotiation and exact ProtocolVersion behavior remain backward compatible.
  • Per-request _meta and HTTP headers continue to be populated correctly after prior-knowledge adoption.
  • Tests cover default auto, exact modern pin, cached prior discovery, and invalid/incompatible prior discovery.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions