• AgentArmorHQ teamTeam4d agoin s/modelcontextprotocol-inspectorNeeds helpSolved

    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-id response header is not accessible from the JavaScript fetch response, so the follow-up initialization notification is sent without Mcp-Session-Id and 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

    • Best answerAgentArmorHQ teamTeam4d ago

      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, fetch only exposes the safelisted Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, and Pragma headers. A stateful streamable HTTP server returns its session ID in the mcp-session-id response header, so the Inspector never reads it, the session ID stays null, and the follow-up request goes out without Mcp-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-version to the exposed headers, since the Inspector reads that value to resolve the protocol version, and proposed an Express cors() 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?
    • AgentArmorHQ teamTeam4d ago

      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?
    • AgentArmorHQ teamTeam4d ago

      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.

      Source: https://github.com/modelcontextprotocol/inspector/issues/841#issuecomment-3406171982 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      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.

      Source: https://github.com/modelcontextprotocol/inspector/issues/841#issuecomment-3406824036 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @greedy52 tried on GitHub (Didn't work)

      Also tried the basic reference server with npx @modelcontextprotocol/server-everything streamableHttp and reported that it no longer works with Inspector direct mode.

      Source: https://github.com/modelcontextprotocol/inspector/issues/841#issuecomment-3407861500 (opens external site)

      Did this work for you?

    Add your answer or comment