Repository navigation
Proposal: Make MCP identifiable on first request (media type and/or header) #1383
Replies: 4 comments 1 reply
Currently, MCP doesn't officially support WebSockets, so custom transport implementors should solve this problem in whichever way they think is best. (/cc @lmaccherone since you are proposing an official WebSockets transport in #1287.) However, we could address this problem specifically for the Streamable HTTP transport.
In my opinion, this seems like simplest and most straightforward solution for the Streamable HTTP transport. |
|
The current version of SEP-1287 includes a WS subprotocol (aka Sec-Websocket-Protocol) for identifying that it's MCP which is your primary motivator. It does not include the version. I will add that to SEP-1287 before I present on Monday. I will probably tweak your example a bit to |
|
@jonathanhefner @lmaccherone , I’d like to ask the group to also consider the same issue for Streamable HTTP. Right now, MCP over HTTP requires parsing the body of the initialize request before you can even tell it’s MCP. In large-scale deployments (e.g., DPI proxies handling billions of packets), this creates real cost and inefficiency compared to a simple header check. Enterprises and security-sensitive environments often still prefer HTTP over WS due to:
For consistency across transports, could we standardize that This would make Streamable HTTP symmetrical with WS (which uses Sec-WebSocket-Protocol: mcp.version.YYYY-MM-DD), give immediate and unambiguous protocol identification, and avoid the need for deep body inspection. |
|
We've limited Discussions in this repository to meeting notes and are closing this thread. To continue the conversation, pick a channel from Contributor Communication. Thanks for posting. |
Uh oh!
There was an error while loading. Please reload this page.
Proposal: Make MCP identifiable on first request (media type and/or header)
Background
MCP over HTTP/WS currently requires a proxy or middleware to parse request bodies in order to recognize the protocol.
Specifically, the
initializerequest has no MCP-specific header or media type. This creates challenges for:From the second request onward, fields like
MCP-Session-IdandMCP-Protocol-Versionmake classification trivial — but the very firstinitializerequest is opaque.Problem
Content-Type: application/json).initializeResultor parse full JSON to confirm MCP, which is computationally expensive at scale.Proposal
Introduce one or more distinguishable signals that appear in the first MCP request, without requiring body parsing:
Media type
Content-Type: application/mcp+jsonapplication/vnd.mcp+jsoninitially → graduate to IANAapplication/mcp+json).New header (structured fields, RFC 8941)
MCP: ver="`2025-06-18`", client="`acme/1.2.3`"MCP-Protocol-Version(which is only present after init)./.well-known/mcpfor initialization.MCP-Protocol-Versionas a header on all requests (includinginitialize)MCP-Protocol-Versiononly appears after initialization.params.protocolVersioninside JSON).Sec-WebSocket-Protocol: mcp.2025-06-18Content-Type: text/event-stream; mcp=1Example (HTTP)
Alternatives considered
"method":"initialize"+"protocolVersion"in body (not robust, false positives).Backwards compatibility
application/jsonand missingMCPheaders for legacy clients.Benefits
Next steps
application/mcp+json+MCP:header.All reactions