feat: unified MCP server configuration API#4
Merged
Conversation
Adds add_mcp_server / remove_mcp_server / list_mcp_servers to AgentShell and the AgentAdapter protocol so callers no longer need per-agent dispatch when registering MCP servers. All adapters write user-scope configuration so registrations persist across execute/stream calls. - Claude Code: shells out to `claude mcp add/remove --scope user`; list_mcp_servers raises NotImplementedError pending a follow-up - OpenCode: read/write ~/.config/opencode/opencode.json - Copilot CLI: read/write ~/.copilot/mcp-config.json - MCPServerSpec validates STDIO/HTTP exactly-one-of fields - Adds are idempotent (overwrite); removes warn when name missing Closes #2 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
Author
|
I found one issue worth addressing:
It would be safer to catch |
PR #4 review feedback: a single bad entry in the user-editable opencode.json or copilot mcp-config.json could abort the entire listing because MCPServerSpec validation raises ValueError. Catch per-entry, warn naming the offender, and continue so good entries still surface. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
add_mcp_server/remove_mcp_server/list_mcp_serverstoAgentShelland theAgentAdapterprotocol so callers stop hand-coding per-agent dispatch when wiring MCP servers (e.g. forgetful for evals).execute/streamcalls.MCPServerSpecdataclass validates STDIO/HTTP exactly-one-of fields at construction time.Per-adapter behaviour
claude mcp add/remove --scope usersubprocess~/.claude.json(managed by CLI)~/.config/opencode/opencode.json~/.copilot/mcp-config.jsonlist_mcp_serversraisesNotImplementedErrorfor Claude Code — tracked in #3.Semantics
UserWarning).Test plan
MCPServerSpecvalidation (9 tests covering all invalid combinations)AgentShellpassthrough delegation + exception propagationclaude mcp add/removeargv shape,-e/--headertranslation, error propagation, overwrite-via-pre-removemonkeypatch HOME=tmp_path; preserve unrelated config keys, overwrite same-name, round-trip vialist_mcp_servers, warn on missing removeCloses #2
🤖 Generated with Claude Code