fix(mcp): align allowed-tools parser with SDK option parser by bymle · Pull Request #1373 · anthropics/claude-code-action (original) (raw)
parseAllowedTools (used to decide which GitHub MCP servers to install) hand-rolled a regex parse of claude_args, while the tools actually granted to Claude are parsed by parseClaudeArgsToExtraArgs in base-action/src/parse-sdk-options.ts using shell-quote. The two parsers diverged on two inputs (anthropics#1357):
- Multiple values after a single flag: for
--allowedTools "Read" "Grep" "mcp__github__get_commit"the regex captured only "Read", so the github MCP server was not installed even though mcp__github__get_commit was granted — tool calls then failed. - Commented-out lines: the regex counted tools on
#-prefixed lines that the SDK parser strips, installing servers that were never used.
Reimplement parseAllowedTools on the same shell-quote tokenizer and the
same "accumulating flag consumes all consecutive non-flag values"
semantics, stripping comment lines first, so the install decision agrees
with the tools that are actually granted. Unquoted glob patterns (e.g.
mcp__github__*), which shell-quote yields as glob objects, are
recovered to their literal text to preserve existing behavior.
Closes anthropics#1357