Tighten draft protocol negotiation boundaries (#1692)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Tarek Mahmoud Sayed <tarekms@ntdev.microsoft.com>
This commit is contained in:
Stephen Halter 2026-07-12 14:30:49 -07:00 • committed by GitHub
commit fd38f51e27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 1755 additions and 589 deletions

View file

@ -8,16 +8,19 @@ namespace ModelContextProtocol.Protocol;
/// <remarks>
/// <para>
/// Introduced by the 2026-07-28 protocol revision (SEP-2575) as the canonical way for a client
/// to learn what a server supports without performing the legacy <c>initialize</c> handshake.
/// to learn what a server supports without performing the <c>initialize</c> handshake.
/// </para>
/// </remarks>
public sealed class DiscoverResult : Result, ICacheableResult
{
/// <summary>
/// Gets or sets the list of MCP protocol version strings that the server supports.
/// Gets or sets the list of MCP protocol version strings the server supports for subsequent
/// per-request metadata requests.
/// </summary>
/// <remarks>
/// The client should choose a version from this list for use in subsequent requests.
/// The client should choose a version from this list for subsequent requests that carry the
/// 2026-07-28-style per-request <c>_meta</c> envelope. Versions that require the
/// <c>initialize</c> handshake are negotiated through <c>initialize</c> instead.
/// </remarks>
[JsonPropertyName("supportedVersions")]
public required IList<string> SupportedVersions { get; set; }

View file

@ -22,16 +22,17 @@ namespace ModelContextProtocol.Protocol;
public sealed class InitializeRequestParams : RequestParams
{
/// <summary>
/// Gets or sets the version of the Model Context Protocol that the client wants to use.
/// Gets or sets the initialize-handshake Model Context Protocol version that the client wants to use.
/// </summary>
/// <remarks>
/// <para>
/// Protocol version is specified using a date-based versioning scheme in the format "YYYY-MM-DD".
/// The client and server must agree on a protocol version to communicate successfully.
/// The client and server must agree on an initialize-capable protocol version to communicate successfully.
/// </para>
/// <para>
/// During initialization, the server will check if it supports this requested version. If there's a
/// mismatch, the server will reject the connection with a version mismatch error.
/// During initialization, the server will check if it supports this requested version. Protocol
/// revisions starting with <c>2026-07-28</c> do not use <c>initialize</c>; clients select them with
/// <c>server/discover</c> and per-request metadata instead.
/// </para>
/// <para>
/// See the <see href="https://spec.modelcontextprotocol.io/specification/">protocol specification</see> for version details.

View file

@ -22,11 +22,11 @@ namespace ModelContextProtocol.Protocol;
public sealed class InitializeResult : Result
{
/// <summary>
/// Gets or sets the version of the Model Context Protocol that the server will use for this session.
/// Gets or sets the initialize-handshake Model Context Protocol version that the server will use for this session.
/// </summary>
/// <remarks>
/// <para>
/// This is the protocol version the server has agreed to use, which should match the client's
/// This is the initialize-capable protocol version the server has agreed to use, which should match the client's
/// requested version. If there's a mismatch, the client should throw an exception to prevent
/// communication issues due to incompatible protocol versions.
/// </para>

View file

@ -217,7 +217,7 @@ public abstract class JsonRpcMessage
// Per JSON-RPC 2.0, when an error occurs before the request id can be determined
// (e.g. parse error or invalid request), the server MUST respond with id=null.
// Accept null-id error responses so callers can recognize the structured signal
// (e.g. an HTTP 400 body whose JSON-RPC envelope carries a non-modern error code).
// (e.g. an HTTP 400 body whose JSON-RPC envelope carries a non-SEP-2575 error code).
return new JsonRpcError
{
Id = id,

View file

@ -159,15 +159,15 @@ public static class RequestMethods
/// <remarks>
/// <para>
/// This RPC is introduced in the 2026-07-28 protocol revision (SEP-2575) as the canonical way for a client
/// to learn what a server supports without performing the legacy <c>initialize</c> handshake.
/// to learn what a server supports without performing the <c>initialize</c> handshake.
/// </para>
/// <para>
/// The server's response includes its supported protocol versions, capabilities, implementation
/// information, and optional usage instructions.
/// </para>
/// <para>
/// Servers SHOULD implement this method. Legacy clients MAY ignore it. Clients on the 2026-07-28 revision
/// typically call this once during connection establishment.
/// Servers SHOULD implement this method. Initialize-handshake clients MAY ignore it. Clients on the
/// 2026-07-28 revision typically call this once during connection establishment.
/// </para>
/// </remarks>
public const string ServerDiscover = "server/discover";
@ -179,7 +179,7 @@ public static class RequestMethods
/// <remarks>
/// <para>
/// This RPC is introduced in the 2026-07-28 protocol revision (SEP-2575) and replaces the unsolicited
/// HTTP GET endpoint and the legacy <see cref="ResourcesSubscribe"/> / <see cref="ResourcesUnsubscribe"/>
/// HTTP GET endpoint and the initialize-handshake <see cref="ResourcesSubscribe"/> / <see cref="ResourcesUnsubscribe"/>
/// request methods.
/// </para>
/// <para>