Skip to content

Commit a53350a

Browse files
halter73Copilot
andcommitted
Address PR review feedback
- WriteUnsupportedProtocolVersionErrorAsync: anchor the prose message to the July2026 floor ("Starting with protocol version ...") instead of echoing client input, while reporting the actual requested MCP-Protocol-Version header in the structured UnsupportedProtocolVersionErrorData.Requested field for diagnostics/fallback. - Rename July2026Post_WithUnsupportedProtocolVersionHeader_Returns400_With_Minus32004 to ...Minus32022 to match the renumbered error code. - Fix mid-sentence capitalization of "introduced" in two McpServerImpl XML docs. - Correct MetaKeys.ProtocolVersion remark: header/body version mismatches are rejected with HeaderMismatch, not UnsupportedProtocolVersion. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b898250 commit a53350a

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/ModelContextProtocol.AspNetCore/StreamableHttpHandler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,16 +693,17 @@ private static bool ValidateProtocolVersionHeader(HttpContext context, [NotNullW
693693
/// </summary>
694694
private static Task WriteUnsupportedProtocolVersionErrorAsync(HttpContext context)
695695
{
696+
var requestedProtocolVersion = context.Request.Headers[McpProtocolVersionHeaderName].ToString();
696697
var errorDetail = new JsonRpcErrorDetail
697698
{
698699
Code = (int)McpErrorCode.UnsupportedProtocolVersion,
699-
Message = $"Bad Request: The protocol revision '{McpHttpHeaders.July2026ProtocolVersion}' does not support Streamable HTTP sessions and is not supported when the server is configured with sessions (HttpServerTransportOptions.Stateless = false). " +
700+
Message = $"Bad Request: Starting with protocol version '{McpHttpHeaders.July2026ProtocolVersion}', Streamable HTTP does not support sessions and is not supported when the server is configured with sessions enabled (HttpServerTransportOptions.Stateless = false). " +
700701
"Use the initialize handshake with a protocol version that still supports sessions instead.",
701702
Data = JsonSerializer.SerializeToNode(
702703
new UnsupportedProtocolVersionErrorData
703704
{
704705
Supported = s_sessionSupportingProtocolVersions,
705-
Requested = McpHttpHeaders.July2026ProtocolVersion,
706+
Requested = requestedProtocolVersion,
706707
},
707708
GetRequiredJsonTypeInfo<UnsupportedProtocolVersionErrorData>()),
708709
};

src/ModelContextProtocol.Core/Protocol/MetaKeys.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public static class MetaKeys
1010
/// </summary>
1111
/// <remarks>
1212
/// Introduced by the 2026-07-28 protocol revision (SEP-2575). For HTTP transports, the value MUST
13-
/// match the <c>MCP-Protocol-Version</c> header. Servers reject mismatched versions with
14-
/// <see cref="McpErrorCode.UnsupportedProtocolVersion"/>.
13+
/// match the <c>MCP-Protocol-Version</c> header. Servers reject a header/body mismatch with
14+
/// <see cref="McpErrorCode.HeaderMismatch"/>.
1515
/// </remarks>
1616
public const string ProtocolVersion = "io.modelcontextprotocol/protocolVersion";
1717

src/ModelContextProtocol.Core/Server/McpServerImpl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ private void ConfigureInitialize(McpServerOptions options)
391391
}
392392

393393
/// <summary>
394-
/// Registers the <c>server/discover</c> request handler Introduced by the 2026-07-28 protocol revision (SEP-2575).
394+
/// Registers the <c>server/discover</c> request handler introduced by the 2026-07-28 protocol revision (SEP-2575).
395395
/// </summary>
396396
/// <remarks>
397397
/// The handler is registered unconditionally so legacy clients can probe it too. It returns the server's
@@ -421,7 +421,7 @@ private void ConfigureDiscover(McpServerOptions options)
421421
}
422422

423423
/// <summary>
424-
/// Registers the <c>subscriptions/listen</c> request handler Introduced by the 2026-07-28 protocol revision (SEP-2575).
424+
/// Registers the <c>subscriptions/listen</c> request handler introduced by the 2026-07-28 protocol revision (SEP-2575).
425425
/// </summary>
426426
/// <remarks>
427427
/// <para>

tests/ModelContextProtocol.AspNetCore.Tests/RawHttpConformanceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public async Task ServerDiscover_RawPost_ReturnsDiscoverResult()
136136
}
137137

138138
[Fact]
139-
public async Task July2026Post_WithUnsupportedProtocolVersionHeader_Returns400_With_Minus32004()
139+
public async Task July2026Post_WithUnsupportedProtocolVersionHeader_Returns400_With_Minus32022()
140140
{
141141
await StartAsync();
142142

0 commit comments

Comments
 (0)