-
Notifications
You must be signed in to change notification settings - Fork 1.7k
MCP_TIMEOUT not passed to Claude CLI subprocess — npx-based MCP servers always fail #1152
Description
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:
- Step-level
env:— not forwarded to the CLI subprocess settingsinput{"env": {"MCP_TIMEOUT": "120000"}}— no effectGITHUB_ENV(echo "MCP_TIMEOUT=120000" >> "$GITHUB_ENV") — no effect- Project
.claude/settings.jsonwith{"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) || 30000But 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-serverRelated
- MCP_TIMEOUT ignored in GitHub Actions — forces slow pre-install workaround claude-code#42770 — companion issue on Claude Code side
- [BUG] Claude code does not obey values of MCP_TIMEOUT longer than 60 seconds claude-code#16837 —
MCP_TIMEOUTnot respected beyond 60s
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-serverCache auto-busts when either package publishes a new version. Still a workaround though — MCP_TIMEOUT should just work.