Troubleshooting

Atlas MCP error: Connection closed mid-session

Updated 6 min read

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.

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.

How to fix it

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

Frequently asked questions

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.

Try Atlas in your terminal

The terminal-native AI coding agent. Free core, single binary.

Install Atlas

Related guides

Atlas for Go in 2026

Atlas, the terminal-native AI coding agent, empowers Go developers in 2026 with intelligent code understanding, safe refactoring, and robust testing capabilities.

Atlas with Kimi K2 0711: The Original Trillion-Parameter Preview in 2026

Run Atlas on Kimi K2 0711 in 2026. Moonshot's original K2 preview costs $0.60 per Mtok input, $2.50 per Mtok output, with a 128K tokens (131,072) context.

Atlas with GPT-OSS 20B (hosted): the cheap slot that can still think in 2026

Run Atlas on GPT-OSS 20B (hosted) in 2026: $0.03/$0.14 per Mtok on DeepInfra, a 131,072 token context, reasoning on, and $0.00/$0.00 locally in LM Studio.

Atlas for Rust in 2026

Adopt Atlas, the terminal-native AI coding agent, for Rust development in 2026. Tackle borrow checker errors and clippy lints with Atlas's secure, approval-gated assistance.

Atlas with Llama 3.3 8B Instruct (Meta Llama API): The small_model Slot in 2026

Llama 3.3 8B Instruct (Meta Llama API) in Atlas for 2026: 128,000 tokens of context in an 8B-class model, a 4,096 token output cap, and why it belongs in small_model.

Atlas with Fireworks AI (gateway) in 2026: Buying Latency with Money

Fireworks AI (gateway) serves Atlas open models with fast-router tiers: DeepSeek V4 Flash at $0.14 / $0.28 per Mtok on a 1,000,000 token context.

Atlas vs Magic.dev: Terminal AI Coding Agents in 2026

Compare Atlas, the terminal-native AI coding agent with permission-gated tools and diff review, against Magic.dev's research claims of 100 million token context models in 2026.

Atlas with Qwen3-Coder Next (local via Ollama): the Top-Ranked Local Coder in 2026

Qwen3-Coder Next is the top-ranked local coding model of mid-2026: 262,144 token context, free self-hosted, or $0.22 / $1.80 per Mtok on Bedrock. Atlas setup and tradeoffs.

Browse this resource hub