# Atlas MCP error: Connection closed mid-session

> Check whether the MCP server process died, raise the `timeout` on the server entry, then restart Atlas or toggle the server off and on in the MCP dialog.

An Atlas MCP server flips to failed with the error "Connection closed" because MCP.watch installs an onclose handler on the live client, and when the transport drops (server crash, stdio process exit, network reset) that handler rewrites the server's status to failed. Fix it by checking whether the MCP server process died, looking for an idle timeout or proxy on remote servers, raising the `timeout` on the server entry, and restarting Atlas to force a fresh connect.

## Symptom

A previously connected MCP server flips to failed with the error "Connection closed", and its tools stop being offered to the model partway through a session.

## Cause

MCP.watch installs an onclose handler on the live client. When the transport drops (server crash, stdio process exit, network reset) the handler rewrites that server's status to failed with error "Connection closed".

## Fix

1. Check whether the MCP server process died: for a local server, run its command manually and watch stderr (StdioClientTransport is created with stderr: "pipe").
2. For a remote server, look for an idle-timeout or a proxy that closes long-lived Streamable HTTP or SSE connections.
3. Increase the `timeout` on the server entry if long tool calls are being cut off.
4. Restart Atlas to force a fresh connect, or toggle the server off and on in the MCP dialog.

## Why does Atlas report Connection closed for an MCP server

Atlas reports "Connection closed" because MCP.watch installs an onclose handler on the live MCP client. When the transport drops, from 1 of 3 ordinary causes, a server crash, a stdio process exit, or a network reset, that handler rewrites the server's status to failed with the error "Connection closed".

The word mid-session is the whole story here. The Atlas MCP server did connect. Its tools were exposed to the agent and were working. Then the transport went away underneath a live client, and MCP.watch caught the close event. That rules out a configuration problem: your `command` array or `url` is fine, because the initial connect succeeded. Something ended the connection after the fact. Atlas connects to Model Context Protocol servers and exposes their tools to the agent, so the visible consequence is that those tools stop being offered to the model partway through your work.

## How to fix Connection closed on a local stdio MCP server

For a local Atlas MCP server, run the server's command manually and watch stderr. StdioClientTransport is created with stderr set to "pipe", so a crashing process writes its real error there rather than into Atlas, and 1 exiting stdio process is enough to trigger the MCP.watch onclose handler and the failed status you saw.

Local MCP servers in Atlas die for ordinary reasons: an uncaught exception, an out-of-memory kill, a missing dependency that only loads on a specific code path, or a process that closes stdin. Because StdioClientTransport is created with stderr: "pipe", the diagnostic you need is on the server's stderr, not in Atlas. Run the command by hand, exercise the same tool the agent was calling when the connection dropped, and read what the process prints as it dies. Fixing the crash in the server is the actual fix; restarting Atlas only re-establishes a connection that will drop again.

## How to fix Connection closed on a remote MCP server

For a remote Atlas MCP server, look for an idle timeout or a proxy that closes long-lived Streamable HTTP or SSE connections. Load balancers and corporate proxies routinely cut connections that sit quiet, and 1 network reset is enough to trigger the MCP.watch onclose handler and flip the server to failed.

Remote MCP transports in Atlas are long-lived by design, which is exactly what an aggressive intermediary dislikes. The signature is a connection that stays healthy while you are actively using tools and drops during a quiet stretch, or one that dies at a suspiciously round interval. Check the idle timeout on any proxy, gateway, or load balancer between Atlas and the server, and check whether that layer supports Streamable HTTP or SSE at all. Some proxies buffer streaming responses and close them. Raising the `timeout` on the Atlas server entry does not stop an intermediary from closing the socket, so fix the intermediary.

## When to raise the timeout on an Atlas MCP server entry

Raise the `timeout` on an Atlas MCP server entry in exactly 1 case: long tool calls are being cut off. A tool that legitimately takes a long time to return can outlast the configured timeout, and the resulting drop surfaces through the MCP.watch onclose handler as status failed with the error "Connection closed".

Diagnose before you tune. If the connection consistently dies during one slow tool and survives everything else, `timeout` is the right knob and raising it on that server entry is the fix. If the connection dies at random, or dies while idle, `timeout` is not the problem and raising it just delays the same failure. For a local server, watching stderr while the slow tool runs settles the question quickly, since StdioClientTransport is created with stderr: "pipe". A crashing process and a timing out call look identical from the status row but need opposite fixes.

## How to reconnect an MCP server in Atlas after Connection closed

Reconnect an Atlas MCP server after a "Connection closed" failure in one of 2 ways: restart Atlas to force a fresh connect, or toggle the server off and on in the MCP dialog. Both rebuild the client, and MCP.watch installs a new onclose handler on the fresh connection.

Toggling the server in the Atlas MCP dialog is the faster option and does not cost you the session. Restarting Atlas is the heavier hammer and is worth reaching for when several servers dropped at once, which usually points at the network rather than at any single server. Be honest with yourself about what reconnecting achieves: it restores the tools, but it does not fix a server that crashes on a particular tool call or a proxy that closes idle connections. Expect the same drop again unless the underlying process or intermediary was actually fixed first.

## FAQ

### What does Connection closed mean for an MCP server in Atlas?

It means the transport dropped on a live client. MCP.watch installs an onclose handler, and when the transport goes away from a server crash, a stdio process exit, or a network reset, the handler rewrites that server's status to failed with error "Connection closed".

### Why did my Atlas MCP tools disappear mid-session?

The MCP server's transport dropped and the MCP.watch onclose handler flipped its status to failed. Atlas exposes Model Context Protocol tools to the model only for connected servers, so the tools stop being offered until the server reconnects.

### How do I see why my local MCP server crashed in Atlas?

Run the server's command manually and watch stderr. StdioClientTransport is created with stderr: "pipe", so the crashing process writes its real error there rather than into Atlas.

### Can a proxy cause Connection closed on an Atlas MCP server?

Yes. Proxies and load balancers frequently close long-lived Streamable HTTP or SSE connections on an idle timeout, and that network reset triggers the MCP.watch onclose handler in Atlas.

### Will raising timeout fix Connection closed in Atlas?

Only when long tool calls are being cut off. Increase the `timeout` on the server entry in that case. A crashing server process or a proxy closing idle connections will not be fixed by a higher timeout.

### How do I reconnect an MCP server in Atlas without restarting?

Toggle the server off and on in the Atlas MCP dialog. That forces a fresh connect and a new MCP.watch onclose handler, without losing your session.

### Is Connection closed a config problem in Atlas?

No. The server connected successfully first, so the `command` array or `url` is valid. The transport dropped afterwards, which points at the server process, the network, or an intermediary.

---

Canonical HTML: https://runatlas.sh/resources/troubleshooting/mcp-connection-closed
Source of truth: aeo_pages row `/resources/troubleshooting/mcp-connection-closed` (segment: Troubleshooting) (this file is generated from it, never hand-edited).
Licence: Atlas is proprietary with a free core. It is not open source and there is no public source repository.
