Skip to content

MCP_TIMEOUT not passed to Claude CLI subprocess — npx-based MCP servers always fail #1152

@Alex0007

Description

@Alex0007

Environment

  • anthropics/claude-code-action@v1
  • Claude Code 2.1.90 (installed by the action)
  • Runner: ubuntu-latest

Problem

Environment variable MCP_TIMEOUT never reaches the Claude CLI process spawned by the action. MCP servers configured via --mcp-config with npx commands fail to start because the default 30s timeout is too short for npx to download and initialize packages.

What we tried

Every method of setting MCP_TIMEOUT is ignored:

  1. Step-level env: — not forwarded to the CLI subprocess
  2. settings input {"env": {"MCP_TIMEOUT": "120000"}} — no effect
  3. GITHUB_ENV (echo "MCP_TIMEOUT=120000" >> "$GITHUB_ENV") — no effect
  4. Project .claude/settings.json with {"env": {"MCP_TIMEOUT": "120000"}} — the SDK doesn't seem to read project settings

The Claude CLI binary reads MCP_TIMEOUT from process.env:

parseInt(process.env.MCP_TIMEOUT || "", 10) || 30000

But the action's entrypoint (bun run src/entrypoints/run.ts) doesn't propagate it to the subprocess.

Desired behavior

MCP_TIMEOUT set via step env:, GITHUB_ENV, or settings input should reach the Claude CLI process, allowing npx-based MCP servers enough time to download and start:

- name: Set MCP timeout
  run: echo "MCP_TIMEOUT=120000" >> "$GITHUB_ENV"

- uses: anthropics/claude-code-action@v1
  with:
    claude_args: |
      --mcp-config '{"mcpServers":{"mongodb":{"command":"npx","args":["-y","mongodb-mcp-server"],...}}}'

Current workaround

Pre-install all MCP servers globally before the action runs, adding 35-40 seconds to every run even when MCP tools aren't needed:

- name: Pre-install MCP servers
  run: npm install -g figma-developer-mcp mongodb-mcp-server

Related

Better workaround: cache MCP servers

Caching the npm global install between runs reduces the overhead from 35-40s to ~3-4s (cache restore):

- name: Get MCP server versions
  id: mcp-versions
  run: |
    FIGMA_V=$(npm view figma-developer-mcp version)
    MONGO_V=$(npm view mongodb-mcp-server version)
    echo "key=mcp-servers--figma-developer-mcp@${FIGMA_V}--mongodb-mcp-server@${MONGO_V}" >> "$GITHUB_OUTPUT"

- name: Cache MCP servers
  id: mcp-cache
  uses: actions/cache@v4
  with:
    path: |
      /usr/local/lib/node_modules/figma-developer-mcp
      /usr/local/lib/node_modules/mongodb-mcp-server
      /usr/local/bin/figma-developer-mcp
      /usr/local/bin/mongodb-mcp-server
    key: ${{ steps.mcp-versions.outputs.key }}

- name: Install MCP servers
  if: steps.mcp-cache.outputs.cache-hit != 'true'
  run: npm install -g figma-developer-mcp mongodb-mcp-server

Cache auto-busts when either package publishes a new version. Still a workaround though — MCP_TIMEOUT should just work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmcpp2Non-showstopper bug or popular feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions