Urgent.News

What's breaking now, across thousands of outlets.

Tech

MCP connection errors explained: 404 on /sse, 406 Not Acceptable, session 400s, 402

MCP Streamable HTTP is one URL. The client POSTs JSON-RPC to it and may open a GET stream on the same URL; nothing else is part of the address. Most connection failures we see in our own server log are a client talking to a different address than the one it was given, or sending the wrong headers. Here is what each status means and the fix, with the exact messages the official TypeScript and…

MCP Streamable HTTP operates over a single URL. Client applications send JSON-RPC requests via a POST, and optionally establish a GET stream back to the same URL. Connection issues often arise from clients connecting to the wrong address or sending inappropriate headers.

The most common HTTP status codes encountered are:

404 - Not Found: This occurs when a client speaks the older HTTP+SSE protocol, attempting to access a GET stream URL, or when using /sse or /mcp appended to the URL. Most SDKs will handle this automatically.

406 - Not Acceptable: The client must accept both application/json and text/event-stream content types. A POST must specify Accept: application/json, text/event-stream, while a GET stream requires Accept: text/event-stream. Curl and many HTTP libraries default to */*, which can cause mismatches.

415 - Unsupported Media Type: The Content-Type header must be application/json for the request body. Form-encoded data, missing headers, or text/plain payloads will raise this error.

400 - Bad Request: This signifies a few issues - the server hasn't been initialized, a session ID was omitted, or the client has not yet initialized the stateful server. After a server restart, the session header may no longer be recognized, requiring a new initialize request.

405 - Method Not Allowed on GET: The server may decline the standalone GET stream. A client that receives a 405 should continue using POST requests. For browsers, the GET with Accept: text/html typically triggers a human webpage.

402 - Payment Required: On pay-per-call servers, a 402 response includes a PaymentRequired object, specifying the amount, currency, and a payment URL. Clients without x402 support will see a tool error with the price displayed. Tanod servers charge for each call, issuing a quote only after the daily allowance is exhausted.

In summary, for MCP Streamable HTTP connections, always use the provided URL exactly as published, include the required headers, and ensure proper session initialization. Pay attention to the status codes returned, as they provide clear guidance on correcting the issue.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Apple's October 13 Launch: What's Coming

Apple is planning to introduce new products on Tuesday, October 13, Apple marketing chief Greg Joswiak announced today . It won't be a traditional Apple event, but Apple has invited some members of…

More from Thursday 8 October →