Repository navigation
Context object (layered, per-request) #2895
Description
Activity
- addedv2Affects the v2 line (2.x on main)Affects the v2 line (2.x on main)spec-2026-07-28Concerns the SDK's implementation of the 2026-07-28 MCP spec revisionConcerns the SDK's implementation of the 2026-07-28 MCP spec revision
on Jun 17, 2026 - added a parent issue
on Jun 17, 2026 Shipped in v2.0.0b1: typed per-transport context, per-request client identity/capabilities/version from the envelope, the per-request logLevel gate, and OTel/user meta coexistence. This issue's conformance bar — the per-request-logging and capability-enforcement checks inside
server-statelessrunning and passing — is met. Some context-API ergonomic refinements remain tracked as post-beta polish.Hello @maxisbey , I can still reproduce a request-scoped
notifications/messageonv2.0.0b1when the originating 2026-07-28 request does not includeio.modelcontextprotocol/logLevel.I reproduced this with the
simple-streamablehttp-statelessexample server onv2.0.0b1(0da9092). The request used a valid 2026-07-28 envelope and the requiredMcp-MethodandMcp-Nameheaders; the only relevant field omitted from_metawasio.modelcontextprotocol/logLevel:{ "jsonrpc": "2.0", "id": 1001, "method": "tools/call", "params": { "name": "start-notification-stream", "_meta": { "io.modelcontextprotocol/protocolVersion": "2026-07-28", "io.modelcontextprotocol/clientInfo": {"name": "repro", "version": "0.1.0"}, "io.modelcontextprotocol/clientCapabilities": {} }, "arguments": {"interval": 1, "count": 1, "caller": "rc-repro"} } }The request returned HTTP 200 and emitted the following request-scoped log notification on that request's response stream before the final response:
{"jsonrpc":"2.0","method":"notifications/message","params":{"level":"info","logger":"notification_stream","data":"Notification 1/1 from caller: rc-repro"}}The reproduced example path calls
ctx.session.send_log_message(..., related_request_id=ctx.request_id).ServerSession.send_log_message()forwards the log notification through the request-scoped channel, but I do not see a check forio.modelcontextprotocol/logLevelin the originating request's_meta.Context.log()also appears to send a request-scopednotifications/messagewithout consulting that metadata.Since #2895 lists the per-request
logLevelgate as completed, I wanted to flag that this request-scopedServerSession.send_log_message()path still reproduces onv2.0.0b1. Is this an uncovered path in the current implementation, or am I missing another condition required for the gate to apply?
The handler-facing context: per-request client identity/capabilities/version reachable from handlers, transport info under a namespace, legacy session surface quarantined. Several other issues in this milestone add fields to this object, so settling its shape early unblocks them.
What's in it
ctx.transport.…; legacy-only verbs/state quarantined)._metain the modern era, from the connection in legacy).logLevelgate: nonotifications/messageunless the request opted in.meta=keys coexist with the envelope.Requestcarrier; auth/headers reachable.Conformance
server-statelessrun (not skip) and passDependencies
References