@@ -166,14 +166,16 @@ void Register<TPrimitive>(McpServerPrimitiveCollection<TPrimitive>? collection,
166166
167167 /// <summary>
168168 /// Wraps <paramref name="inner"/> so that, for every JSON-RPC request, a built-in filter first
169- /// synchronizes server-side state (<see cref="_negotiatedProtocolVersion"/>,
170- /// <see cref="_clientCapabilities"/>, <see cref="_clientInfo"/>) from the per-request <c>_meta</c>
171- /// values projected onto <see cref="JsonRpcMessageContext"/> and validates the per-request protocol
172- /// version, before delegating to the user-supplied incoming filters.
169+ /// synchronizes server-side state (<see cref="_negotiatedProtocolVersion"/>, <see cref="_clientInfo"/>)
170+ /// from the per-request <c>_meta</c> values projected onto <see cref="JsonRpcMessageContext"/> and
171+ /// validates the per-request protocol version, before delegating to the user-supplied incoming filters.
173172 /// </summary>
174173 /// <remarks>
175174 /// Under the 2026-07-28 protocol revision (SEP-2575) there is no <c>initialize</c> handshake, so these values
176- /// MUST be populated per-request. For initialize-handshake clients the per-request values are absent and the built-in
175+ /// MUST be populated per-request. Per-request client capabilities and client info are consumed request-scoped
176+ /// by <see cref="DestinationBoundMcpServer"/> and are not read from server-wide state by request handlers. The
177+ /// shared <see cref="_clientInfo"/> write below is best-effort and used only to derive the session endpoint
178+ /// name for logging/telemetry. For initialize-handshake clients the per-request values are absent and the built-in
177179 /// filter is a no-op (the values were captured during the initialize handler).
178180 /// </remarks>
179181 private JsonRpcMessageFilter PrependMetaReadingFilter ( JsonRpcMessageFilter inner )
@@ -259,23 +261,16 @@ private JsonRpcMessageFilter PrependMetaReadingFilter(JsonRpcMessageFilter inner
259261
260262 ValidateRequestMethodBoundary ( request ) ;
261263
262- if ( context ? . ClientCapabilities is { } clientCapabilities && IsJuly2026OrLaterProtocol ( ) && HasStatefulTransport ( ) )
263- {
264- // Under the 2026-07-28 revision the per-request _meta envelope carries the client's FULL
265- // capabilities (SEP-2575), so a plain overwrite is correct. The IsJuly2026OrLaterProtocol() gate
266- // makes any initialize-handshake per-request envelope a no-op (capabilities stay as the
267- // initialize handshake established them); the HasStatefulTransport() gate keeps
268- // _clientCapabilities null under StreamableHttpServerTransport { Stateless = true }
269- // (where the same server instance handles every request, so persisting per-request
270- // capability state would both leak across requests and break the StatelessServerTests
271- // invariant that surfaces the "X is not supported in stateless mode" errors).
272- _clientCapabilities = clientCapabilities ;
273- }
274-
275264 if ( context ? . ClientInfo is { } clientInfo &&
276265 ( _clientInfo is null || ! string . Equals ( _clientInfo . Name , clientInfo . Name , StringComparison . Ordinal ) ||
277266 ! string . Equals ( _clientInfo . Version , clientInfo . Version , StringComparison . Ordinal ) ) )
278267 {
268+ // This shared write is best-effort and used only to derive the session endpoint name for
269+ // logging/telemetry. It is intentionally NOT read by request handlers on 2026-07-28+ sessions:
270+ // DestinationBoundMcpServer resolves ClientInfo (and ClientCapabilities) request-scoped from
271+ // the per-request _meta so concurrent requests never observe each other's values. Under a
272+ // draft stateful session with differing per-request client info, the last writer wins here,
273+ // which only affects the logged endpoint name and never the request-scoped values handlers see.
279274 _clientInfo = clientInfo ;
280275 endpointNameNeedsRefresh = true ;
281276 }
@@ -1884,7 +1879,7 @@ async ValueTask<TResult> InvokeScopedAsync(
18841879
18851880 private DestinationBoundMcpServer CreateDestinationBoundServer ( JsonRpcRequest jsonRpcRequest )
18861881 {
1887- var server = new DestinationBoundMcpServer ( this , jsonRpcRequest . Context ? . RelatedTransport ) ;
1882+ var server = new DestinationBoundMcpServer ( this , jsonRpcRequest . Context ? . RelatedTransport , jsonRpcRequest . Context ) ;
18881883
18891884 if ( _mrtrContextsByRequestId . TryRemove ( jsonRpcRequest . Id , out var mrtrContext ) )
18901885 {
@@ -1997,7 +1992,7 @@ private JsonRpcMessageFilter BuildMessageFilterPipeline(IList<McpMessageFilter>
19971992 {
19981993 // Ensure message has a Context so Items can be shared through the pipeline
19991994 message . Context ??= new ( ) ;
2000- var context = new MessageContext ( new DestinationBoundMcpServer ( this , message . Context . RelatedTransport ) , message ) ;
1995+ var context = new MessageContext ( new DestinationBoundMcpServer ( this , message . Context . RelatedTransport , message . Context ) , message ) ;
20011996 await current ( context , cancellationToken ) . ConfigureAwait ( false ) ;
20021997 } ;
20031998 } ;
@@ -2052,8 +2047,12 @@ internal bool HasStatefulTransport() =>
20522047 /// Used to gate the SEP-2663 Tasks extension, which only interoperates on the 2026-07-28 revision.
20532048 /// </summary>
20542049 private bool IsJuly2026OrLaterProtocolRequest ( JsonRpcRequest ? request ) =>
2050+ IsJuly2026OrLaterProtocolRequest ( request ? . Context ) ;
2051+
2052+ /// <inheritdoc cref="IsJuly2026OrLaterProtocolRequest(JsonRpcRequest?)"/>
2053+ internal bool IsJuly2026OrLaterProtocolRequest ( JsonRpcMessageContext ? requestContext ) =>
20552054 McpProtocolVersions . IsJuly2026OrLaterProtocolVersion (
2056- request ? . Context ? . ProtocolVersion ?? NegotiatedProtocolVersion ) ;
2055+ requestContext ? . ProtocolVersion ?? NegotiatedProtocolVersion ) ;
20572056
20582057 /// <inheritdoc />
20592058 public override bool IsMrtrSupported => ClientSupportsMrtr ( ) || HasStatefulTransport ( ) ;
0 commit comments