Skip to content

[BUG] Claude code does not obey values of MCP_TIMEOUT longer than 60 seconds #16837

Description

@marcindulak

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?

Claude code does not obey values of MCP_TIMEOUT longer than 60 seconds

What Should Happen?

Claude code should obey longer values of MCP_TIMEOUT. This is needed for MCP servers that have a long startup times, e.g. download some resources.

Error Messages/Logs

[DEBUG] MCP server "sleep": Starting connection with timeout of 100000ms
[DEBUG] MCP server "sleep": Connection failed after 60031ms: MCP error -32001: Request timed out

Steps to Reproduce

rm -rf /tmp/claude-60seconds-timeout
mkdir /tmp/claude-60seconds-timeout
cd /tmp/claude-60seconds-timeout
export MCP_TIMEOUT=100000 # 100 seconds
claude mcp remove sleep || true
claude mcp add sleep -- bash -c "sleep infinity"
DEBUG=true claude mcp list  # claude mcp list  --debug option is no longer available as of Claude Code 2.1.121
sleep: bash -c sleep infinity - ✗ Failed to connect

real    1m0.692s
user    0m1.383s
sys     0m0.320s

Debug output:

grep -E 'timeout|sleep' ~/.claude/debug/54bfa90c-4134-48e4-a4d3-81368ead51f8.txt 
2026-01-08T10:50:33.583Z [DEBUG] MCP server "sleep": Starting connection with timeout of 100000ms
2026-01-08T10:51:33.602Z [DEBUG] MCP server "sleep": Connection failed after 60021ms: MCP error -32001: Request timed out
2026-01-08T10:51:33.603Z [ERROR] MCP server "sleep" Connection failed: MCP error -32001: Request timed out

Claude Model

Not sure / Multiple models

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

2.1.1

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

This is a new instance of the #7575 issue, which was incorectly closed with "60 days of inactivity", despite human comments being present. This behavior of the autoclose bot is reported in #16497.

