-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Describe the bug
When using v1.0.24 with the Agent SDK path (now the default per #738), multiple --mcp-config flags in claude_args are not properly merged. Only the last --mcp-config value is kept, causing the action's built-in MCP servers (like github_comment) to be lost when a user provides any MCP servers themselves with --mcp-config.
This results in errors like:
Error: No such tool available: mcp__github_comment__update_claude_comment
Root Cause
In base-action/src/parse-sdk-options.ts, the parseClaudeArgsToExtraArgs function overwrites previous --mcp-config values instead of merging them:
// Line 37-42 in parse-sdk-options.ts
if (nextArg && !nextArg.startsWith("--")) {
// For accumulating flags, join multiple values with commas
if (ACCUMULATING_FLAGS.has(flag) && result[flag]) {
result[flag] = `${result[flag]},${nextArg}`;
} else {
result[flag] = nextArg; // <-- BUG: Overwrites previous mcp-config!
}
}The ACCUMULATING_FLAGS set only contains allowedTools and disallowedTools (added in PR #719), but not mcp-config.
To Reproduce
- Use
[email protected](or any version where Agent SDK is default) - Configure a workflow with user-provided
--mcp-configinclaude_args:claude_args: | --mcp-config /tmp/my-mcp-config.json
- The action internally prepends its own
--mcp-configwithgithub_comment,github_ci, etc. - The SDK path parses
claude_argsand only keeps the last--mcp-config - Claude tries to use
mcp__github_comment__update_claude_commentbut the MCP server was never registered - Error:
No such tool available: mcp__github_comment__update_claude_comment
Expected behavior
Multiple --mcp-config flags should be merged by combining their mcpServers objects, similar to how --allowedTools flags are accumulated. The CLI path handles this correctly by passing all flags through to the claude CLI.
Evidence from Job Logs
INPUT_CLAUDE_ARGS contains TWO --mcp-config flags:
--mcp-config '{"mcpServers": {"github_comment": {...}}}' ... --mcp-config /tmp/claude-mcp-config.json
But SDK options only shows ONE:
"extraArgs": {
"mcp-config": "/tmp/claude-mcp-config.json"
}The action's github_comment MCP server config is lost.
Workaround
1️⃣ Don't use agent SDK
Set USE_AGENT_SDK=false to force the CLI path:
- name: Run Claude Code
uses: anthropics/claude-code-action@v1
env:
USE_AGENT_SDK: "false"
with:
# ... inputsor
2️⃣ Pin the action to v1.0.23:
- name: Run Claude Code
uses: anthropics/[email protected]
with:
# ... inputsAny workflow using custom MCP servers via claude_args with --mcp-config is affected.
API Provider
- Anthropic First-Party API (default)
- AWS Bedrock (likely affected)
- GCP Vertex (likely affected)
Additional context
- Working version: v1.0.23 (CLI path was default)
- Broken version: v1.0.24 (SDK path is now default)
- Introduced by: Commit
79b343c- "feat: Make Agent SDK the default execution path (feat: Make Agent SDK the default execution path #738)" - Similar fix exists: PR fix: accumulate multiple --allowedTools flags for Agent SDK #719 (
05c95ae) fixed the same issue for--allowedToolsflags
Proposed Fix
Merge multiple --mcp-config values by combining their mcpServers objects:
// Add special handling for mcp-config in parseClaudeArgsToExtraArgs or parseSdkOptions
function mergeMcpConfigs(configs: string[]): string {
const merged = { mcpServers: {} };
for (const config of configs) {
const parsed = JSON.parse(config);
Object.assign(merged.mcpServers, parsed.mcpServers || {});
}
return JSON.stringify(merged);
}