WEIR

MCP Connection Closed: Fix It and 5 Other MCP Errors (2026)

What MCP connection closed, request timed out, session not found, HTTP 405 and 401 errors mean, with each SDK's exact wording, the cause and the fix.


Published · Updated · 7 min read

Cover image: Match the message, not the code

MCP connection closed means the client lost its link to the server before it answered, usually because a local server process exited.

Below, each error has its exact SDK wording, cause and fix, from the source or our runs on 26 November 2026. We run Weir, our test server.

# bash or zsh: the command from your MCP config, stdin closed, stderr hidden
python server.py < /dev/null 2>/dev/null; echo "exit code: $?"

A healthy stdio server prints nothing, so you see only exit code: 0. Text above it means stdout pollution; a non-zero code means a crash.

To split client faults from server faults, connect a server known to work: Weir's MCP server at https://api.weirapp.io/mcp. Sign in free; its get_limits tool costs 0 credits and returned this:

{ "data": { "tier": "free", "rateLimitPerMinute": 30 }, "meta": { "creditsCharged": 0 } }
Table of seven MCP error messages with the usual cause and the fix for each one
The errors at a glance

MCP connection closed (-32000): the other side went away

The client's transport ended before a reply came. TypeScript SDK 1.x prints MCP error -32000: Connection closed, while its 2.4.0 client and Python's mcp 2.3.0 print just Connection closed.

We reproduced it by launching a "server" that exits at once.

Terminal output of four MCP client errors reproduced with the Python SDK, and one success
Our script on 26 November 2026, with no API key
  • The process dies at start or during initialize. A wrong path, a missing runtime or an unset variable. The test at the top shows a non-zero code.
  • It crashes later. Its stack trace goes to stderr, which the client keeps in its MCP log.
  • A remote link drops. Claude Code then says MCP server "<name>" connection closed before the tool call was answered.

Stdout matters too. The MCP spec says a stdio server "MUST NOT write anything to its stdout that is not a valid MCP message."

When our test server printed a banner, mcp 2.3.0 logged Failed to parse JSONRPC message from server and carried on. A stricter client may not, so log to stderr.

On Windows, an ENOENT error naming ${APPDATA} means the server needs APPDATA in its env block, per the MCP site's guide.

MCP server disconnected in Claude Desktop? Read the log

"Disconnected" is the same event seen from the app, and the log says why.

  • Claude Desktop: the MCP site puts its logs in ~/Library/Logs/Claude on macOS and %APPDATA%\Claude\logs on Windows. mcp.log holds connection failures; mcp-server-NAME.log holds the server's stderr.
  • Claude Code: claude mcp list shows ✘ Failed to connect with the error. Mid-session you see MCP server "<name>" disconnected · open /mcp to reconnect.
  • Cursor: its docs point to the Output panel's "MCP Logs".

In a Claude Desktop log posted to the TypeScript SDK's issue #554, the telling line was "Server transport closed unexpectedly, this is likely due to the process exiting early." Our Claude Desktop config guide covers the config file.

MCP error -32001: request timed out

The client stopped waiting. TypeScript SDK clients allow 60,000 milliseconds per request by default, and 1.x then prints MCP error -32001: Request timed out.

With a server that never answers and a 3-second limit, mcp 2.3.0 raised Request 'initialize' timed out. Raise the limit where your client reads it:

  • Claude Code: MCP_TIMEOUT=10000 claude sets a 10-second startup limit. A per-server timeout in milliseconds caps tool calls.
  • Codex: startup_timeout_sec and tool_timeout_sec in config.toml default to 10 and 60 seconds.
  • Your code: the request timeout option in TypeScript, or read_timeout_seconds in Python.

Our setup guides for Codex, OpenCode and LM Studio show where each config file lives.

MCP session not found, invalid session ID or session terminated

These come from Streamable HTTP servers that keep sessions, which protocol versions 2025-03-26 to 2025-11-25 allowed.

The server hands out an Mcp-Session-Id. Once it ends a session, the 2025-11-25 spec says it must answer that ID with a 404, and the client must start a new one.

  • TypeScript SDK 1.32.2 servers: Session not found with a 404, or Bad Request: Mcp-Session-Id header is required with a 400.
  • Python SDK 2.3.0 servers: Session not found, or Not Found: Invalid or expired session ID.
  • The TypeScript README example, up to 1.23.1: Invalid or missing session ID with a 400.
  • Python clients: mcp 1.30.0 turns any 404 into Session terminated, and 2.3.0 does so when a session's 404 carries no JSON-RPC error.