Activity

  1. github-actions commented on Jan 8, 2026

    @github-actions

    Found 2 possible duplicate issues:

    1. [BUG] Claude code does not obey values of MCP_TIMEOUT longer than 60 seconds #7575
    2. [BUG] MCP Timeout needs to be configurable #424

    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

  2. Peter4daggai commented on Jan 15, 2026

    @Peter4daggai

    I think mine #17662 got marked as a duplicate.
    I thought this was an Anthropic API server issues (and their support even told me that they limited the tool call time to 1 minute due to "incidents")
    But purely by accident i ran it on v2.0.32 and there my long running mcp tools work perfectly

  3. marcindulak commented on Jan 15, 2026

    @marcindulak
    Author

    The original issue described here is about a local stdio MCP server (linux sleep infinity command, not an http MCP server).

    @Peter4daggai - please don't upvote the "Found possible duplicate issues:" bot like in #16837 (comment) or #17662 (comment), because by upvoting you indicate the issue is a duplicate, and the bot should close it. You need to downvote the bot message to indicate you want to keep the issue open.

    The standalone reproduction for the MCP_TIMEOUT environment setting, is present for me since 1.0.113 #7575.
    You could try to perform the reproduction steps described in this issue, with the latest 2.1.7 release, as 2.0.32 is old.

  4. Peter4daggai commented on Jan 15, 2026

    @Peter4daggai

    @marcindulak I wont. And thanks for telling me that. I read it as "or comment" so i commented on my issue immediately.

    I know 2.0.32 is old I was happily running my mcp tools on 2.1.4 (or 5 not sure) when last weekend it stopped working. I then reverted as far back as 2.1.1. Still did not work so I and Anthropic's support deemed it an API server issue and not Claude Code. The issue was deliberate the AI said because of some "incidents" so they took it down from 5 minutes to 1 minute. But then my colleague said he did not have the issue. I was amazed at the fact he ran it all successfully on his machine where he had 2.0.32. I reverted to that version and it also worked for me. Very strange indeed.

    I also notice this issue is about the startup time of the server my issue is about MCP_TOOL_TIMEOUT i.e. the tool take about 2 minutes to return a result (transport=http)

  5. unbalanced commented on Jan 29, 2026

    @unbalanced

    Long starting mcps and long running mcps should be a user option
    Please bring back MCP_TIMEOUT and MCP_TOOL_TIMEOUT

    Also if there's a way to contribute to solving this please refer us to which codebase this belongs because i could not seem to find those implementations

  6. marcindulak commented on Jan 29, 2026

    @marcindulak
    Author

    People suggested in #424 (comment) that the 60 seconds limit is due to Claude Code (and Gemini CLI) somehow using the default value from https://github.com/modelcontextprotocol/typescript-sdk/blob/b0ef89ffaf6db8b3c52cd8919e8949b0f1da9ca4/packages/core/src/shared/protocol.ts#L110

  7. marcindulak commented on Feb 16, 2026

    @marcindulak
    Author

    .

  8. marcindulak commented on Feb 28, 2026

    @marcindulak
    Author

    .

  9. marcindulak commented on Mar 11, 2026

    @marcindulak
    Author

    .

  10. marcindulak commented on Apr 13, 2026

    @marcindulak
    Author

    .

  11. Hani-AMJ commented on May 14, 2026

    @Hani-AMJ

    Additional data point from the field — a different angle on this same class of bug.

    We run a self-hosted MCP server with a long-poll tool (wait_for_channel_event — a multi-agent message broker subscribe primitive). The expected wait window is up to 5 minutes, well within the documented MCP server-side ceiling but obviously above any client cap.

    To work around exactly this class of timeout, we shipped a server-side keepalive (FastMCP ctx.report_progress() frames at 30s cadence — well inside the 60s default) on the assumption that any properly-implemented MCP client would reset its tool-call timer on progress notifications. Reference design: RequestOptions.resetTimeoutOnProgress: true from the TypeScript SDK.

    It did not help. Empirically, our wait_for_channel_event calls from Claude Code via mcp-remote bridge time out at ~30 seconds with MCP error -32001 Request timed out, regardless of:

    • Server-side keepalive frames being sent (verified via docker exec from inside the FastMCP container — frames go out at 30s/60s/90s exactly)
    • MCP_TIMEOUT env var (we tried 60000, 120000, 300000 — all behave the same)
    • Streamable HTTP vs SSE transport (same shape on both)

    Source-level inspection of mcp-remote@0.1.37/0.1.38 (chunk-65X3S4HB.js) confirms mcp-remote itself doesn't impose this cap — its mcpProxy is a pure transport relay with no Client.request() path. The cap therefore fires UPSTREAM of mcp-remote, inside @anthropic-ai/claude-agent-sdk 0.2.138 (bundled with Claude Desktop / Claude Code).

    Specifically, our probe + the linked source inspection suggest a hardcoded TOOL_CALL_TIMEOUT_MS in claude-agent-sdk that:

    1. Does NOT honor MCP_TIMEOUT values above ~30s (in our case; possibly 60s in others as reported here)
    2. Does NOT honor server-side progress notifications (the resetTimeoutOnProgress option doesn't appear to be wired)

    The combination of these means even legitimate long-poll MCP tools that follow MCP spec for progress notifications cannot be used reliably from Claude Code today.

    Two fix-direction ideas that would unblock this class of tool:

    1. Expose TOOL_CALL_TIMEOUT_MS as a configurable (env var or config file). Even 5 minutes would be enough for most long-poll use cases.
    2. Honor server-side progress notifications by resetting the timer (the resetTimeoutOnProgress: true semantics already in the TypeScript SDK). This is the cleanest fix because it doesn't require user configuration; the timer extends as long as the server keeps work happening.

    Happy to share probe-level repros on request if it helps.

    Cross-referenced here so it informs upstream priority for the timeout/keepalive class.

  12. marcindulak commented on Jun 16, 2026

    @marcindulak
    Author

    .

  13. neerajbhatmongo commented on Jun 29, 2026

    @neerajbhatmongo

    @Hani-AMJ facing the exact same issue as well. It doesn't honor the progress notifications sent from the remote MCP tool

  14. FlorinAndrei commented on Jun 30, 2026

    @FlorinAndrei

    Plenty of Docker-based MCPs fail to start in 60 seconds, because downloading a new image takes too long, even on a good internet connection. E.g. I'm having issues right now with Playwright.

    The CLI should allow bigger values for this timeout.

  15. qasimsethi1-svg commented on Aug 14, 2026

    @qasimsethi1-svg

    Independent reproduction on Windows, Claude Code 2.1.220, with a real server and a real-world consequence — and the same log signature as the original report.

    Environment: Windows 11 Enterprise 26100 (managed, Defender real-time on), Claude Code session hosted by the desktop app (local agent mode), stdio server = @wonderwhy-er/desktop-commander 0.2.47 declared at user scope, env.MCP_TIMEOUT = "180000" set in ~/.claude/settings.json.

    Log (%LOCALAPPDATA%\claude-cli-nodejs\Cache\<cwd-slug>\mcp-logs-desktop-commander\2026-08-14T21-36-17-191Z.jsonl):

    {"debug":"Starting connection with timeout of 180000ms","timestamp":"2026-08-14T21:37:09.508Z",...}
    {"debug":"Connection failed after 60040ms (-32001): MCP error -32001: Request timed out","timestamp":"2026-08-14T21:38:09.549Z",...}
    

    So the configured 180 s is read and printed as the connection budget, but the initialize request underneath still has its own ~60 s cap, and the connection is killed at 60.0 s — 120 s of the stated budget never usable.

    Why this matters beyond a sleep infinity repro: the server is healthy but slow to cold-start. On this machine (AV-scanned node_modules, ~12k files; measured previously at ~80–83 s cold over a raw JSON-RPC handshake) the first connect after a cache-cold period can never fit in 60 s, so the server fails on exactly the runs where MCP_TIMEOUT was raised to save it. A retry minutes later — file cache warm — connected in 12.7 s on the same code:

    {"debug":"Successfully connected (transport: stdio) in 12721ms",...}
    

    Cold-start-over-60s is not exotic: any corporate Windows box with real-time AV plus a normal-sized Node dependency tree hits it, and the cache goes cold again within ~20 minutes under memory pressure, so it recurs all day.

    Related: #84136 tracks what looks like the same hardcoded 60 s initialize cap on the desktop-app/DXT path (5 s spawn + 60 s init there, reported with measurements in July). Fixing the cap so MCP_TIMEOUT (or a dedicated env var) actually reaches the initialize request would resolve both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:mcpbugSomething isn't workinghas reproHas detailed reproduction stepsplatform:linuxIssue specifically occurs on Linux

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions