Summary
The parseAllowedTools() function in src/modes/agent/parse-tools.ts only extracts tools from the first --allowed-tools flag, ignoring any subsequent flags. This causes GitHub MCP servers (like github_inline_comment) to not initialize when users specify multiple --allowed-tools flags in their claude_args.
Reproduction
- Configure a workflow with multiple
--allowed-tools flags:
claude_args: |
--allowed-tools 'mcp__context7__*'
--allowed-tools 'Read,Glob,Grep,LS'
--allowed-tools 'mcp__github_inline_comment__create_inline_comment'
-
Trigger Claude via a PR comment
-
Observe that:
mcp__github_inline_comment__create_inline_comment appears in final allowedTools array ✅
- But
github_inline_comment MCP server is NOT initialized ❌
Root Cause
In src/modes/agent/parse-tools.ts:
export function parseAllowedTools(claudeArgs: string): string[] {
const patterns = [
/--(?:allowedTools|allowed-tools)\s+"([^"]+)"/,
/--(?:allowedTools|allowed-tools)\s+'([^']+)'/,
/--(?:allowedTools|allowed-tools)\s+([^\s]+)/,
];
for (const pattern of patterns) {
const match = claudeArgs.match(pattern); // ← Only finds FIRST match
if (match && match[1]) {
return match[1].split(",")...; // ← Returns immediately
}
}
return [];
}
The regex patterns don't use the /g flag, and .match() only returns the first match. The function returns immediately after finding one match.
Impact
In Tag Mode, this parsed list is filtered for mcp__github_* tools to determine which MCP servers to start:
const userAllowedMCPTools = parseAllowedTools(userClaudeArgs).filter(
(tool) => tool.startsWith("mcp__github_"),
);
If the first --allowed-tools flag doesn't contain mcp__github_* tools, no GitHub MCP servers get initialized from user config.
Suggested Fix
Use matchAll() with /g flag to find ALL occurrences:
export function parseAllowedTools(claudeArgs: string): string[] {
const patterns = [
/--(?:allowedTools|allowed-tools)\s+"([^"]+)"/g,
/--(?:allowedTools|allowed-tools)\s+'([^']+)'/g,
/--(?:allowedTools|allowed-tools)\s+([^\s]+)/g,
];
const tools: string[] = [];
for (const pattern of patterns) {
for (const match of claudeArgs.matchAll(pattern)) {
if (match[1] && !match[1].startsWith("--")) {
tools.push(...match[1].split(",").map((t) => t.trim()));
}
}
}
return [...new Set(tools)]; // Deduplicate
}
Workaround
Put mcp__github_* tools in the first --allowed-tools flag:
claude_args: |
--allowed-tools 'mcp__github_inline_comment__create_inline_comment' # Must be first!
--allowed-tools 'mcp__context7__*'
--allowed-tools 'Read,Glob,Grep,LS'
Environment
- claude-code-action version: v1.0.28 (c9ec2b0)
- Event type:
issue_comment on PR
Summary
The
parseAllowedTools()function insrc/modes/agent/parse-tools.tsonly extracts tools from the first--allowed-toolsflag, ignoring any subsequent flags. This causes GitHub MCP servers (likegithub_inline_comment) to not initialize when users specify multiple--allowed-toolsflags in theirclaude_args.Reproduction
--allowed-toolsflags:Trigger Claude via a PR comment
Observe that:
mcp__github_inline_comment__create_inline_commentappears in finalallowedToolsarray ✅github_inline_commentMCP server is NOT initialized ❌Root Cause
In
src/modes/agent/parse-tools.ts:The regex patterns don't use the
/gflag, and.match()only returns the first match. The function returns immediately after finding one match.Impact
In Tag Mode, this parsed list is filtered for
mcp__github_*tools to determine which MCP servers to start:If the first
--allowed-toolsflag doesn't containmcp__github_*tools, no GitHub MCP servers get initialized from user config.Suggested Fix
Use
matchAll()with/gflag to find ALL occurrences:Workaround
Put
mcp__github_*tools in the first--allowed-toolsflag:Environment
issue_commenton PR