The usual causes: the server restarted, a load balancer sent you to another copy, or the session sat idle. Python SDK servers end idle sessions after 1,800 seconds by default.

Reconnect first. If you run the server, make it stateless: sessionIdGenerator: undefined in TypeScript, stateless_http=True in Python. Revision 2026-07-28 dropped sessions, and Weir never sends a session ID.

Streamable HTTP error HTTP 405: the URL doesn't take POST

A 405 on a POST means that URL doesn't take MCP messages. The server may speak only the old HTTP+SSE transport, which the spec says can refuse a POST with 400, 404 or 405. TypeScript's Streamable HTTP client words it by version:

up to 1.23.1:  Error POSTing to endpoint (HTTP 405): <response body>
from 1.24.0:   Streamable HTTP error: Error POSTing to endpoint: <response body>

From 1.24.0 the status moves to the error's code, while the SSE client still uses the first form. If the server only speaks HTTP+SSE, set your client to sse, or use its Streamable HTTP URL if it has one.

A 405 on a GET is normal for a Streamable HTTP client, which the spec allows and the TypeScript client ignores. A client set to sse fails there, so switch it to http. Weir answers a GET like this:

$ curl -s https://api.weirapp.io/mcp
{"jsonrpc":"2.0","id":null,"error":{"code":-32000,"message":"Method not allowed. Send JSON-RPC with POST."}}

Our remote MCP server URL guide shows where the URL and transport go in each app.

MCP 401 unauthorized: read what the server asks for

A 401 means the server refused your credential, and OAuth clients start sign-in from its WWW-Authenticate header. Weir's /mcp gave these on 26 November 2026:

no Authorization header          Authorization is required.
Authorization: Token abc         Send the credential as `Authorization: Bearer <token>`.
Authorization: Bearer not-a-key  The credential is not a Weir access token or API key.
  • A key in X-Api-Key gets the first answer. Weir's /mcp reads only Authorization.
  • Extra spaces after Bearer are fine. Our two-space test reached the key check.
  • Python hides the 401. mcp 2.3.0 called it Server returned an error response, and our Python MCP client guide adds a hook that prints it.

Claude Code marks such a server ! Needs authentication. For claude.ai, see why a Claude custom connector is not working. Broken imports after pip install -U mcp have their own guide.

The same MCP error in different words, by SDK

The latest releases, as of 26 November 2026, word one failure three ways: TypeScript from the source, Python from our runs.

Failure TypeScript 1.32.2 TypeScript 2.4.0 Python mcp 2.3.0
Transport ended MCP error -32000: Connection closed Connection closed Connection closed
No reply in time MCP error -32001: Request timed out Request timed out Request 'initialize' timed out
POST got a 401 Streamable HTTP error: Error POSTing to endpoint: … Error POSTing to endpoint: … Server returned an error response
Wrong path (404) Streamable HTTP error: Error POSTing to endpoint: … Error POSTing to endpoint: … Not Found

So a code alone misleads. TypeScript servers also send -32000 for a missing session ID, and -32001 with Session not found.

When not to use Weir's server as a test

  • Your bug is in a local stdio server. A remote server can't show it, so use the test at the top.
  • You need to reproduce session errors. Weir runs stateless and never issues a session ID.
  • You want to post to X (Twitter). Weir reads public data only and isn't licensed by X, so access can change.

FAQ

What does MCP error -32000 mean?

In TypeScript SDK 1.x and Python's mcp, -32000 is the code for a closed connection. Servers reuse it too, for Weir's 405 and for a missing session ID, so read the message.

Why does my MCP server keep disconnecting in Claude Desktop?

Usually the server process exited or crashed. Read the last lines of mcp.log and the server's mcp-server-NAME.log before the disconnect. Then run its command with the test at the top, which also catches stray stdout.

Can a remote MCP server work without auth?

Yes, and then no 401 ever starts a sign-in. Weir's docs server at https://docs.weirapp.io/api/mcp works that way: our mcp 2.3.0 client listed its 3 tools with no key. It tests your transport apart from your auth.

Sources

All checked on 26 November 2026: