-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
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-toolsflags:
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_commentappears in finalallowedToolsarray ✅- But
github_inline_commentMCP 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_commenton PR