Inspector 0.17.0 direct connection fails on streamable HTTP: mcp-session-id header not exposed via CORS
Using MCP Inspector 0.17.0's direct-connection feature against a stateful streamable HTTP server hosted on a different origin, the initialize request completes but the server's session ID is never read: the
mcp-session-idresponse header is not accessible from the JavaScriptfetchresponse, so the follow-up initialization notification is sent withoutMcp-Session-Idand fails with a 400. The header is visible in Chrome DevTools but not to the Inspector. How do I make the server expose the session ID (and protocol version) headers to the Inspector?Originally asked on GitHub: https://github.com/modelcontextprotocol/inspector/issues/841
5 answers
Status: explained — the issue was closed as completed; a server-side CORS fix was confirmed to solve it.
The cause, described in the issue body, is the browser CORS restriction on response headers: when Inspector 0.17.0 runs in direct-connection mode against a server on a different origin,
fetchonly exposes the safelistedCache-Control,Content-Language,Content-Type,Expires,Last-Modified, andPragmaheaders. A stateful streamable HTTP server returns its session ID in themcp-session-idresponse header, so the Inspector never reads it, the session ID stays null, and the follow-up request goes out withoutMcp-Session-Id, producing a 400.The fix confirmed in the thread is to expose the header via CORS in your server or reverse proxy. The Caddy example that worked was:
localhost:8080 { header { Access-Control-Allow-Origin * Access-Control-Allow-Credentials true Access-Control-Allow-Methods * Access-Control-Allow-Headers * Access-Control-Expose-Headers "mcp-session-id" defer } root * public/ file_server log php_server }The same contributor also added
mcp-protocol-versionto the exposed headers, since the Inspector reads that value to resolve the protocol version, and proposed an Expresscors()middleware example (exposedHeaders: ["mcp-session-id", "mcp-protocol-version"]) for the TypeScript SDK — a proposal, not confirmed tested in the thread. Other commenters recommended documenting the requirement rather than changing SDK defaults; one noted that setting permissive CORS as a default is a security issue, so configure it deliberately in your own proxy or CDN. The thread also reports that the basic reference server (npx @modelcontextprotocol/server-everything streamableHttp) no longer works with Inspector direct mode.Did this work for you?What a GitHub user tried on GitHub (Didn't work)
Connected Inspector 0.17.0's direct-connection mode to a stateful streamable HTTP server on a different origin. The mcp-session-id response header was not exposed to the fetch response, the session ID stayed null, and the initialization notification was rejected with 400 because no Mcp-Session-Id header was sent.
Source: https://github.com/modelcontextprotocol/inspector/issues/841 (opens external site)
Did this work for you?What @soyuka tried on GitHub (Worked)
Served the server behind a Caddy reverse proxy with Access-Control-Expose-Headers "mcp-session-id" plus permissive CORS headers. A contributor confirmed this configuration solves the issue.
Did this work for you?What @fredericbarthelet tried on GitHub (Outcome unclear)
The contributor added mcp-protocol-version to the exposed headers and proposed an Express cors() middleware example (exposedHeaders: ["mcp-session-id", "mcp-protocol-version"]) as a possible SDK default. The Express snippet was not confirmed tested in the thread.
Did this work for you?What @greedy52 tried on GitHub (Didn't work)
Also tried the basic reference server with
npx @modelcontextprotocol/server-everything streamableHttpand reported that it no longer works with Inspector direct mode.Did this work for you?
Related questions
- MCP Inspector 0.10.2 sends null for unset optional params (error -32602)?
- Why does npx @modelcontextprotocol/inspector fail with 'mcp-inspector: command not found' after 0.10.0?
- How do I increase MCP Inspector's 10-second request timeout?
- MCP Inspector crashes with 'Controller is already closed' on fastmcp Streamable HTTP
- Why does the MCP Inspector Docker container refuse connections on localhost:6274, and how do I fix it?