Skip to content

fix: agent config panel resolves Claude MCP paths from CLAUDE_CONFIG_DIR - #3502

Open
1nderboi wants to merge 1 commit into
block:mainfrom
1nderboi:fix/3493-mcp-config-isolation
Open

fix: agent config panel resolves Claude MCP paths from CLAUDE_CONFIG_DIR#3502
1nderboi wants to merge 1 commit into
block:mainfrom
1nderboi:fix/3493-mcp-config-isolation

Conversation

@1nderboi

Copy link
Copy Markdown

Summary

  • The agent config panel's MCP server list and "From config file (…)" attribution for the claude runtime always read ~/.claude/settings.json + ~/.claude.json, ignoring an agent's own CLAUDE_CONFIG_DIR.
  • An agent given its own CLAUDE_CONFIG_DIR (to isolate it from the operator's personal Claude Code config) genuinely spawns isolated — but the panel kept showing the operator's MCP servers, which reads as "the isolation didn't work" and is alarming when the personal config has mail/drive/database connectors.

Fix

  • claude::read_config_file now takes an optional config_dir and resolves both settings.json and .claude.json under it when given (matching Claude Code's own CLAUDE_CONFIG_DIR resolution, which relocates both files together) — falling back to ~/.claude/settings.json + ~/.claude.json otherwise.
  • reader::mcp_config_file_path_for_runtime resolves the same way for the panel's file-attribution path.
  • Both call sites pull CLAUDE_CONFIG_DIR from the agent's own record.env_vars.

Why this scope

The confirmed root cause (and the issue title) is specifically the per-agent CLAUDE_CONFIG_DIR override — the most common way to isolate an agent today. Threading the fully layered effective env (global defaults + persona + per-agent) through would require widening read_config_surface's signature across ~25 call sites for a case the issue doesn't demonstrate a concrete repro for; happy to follow up if that's wanted.

Test plan

  • Added unit tests in claude.rs: isolated CLAUDE_CONFIG_DIR reads settings/MCP servers from that dir; an empty isolated dir does not fall back to ~/.claude.json; claude_config_paths nests both files under an explicit dir.
  • Added a reader_tests.rs test asserting read_config_surface surfaces MCP extensions and the mcp_config_file_path from the per-agent CLAUDE_CONFIG_DIR, not the default.
  • cargo test --manifest-path desktop/src-tauri/Cargo.toml --lib managed_agents::config_bridge — 84 passed, 0 failed.
  • cargo clippy --manifest-path desktop/src-tauri/Cargo.toml --all-targets — clean.
  • cargo fmt --manifest-path desktop/src-tauri/Cargo.toml --all -- --check — clean.

🤖 Generated with Claude Code

…ONFIG_DIR

The agent config panel read Claude Code's MCP server list and file
attribution from ~/.claude/settings.json and ~/.claude.json unconditionally,
ignoring an agent's own CLAUDE_CONFIG_DIR. An isolated agent's runtime was
correctly scoped, but its config panel still showed the operator's personal
MCP servers, making the isolation look broken when it wasn't.

claude::read_config_file and reader::mcp_config_file_path_for_runtime now
resolve settings.json/.claude.json against the agent's effective
CLAUDE_CONFIG_DIR (record.env_vars) when set, matching Claude Code's own
resolution.

Fixes block#3493

Signed-off-by: 1nderboi <201919958+1nderboi@users.noreply.github.com>
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.

1 participant