[Bug] MCP Server Shutdown Failure on /exit Command in v1.0.63+

Status Closed — not planned
Maintainer reply None cached
Activity 11 comments · opened Aug 10, 2025 · closed Feb 7, 2026

Bug Description
I use the Claude Code CLI (npm @anthropic-ai/claude-code) v1.0.72 with a single local MCP Server. When I enter the /exit command, I get an error message in the terminal that "1 MCP server failed - see /mcp for more info". I downgraded to previous versions of Claude Code CLI and found that the MCP server failed messages started to appear in v1.0.63. It does not happen in v1.0.62 and has not been fixed as of v1.0.72

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 1.0.72
  • Feedback ID: eec1424d-b0be-4877-be73-bade01f7783a

Errors

<img width="1726" height="160" alt="Image" src="https://github.com/user-attachments/assets/2457b09c-29e4-411d-bdcd-fd9368d6f1e6" />

View original on GitHub ↗

11 Comments

github-actions[bot] · 1 year ago

Found 1 possible duplicate issue:

  1. https://github.com/anthropics/claude-code/issues/1935

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

Brandtweary · 11 months ago

+1 experiencing this same bug consistently across multiple MCP server implementations.

Environment Details:

  • OS: Pop!_OS 22.04 (Linux)
  • Claude Code Version: 1.0.119
  • Terminals tested: Konsole, Zed integrated terminal

Affected MCP Servers:
This bug occurs with every MCP server I've tested, regardless of implementation language:

  1. Python implementations:
  1. Node.js implementations:
  • @modelcontextprotocol/server-github
  • @modelcontextprotocol/server-filesystem
  1. Rust implementations:

Key Observations:

  • The error message "X MCP Server(s) Failed" appears on EVERY /exit command
  • No error details are logged anywhere accessible to users
  • The servers actually shut down cleanly, but Claude Code reports them as "failed"
  • This error originates in the Claude Code <-> MCP communication layer, not within the MCP servers themselves
  • The complete lack of logging makes this impossible to debug from the user side

Impact:
Beyond being a false positive, the lack of any error logging means users cannot distinguish between:

  • This cosmetic shutdown bug
  • Actual server failures
  • Configuration issues
  • Connection problems

At minimum, Claude Code should log WHY it thinks servers are failing. The current state leaves users guessing about what might be wrong, making MCP server development unnecessarily difficult.

This bug has been present since v1.0.63 (over a month) and affects all platforms and all MCP server implementations. Given that MCP is a core feature of Claude Code, proper shutdown handling and error logging deserve attention.

jessealama · 9 months ago

+1 to this. I use the Zen MCP server (just one MCP) one a number of projects and also see the error message. Thinking that there must be something wrong, I've checked, using the /mcp command, but everything looks clean. Sessions often delegate to Zen, which works cleanly, but I always see the error message. In fact, I can even launch a fresh session, do /mcp and see that Zen is connected, then do /exit and get the message.

One could perhaps get some insight into this issue by setting up a dummy MCP server that frequently logs its state, or at least logs whenever core MCP functions are invoked, or OS-level signals sent, from Claude Code.

jessealama · 9 months ago

I think we could remove the macos tag here -- @Brandtweary indicated that he's on Linux.

github-actions[bot] · 8 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

jessealama · 8 months ago

Yes, this issue still exists in v2.0.75.

woody1961 · 8 months ago

Still an issue in 2.0.76

cobach · 7 months ago

Additional Evidence from #16744

We did extensive debugging on this issue and can confirm:

Root Cause

Claude Code sends SIGKILL directly to MCP server processes without first:

  1. Closing stdin (as per MCP protocol spec)
  2. Sending SIGTERM to allow graceful shutdown

Proof: Official Anthropic MCP Server Also Fails

We tested with @modelcontextprotocol/server-filesystem (Anthropic's official reference server) and it also reports failure on /exit.

This confirms the bug is in Claude Code's shutdown logic, not in any specific MCP server implementation.

Debugging Attempts (all failed)

We added comprehensive shutdown handlers:

  • SIGTERM, SIGINT, SIGHUP signal handlers
  • stdin end/close/error event listeners
  • Parent PID watchdog (polling every 500ms)
  • stdin.readable polling (every 100ms)
  • beforeExit, uncaughtException, unhandledRejection handlers

None of these handlers ever fire - the process is killed instantly with SIGKILL.

MCP Protocol Spec Reference

"For the stdio transport, the client SHOULD send SIGTERM to the child process. The client can send SIGKILL to forcefully terminate if the child does not exit within a reasonable time."

Claude Code appears to skip SIGTERM entirely.

---
Closing #16744 as duplicate. 👍 on this issue.

github-actions[bot] · 6 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

marcindulak · 6 months ago

This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.

github-actions[bot] · 6 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.