Rename MinVersionForStandardHeaders to DraftProtocolVersion (#1603)
This commit is contained in:
parent
168c37179d
commit
711e5bb3b7
1 changed files with 20 additions and 7 deletions
|
|
@ -10,14 +10,27 @@ namespace ModelContextProtocol.Protocol;
|
|||
internal static class McpHttpHeaders
|
||||
{
|
||||
/// <summary>
|
||||
/// The minimum protocol version that requires standard MCP request headers.
|
||||
/// The draft MCP protocol version string used to gate behaviors that are only enabled
|
||||
/// for clients negotiating the in-progress draft specification.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Servers enforce missing <c>Mcp-Method</c> and <c>Mcp-Name</c> headers as errors only when
|
||||
/// the client's <c>MCP-Protocol-Version</c> header indicates this version or later.
|
||||
/// Clients using older versions are not required to send these headers.
|
||||
/// Behaviors currently gated on this version include:
|
||||
/// <list type="bullet">
|
||||
/// <item><description>
|
||||
/// Requiring the standard MCP request headers (<c>Mcp-Method</c> and <c>Mcp-Name</c>)
|
||||
/// on Streamable HTTP POST requests; servers treat missing headers as errors only when
|
||||
/// the client's <c>MCP-Protocol-Version</c> header matches this value.
|
||||
/// </description></item>
|
||||
/// <item><description>
|
||||
/// Reporting unresolvable resource URIs from <c>resources/read</c> with the standard
|
||||
/// JSON-RPC <see cref="McpErrorCode.InvalidParams"/> (-32602) code rather than the
|
||||
/// legacy <see cref="McpErrorCode.ResourceNotFound"/> (-32002) code.
|
||||
/// </description></item>
|
||||
/// </list>
|
||||
/// The associated helpers perform exact ordinal matches against this single value rather
|
||||
/// than any ordered comparison.
|
||||
/// </remarks>
|
||||
public static readonly string MinVersionForStandardHeaders = "DRAFT-2026-v1";
|
||||
public const string DraftProtocolVersion = "DRAFT-2026-v1";
|
||||
|
||||
/// <summary>The session identifier header.</summary>
|
||||
public const string SessionId = "Mcp-Session-Id";
|
||||
|
|
@ -67,7 +80,7 @@ internal static class McpHttpHeaders
|
|||
/// </summary>
|
||||
private static readonly HashSet<string> s_versionsWithStandardHeaders = new(StringComparer.Ordinal)
|
||||
{
|
||||
MinVersionForStandardHeaders,
|
||||
DraftProtocolVersion,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -82,5 +95,5 @@ internal static class McpHttpHeaders
|
|||
/// rather than the legacy <see cref="McpErrorCode.ResourceNotFound"/> (-32002).
|
||||
/// </summary>
|
||||
internal static bool UseInvalidParamsForMissingResource(string? protocolVersion)
|
||||
=> string.Equals(protocolVersion, MinVersionForStandardHeaders, StringComparison.Ordinal);
|
||||
=> string.Equals(protocolVersion, DraftProtocolVersion, StringComparison.Ordinal);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue