claude-code - 💡(How to fix) Fix [BUG] claude.ai custom MCP connectors send stale session IDs after service restart — tools load but all calls fail, disconnect/reconnect does not fix [3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48557Fetched 2026-04-16 06:56:49
View on GitHub
Comments
3
Participants
3
Timeline
10
Reactions
0
Author
Timeline (top)
labeled ×4commented ×3cross-referenced ×2closed ×1

Error Message

Custom Streamable HTTP MCP connectors (via supergateway 3.4.3, --stateful) load tools successfully in claude.ai web conversations, but every tool call fails with "Error occurred during tool execution." Nginx debug logging reveals claude.ai is sending a stale Mcp-Session-Id header that doesn't exist on the server. supergateway correctly returns 400. claude.ai does not fall back to re-initializing a fresh session — it just surfaces the error.

Error Messages/Logs

User-visible error (in claude.ai conversation):

"Error occurred during tool execution" {"jsonrpc":"2.0","error":{"code":-32000,"message":"Bad Request: No valid session ID provided"},"id":null} 5. Tool call fails with "Error occurred during tool execution"

Root Cause

N/A — this bug is in the claude.ai web MCP connector client, not Claude Code CLI. Filing here because this repo is the standard location for MCP connector issues.

Code Example

# User-visible error (in claude.ai conversation):
"Error occurred during tool execution"

# Nginx debug log showing claude.ai's requests with stale session ID:
# (custom log format capturing $http_mcp_session_id header)

172.70.34.132 - GET /[secret-path] HTTP/1.1 - status:400 body_bytes:29 accept:"text/event-stream" content_type:"-" session_id:"ead943df-8fd9-4839-ae58-611a949e59c4" content_length:"-"
104.23.209.43 - POST /[secret-path] HTTP/1.1 - status:400 body_bytes:105 accept:"application/json, text/event-stream" content_type:"application/json" session_id:"ead943df-8fd9-4839-ae58-611a949e59c4" content_length:"109"

# supergateway response for invalid session ID (confirmed via localhost curl):
{"jsonrpc":"2.0","error":{"code":-32000,"message":"Bad Request: No valid session ID provided"},"id":null}

# supergateway journal shows NO entries for claude.ai's requests —
# the 400 rejection happens at Express's HTTP layer before MCP logging.

# External curl through Cloudflare SUCCEEDS with no session ID (fresh initialize):
$ curl -X POST https://[domain]/[secret-path] \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'

HTTP/2 200
mcp-session-id: b4b6586d-c5f5-40f9-ada1-873c05776f0d
event: message
data: {"result":{"protocolVersion":"2025-03-26","capabilities":{"tools":{"listChanged":true}},"serverInfo":{"name":"memory-server","version":"0.6.3"}},"jsonrpc":"2.0","id":1}

# Cloudflare security analytics show all requests matched the skip rule (Action: Skip).
# Requests are reaching nginx and being proxied to supergateway — Cloudflare is not blocking.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

What's Wrong?

Custom Streamable HTTP MCP connectors (via supergateway 3.4.3, --stateful) load tools successfully in claude.ai web conversations, but every tool call fails with "Error occurred during tool execution."

Nginx debug logging reveals claude.ai is sending a stale Mcp-Session-Id header that doesn't exist on the server. supergateway correctly returns 400. claude.ai does not fall back to re-initializing a fresh session — it just surfaces the error.

This stale session ID persists across disconnecting/reconnecting the connector, fully deleting and re-adding the connector, using an incognito browser window, and starting new conversations. The Connectors settings UI also exhibits a related bug: after clicking "Disconnect," reloading the page reverts the connector to connected state as though the disconnect never committed.

Two custom connectors on the same host (different ports) broke simultaneously. The server is confirmed healthy — external curl through Cloudflare succeeds and returns a valid session.

What Should Happen?

When a tool call receives a 400 due to an invalid session ID, claude.ai should discard the cached session ID and send a fresh initialize request to obtain a new one.

Disconnecting or deleting a connector should reliably clear all cached state, including any stored session ID.

Error Messages/Logs

# User-visible error (in claude.ai conversation):
"Error occurred during tool execution"

# Nginx debug log showing claude.ai's requests with stale session ID:
# (custom log format capturing $http_mcp_session_id header)

172.70.34.132 - GET /[secret-path] HTTP/1.1 - status:400 body_bytes:29 accept:"text/event-stream" content_type:"-" session_id:"ead943df-8fd9-4839-ae58-611a949e59c4" content_length:"-"
104.23.209.43 - POST /[secret-path] HTTP/1.1 - status:400 body_bytes:105 accept:"application/json, text/event-stream" content_type:"application/json" session_id:"ead943df-8fd9-4839-ae58-611a949e59c4" content_length:"109"

# supergateway response for invalid session ID (confirmed via localhost curl):
{"jsonrpc":"2.0","error":{"code":-32000,"message":"Bad Request: No valid session ID provided"},"id":null}

# supergateway journal shows NO entries for claude.ai's requests —
# the 400 rejection happens at Express's HTTP layer before MCP logging.

# External curl through Cloudflare SUCCEEDS with no session ID (fresh initialize):
$ curl -X POST https://[domain]/[secret-path] \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'

HTTP/2 200
mcp-session-id: b4b6586d-c5f5-40f9-ada1-873c05776f0d
event: message
data: {"result":{"protocolVersion":"2025-03-26","capabilities":{"tools":{"listChanged":true}},"serverInfo":{"name":"memory-server","version":"0.6.3"}},"jsonrpc":"2.0","id":1}

# Cloudflare security analytics show all requests matched the skip rule (Action: Skip).
# Requests are reaching nginx and being proxied to supergateway — Cloudflare is not blocking.

Steps to Reproduce

  1. Set up a custom MCP server using supergateway 3.4.3 with --stateful --outputTransport streamableHttp, behind nginx and Cloudflare
  2. Add the connector in claude.ai (Settings → Connections) — tools load and work normally
  3. Restart the MCP server service (sudo systemctl restart memory-mcp)
  4. Open a new claude.ai conversation and attempt any tool call
  5. Tool call fails with "Error occurred during tool execution"
  6. Go to Settings → Connections → click Disconnect on the connector
  7. Reload the page — connector shows as connected again (disconnect did not persist)
  8. Delete the connector entirely and re-add it
  9. Open a new conversation in an incognito window — same failure
  10. Check nginx logs: claude.ai is still sending the same stale Mcp-Session-Id from step 2

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

Unknown — connectors were working as recently as early April 2026. The issue may be related to changes deployed around the April 6–10 outage period.

Claude Code Version

N/A — this bug is in the claude.ai web MCP connector client, not Claude Code CLI. Filing here because this repo is the standard location for MCP connector issues.

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Stack: supergateway 3.4.3 (Node, --stateful streamableHttp) → nginx (proxy_pass to localhost:PORT/mcp) → Cloudflare (orange cloud, skip rule for MCP paths) → AWS Lightsail (Ubuntu 24.04)

Two connectors affected simultaneously: Both a Bluesky MCP server (port 3000) and a Memory MCP server (port 3001) on the same host broke at the same time, confirming this is not server-specific.

Connector disconnect UI bug: Clicking "Disconnect" in Settings → Connections appears to succeed, but reloading the page reverts the connector to connected/"Configure" state. This may be the same underlying issue — the cached session state is not being cleared.

Possibly related:

  • March 31 incident: "connectors became unavailable in the Claude.ai desktop application"
  • #44361: Slack MCP connector not recovering after April 6 service disruption

extent analysis

TL;DR

The issue can be resolved by modifying the claude.ai web MCP connector client to discard the cached session ID and send a fresh initialize request when a 400 error occurs due to an invalid session ID.

Guidance

  • Investigate the claude.ai web MCP connector client code to identify where the session ID is being cached and modify it to clear the cache when a 400 error occurs.
  • Verify that the Disconnect button in the Settings → Connections page is properly clearing the cached session state by checking the connector's state after reloading the page.
  • Check the nginx logs to confirm that the stale Mcp-Session-Id header is no longer being sent after implementing the fix.
  • Consider implementing a retry mechanism to handle cases where the session ID becomes invalid due to server restarts or other issues.

Example

No code snippet is provided as the issue is related to the claude.ai web MCP connector client, which is not publicly available.

Notes

The issue seems to be related to a regression introduced in a recent version, and the exact cause is still unknown. The provided information suggests that the issue is not specific to a particular server or connector, but rather a problem with the claude.ai web MCP connector client.

Recommendation

Apply a workaround to modify the claude.ai web MCP connector client to handle invalid session IDs and clear the cached state when the Disconnect button is clicked. This should resolve the issue until a permanent fix is implemented.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING