fix(claude_code): pass --strict-mcp-config so unrelated MCP servers stay out of every role - #75
Open
maaz-codes wants to merge 1 commit into
Open
Conversation
…tay out of every role claude_code.py:65 said --strict-mcp-config keeps unrelated user/project MCP servers out of every role, but the flag was never appended to command_parts; it occurred exactly once in the repository, inside that comment. Without it the claude CLI reads its normal MCP configuration sources, so every user-scope server on the operator's account and any .mcp.json in the workspace is loaded into the manager, executor, auditor and final-response episodes. Because the adapter also passes --dangerously-skip-permissions, a workspace .mcp.json loads with no approval prompt. policy_for_role denies mcp__* for manager and final_response only, so for the roles that act those tools were callable. Add the flag, correct the comment, and add tests/test_claude_code_adapter.py covering every role and both explicit and environment-provided --mcp-config.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--strict-mcp-configto the Claude Code command, so a role loads only the servers in anexplicit
--mcp-configand none when there is no configclaude_code.py:65, which described the flag as if it were already passedtests/test_claude_code_adapter.py: every role carries the flag, and an explicit orenvironment-provided
--mcp-configstays the only sourceRoot cause
claude_code.py:65states that--strict-mcp-configkeeps unrelated user/project MCP servers out ofevery role, but the flag was never appended to
command_parts— it occurred exactly once in therepository, inside that comment. Without it the
claudeCLI reads its normal MCP configurationsources, so every user-scope server on the operator's account and any
.mcp.jsonin the workspaceis loaded into the manager, executor, auditor and final-response episodes. Because the adapter also
passes
--dangerously-skip-permissions, a workspace.mcp.jsonloads with no approval prompt.policy_for_roledeniesmcp__*formanagerandfinal_responseonly; the executor deny-list is("Agent",)and the auditor deny-list is the write tools plus"Agent". For the roles that act,those servers' tools were therefore callable.
User impact
Runs that never configured MCP now start no MCP servers at all, which is what the comment always
claimed. Runs that pass
--claude-mcp-config/LH_HARNESS_CLAUDECODE_MCP_CONFIG, or that use acomputer-use plugin, are unchanged: that config remains loaded and is now the only source. The
change is behaviour-preserving for the documented configuration paths and closes the undocumented
one.
This is orthogonal to #61, which opts agents out of plugins and skills via
--setting-sources project. MCP servers are a separate configuration source; in the verification run below theplugin/skill surface is unchanged (63 slash commands, 5 sub-agents still visible) while
mcp_serversbecomes empty.Validation
Measured from the
system/initevent in each role's capturedclaude_stream.jsonl, same task,same workspace, one
.mcp.jsondeclaring a placeholderleak-probeserver,--max-rounds 1 --no-dashboard:Both runs produced the correct
total.txtand the samestatus/abort_reason(
incomplete/max_rounds_exhausted, from--max-rounds 1).main(9 failed) and pass with this change (9 passed)414 passed, 1 skipped(405 + 1 before this PR)git diff --check: passedclaude2.1.251, macOS 26.3 arm64Fixes #74.