Skip to content

fix: preserve user MCP servers when spawning Claude from dashboard#542

Merged
khaliqgant merged 4 commits intomainfrom
fix/merge-mcp-configs
Mar 11, 2026
Merged

fix: preserve user MCP servers when spawning Claude from dashboard#542
khaliqgant merged 4 commits intomainfrom
fix/merge-mcp-configs

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

@khaliqgant khaliqgant commented Mar 11, 2026

Problem

When the broker spawns Claude agents, it passes --strict-mcp-config with only the relaycast MCP server. This nukes all other MCP servers from .mcp.json.

Fix

New merge_relaycast_with_project_mcp(): reads .mcp.json, merges non-relaycast servers with broker-injected relaycast config. Relaycast always wins (prevents stale creds), other MCPs preserved.

3 new tests, 199/199 Rust unit tests pass.


Open with Devin

When the broker spawns Claude agents, it was passing --strict-mcp-config
with only the relaycast server, which nuked all other MCP servers the
user had configured in .mcp.json (filesystem, database, etc.).

Now reads the project-level .mcp.json, merges all non-relaycast servers
with the broker-injected relaycast config, and passes the combined config.
The relaycast entry always wins to prevent stale credentials, but other
MCPs are preserved.

3 new tests: merge with existing, no .mcp.json, malformed .mcp.json
199/199 Rust unit tests pass.
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Reads MCP servers from all 3 Claude config sources in precedence order:
1. ~/.claude/settings.json (global)
2. ~/.claude/settings.local.json (local, gitignored)
3. .mcp.json (project-level)

Later sources override earlier ones, matching Claude's own loading order.
Relaycast entry always wins. 200/200 tests pass.
@khaliqgant khaliqgant force-pushed the fix/merge-mcp-configs branch from e4817a8 to 889c5e4 Compare March 11, 2026 13:28
Refactors merge_relaycast_with_project_mcp to accept an optional home_dir
parameter (via _inner variant) for testability, then adds 7 integration tests:
- E2E Claude spawn with user servers (Test A)
- Precedence: project overrides global/local (Test B)
- Precedence: local overrides global (Test B cont)
- Global-only MCP servers appear in output (Test C)
- Disabled servers preserved as-is (Test D)
- Large config with 15+ servers (Test E)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@khaliqgant khaliqgant force-pushed the fix/merge-mcp-configs branch from b8be559 to d7a2be3 Compare March 11, 2026 13:56
@khaliqgant khaliqgant merged commit 937afda into main Mar 11, 2026
1 check passed
@khaliqgant khaliqgant deleted the fix/merge-mcp-configs branch March 11, 2026 14:25
khaliqgant added a commit that referenced this pull request Mar 25, 2026
)

* fix: merge user MCP servers with relaycast when spawning Claude agents

When the broker spawns Claude agents, it was passing --strict-mcp-config
with only the relaycast server, which nuked all other MCP servers the
user had configured in .mcp.json (filesystem, database, etc.).

Now reads the project-level .mcp.json, merges all non-relaycast servers
with the broker-injected relaycast config, and passes the combined config.
The relaycast entry always wins to prevent stale credentials, but other
MCPs are preserved.

3 new tests: merge with existing, no .mcp.json, malformed .mcp.json
199/199 Rust unit tests pass.

* fix: also merge global MCP configs (~/.claude/settings.json)

Reads MCP servers from all 3 Claude config sources in precedence order:
1. ~/.claude/settings.json (global)
2. ~/.claude/settings.local.json (local, gitignored)
3. .mcp.json (project-level)

Later sources override earlier ones, matching Claude's own loading order.
Relaycast entry always wins. 200/200 tests pass.

* test: add comprehensive integration tests for MCP config merging

Refactors merge_relaycast_with_project_mcp to accept an optional home_dir
parameter (via _inner variant) for testability, then adds 7 integration tests:
- E2E Claude spawn with user servers (Test A)
- Precedence: project overrides global/local (Test B)
- Precedence: local overrides global (Test B cont)
- Global-only MCP servers appear in output (Test C)
- Disabled servers preserved as-is (Test D)
- Large config with 15+ servers (Test E)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* style: auto-format Rust code with cargo fmt

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@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