[BUG] MCP client hangs when server returns session-expired error (-32004)

Resolved 💬 2 comments Opened Dec 21, 2025 by hortovanyi Closed Dec 21, 2025

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When an MCP server returns JSON-RPC error -32004 "Unknown session" (after session expiry), Claude Code hangs instead of automatically reconnecting.

What Should Happen?

Claude should reconnect creating a new session

Error Messages/Logs

Steps to Reproduce

## Steps to Reproduce

  1. Connect Claude Code to an MCP server that has session expiry (e.g., 30 minutes)
  2. Don't use the MCP server for longer than the expiry period
  3. Try to call an MCP tool
  4. Claude Code hangs indefinitely

## Expected Behavior
Claude Code should detect the session-expired error and automatically:

  1. Re-initialize the connection
  2. Retry the failed request

## Actual Behavior
Claude Code hangs. The only fix is running /mcp reconnect <server-name>.

## Environment

  • Claude Code version: 2.0.75+
  • OS: macOS
  • MCP transport: Streamable HTTP (SSE)

## Workaround
Increase server-side session timeout to 4+ hours to reduce occurrence.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.0.75

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