This repository was archived by the owner on Jul 13, 2026. It is now read-only.
fix(server): route all MCP-endpoint methods through the stateless handler (Cursor 404) - #48
Draft
mikemilla wants to merge 1 commit into
Draft
fix(server): route all MCP-endpoint methods through the stateless handler (Cursor 404)#48mikemilla wants to merge 1 commit into
mikemilla wants to merge 1 commit into
Conversation
…dler The local dev server mounted `statelessHandler` only on `POST /` and hand-rolled separate `GET /` and `DELETE /` routes to emit the 405s the MCP Streamable HTTP spec requires. That parallel-route pattern is exactly what got dropped in a prior deploy: with no `GET /` route, Express answers its default 404, which MCP clients (Cursor, the reference SDK) treat as a fatal "Failed to open SSE stream". `statelessHandler` already returns a spec-compliant 405 for any non-POST method, so route POST/GET/DELETE through the one handler instead. The 405 behavior is now owned by the handler and can't be dropped by accident. Also move the local dev port default 3000 -> 3939 (and update the README) to avoid colliding with other local dev servers. Spec: https://modelcontextprotocol.io/specification/2025-06-18/basic/transports Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Cursor (and other MCP clients) fail to connect to the hosted server with:
The client opens an SSE
GETon the MCP endpoint and receives a 404, which it treats as fatal.Root cause
Per the MCP Streamable HTTP transport spec, the MCP endpoint must answer a
GET(the client's optional server→client SSE stream) with eithertext/event-streamor405 Method Not Allowed. A stateless server never pushes on that stream, so 405 is correct. Any other non-2xx — notably Express's default 404 when noGETroute is registered — is fatal to the client.This dev server mounted
statelessHandleronly onPOST /and hand-rolled separateGET /andDELETE /routes to emit those 405s. That parallel-route pattern is fragile — the exact thing that can be dropped and leaveGET /falling through to a 404.Fix
statelessHandleralready returns a spec-compliant 405 for any non-POST method. RoutePOST/GET/DELETEon/through the one handler instead of maintaining parallel 405 routes, so the behavior is owned by the handler and can't be dropped by accident.Also bump the local dev port default
3000→3939(+ README) to avoid colliding with other local dev servers.Verification
Local server (
:3939):POST /initializeGET /(SSE open)DELETE /OPTIONS /Allow: POST,GET,HEAD,DELETE(CORS preflight preserved)Scope / follow-ups
server/). It does not servemcp.courier.com; the hosted server lives intrycourier/services(apps/mcp/service/http-api/src/app.ts).staging/ not yet deployed — that deploy is what actually fixes users. This PR keeps the repo's reference/dev server correct and in sync./registerdiscovery probes returning an HTML-bodied 404 that Cursor's client crashes parsing as JSON. Porting that handler intoserver/is a possible follow-up.@trycourier/courier-mcppackage change is needed — this is entirely the HTTP/Express layer.🤖 Generated with Claude Code