Skip to content

[FEATURE] Make MCP tool call timeout configurable (MCP_TOOL_TIMEOUT) #47076

Description

@Aboudjem

Problem

MCP tool calls that take longer than ~30-60 seconds fail with socket hang up errors. This affects any MCP server with long-running operations, most notably Google Stitch (generate_screen_from_text takes 2-10 minutes) but also any AI generation, build, or processing tool.

The MCP_TIMEOUT env var only controls startup timeout, not tool call execution timeout. There is currently no way to configure the tool call socket timeout.

Evidence

This has been reported 6+ times across different issues and platforms. Each time it's closed as stale without a fix.

Reproduction

  1. Configure any MCP server with a tool that takes >60 seconds
  2. Call the tool from Claude Code
  3. After ~30-60s: Error: Network error: socket hang up

Specific example with Google Stitch MCP:

mcp__stitch__generate_screen_from_text → socket hang up (every time, 8+ attempts)
mcp__stitch__list_projects → works fine (fast operation)
mcp__stitch__list_screens → works fine (fast operation)

Proposed Solution

Add a configurable MCP_TOOL_TIMEOUT environment variable that controls the socket timeout for MCP tool call execution (not just startup).

# Example: set 10-minute timeout for tool calls
MCP_TOOL_TIMEOUT=600000 claude

Or per-server in settings:

{
  "mcpServers": {
    "stitch": {
      "command": "stitch-mcp",
      "timeout": 600000
    }
  }
}

Current Workaround

The only working workaround is using a proxy server that implements polling-based recovery when the connection drops (e.g., obinnaokechukwu/stitch-mcp for Google Stitch specifically). This shouldn't be necessary — the timeout should be configurable in Claude Code itself.

Impact

This blocks usage of any MCP server with long-running operations, including:

  • Google Stitch (UI generation)
  • Build/CI tools
  • AI image/video generation servers
  • Database migration tools
  • Any tool doing network-intensive work

Environment

  • Claude Code latest (April 2026)
  • macOS Darwin 25.3.0
  • Affects all transports (stdio, SSE, HTTP)

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions