fix: register GET/DELETE /mcp for Streamable HTTP (Inspector, Rider, and other clients)#79
Open
jekakmail wants to merge 1 commit into
Open
Conversation
Move GET and DELETE /mcp route registration out of the POST error handler so they are available at server startup. Streamable HTTP clients (MCP Inspector, JetBrains Rider MCP, Cursor, and others) send GET /mcp during connect to detect an optional SSE stream. Per the MCP transport spec, a stateless server without SSE must respond with HTTP 405 Method Not Allowed. Because handlers were only registered inside the POST /mcp catch block, GET /mcp returned 404 until a POST failed, and clients failed to connect with errors like "Expected status code 200 but was 404".
Author
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
DebugMCP exposes a Streamable HTTP endpoint at
POST /mcp(default port 3001).Several MCP clients perform an initial
GET /mcpduring connection to checkwhether the server offers a Server-Sent Events (SSE) stream for server-to-client
messages.
According to the MCP Streamable HTTP transport spec,
the endpoint must support both POST and GET. If the server is stateless and does
not provide SSE, it must respond to GET with HTTP 405 Method Not Allowed
(not 404).
In the current implementation,
app.get('/mcp')andapp.delete('/mcp')areregistered only inside the
catchblock of thePOST /mcphandler. Until a POSTrequest fails, no GET route exists, so clients receive HTTP 404.
Affected clients (confirmed in practice)
@modelcontextprotocol/inspector, Streamable HTTP)Connect failed (HTTP): Expected status code 200 but was 404onGET http://localhost:3001/mcpmcp-rider-tools, Streamable HTTP to external servers)http://localhost:3001/mcpstreamableHttp)initializePOST /mcpwith a validinitializerequest works; the failure is specific tothe missing or late-registered GET handler.
Fix
GET /mcpandDELETE /mcpat server startup (beforePOST /mcp).POSTcatchblock.How to verify
debugmcp.serverPort).MCP Inspector: Transport = Streamable HTTP, URL =
http://localhost:3001/mcp,headers
Accept: application/json, text/event-stream,Content-Type: application/json→ connect succeeds.JetBrains Rider: Settings → Tools → MCP Servers — add HTTP server
http://localhost:3001/mcpwith Streamable HTTP → tools/resources list loads.Notes
GET /sseremains 410 Gone (deprecated SSE endpoint); this change only fixes/mcp.