Skip to content

Conversation

@AlexanderBartash
Copy link
Contributor

Summary

Fixes #800

The parseAllowedTools() function previously used .match() which only returns the first match. This caused tools specified in subsequent --allowed-tools flags to be ignored during MCP server initialization.

Changes

  • Add /g flag to regex patterns for global matching
  • Use matchAll() to find all occurrences
  • Deduplicate tools while preserving order
  • Make unquoted pattern not match quoted values (to avoid capturing quotes from quoted patterns)

Root Cause

When users specify multiple --allowed-tools flags:

claude_args: |
  --allowed-tools 'mcp__context7__*'
  --allowed-tools 'Read,Glob,Grep'
  --allowed-tools 'mcp__github_inline_comment__create_inline_comment'

Only tools from the first flag were parsed. This broke MCP server initialization when mcp__github_* tools weren't in the first flag.

Test plan

  • All existing tests pass
  • Added new tests for multiple --allowed-tools flags
  • Added test for deduplication across flags
  • Added test for multiline flag parsing

The parseAllowedTools() function previously used .match() which only
returns the first match. This caused tools specified in subsequent
--allowed-tools flags to be ignored during MCP server initialization.

Changes:
- Add /g flag to regex patterns for global matching
- Use matchAll() to find all occurrences
- Deduplicate tools while preserving order
- Make unquoted pattern not match quoted values

Fixes anthropics#800

 #vibe

Co-authored-by: Claude <[email protected]>
@ashwin-ant ashwin-ant merged commit 005436f into anthropics:main Jan 8, 2026
4 of 21 checks passed
@AlexanderBartash AlexanderBartash deleted the fix-parse-all-allowed-tools-flags branch January 8, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parseAllowedTools() only parses first --allowed-tools flag, breaking GitHub MCP server initialization

2 participants