feat(cli): add mcp subcommand for managing MCP servers#361
Merged
Conversation
Closes #346 Adds a new `allagents mcp` subcommand surface with five operations: - `mcp add <name> <commandOrUrl>` — add a server to workspace.yaml and sync to all configured clients. Supports --transport, --arg, -e/--env, --header, --client, --force. - `mcp remove <name>` — remove a server from workspace.yaml and unsync from clients. - `mcp list` — list MCP servers defined in workspace.yaml. - `mcp get <name>` — show the workspace definition for a server. - `mcp update` — sync MCP servers only, without touching other artifacts. Extends WorkspaceConfigSchema with a top-level `mcpServers:` field (parallel to `mcpProxy:`) and plumbs workspace-level servers through the sync pipeline via `collectMcpServers`. Extracts the per-client MCP sync loop from `sync.ts::syncWorkspace` into a shared `mcp-sync.ts::syncMcpServers` function, and adds `syncMcpOnly` for the standalone `mcp update` command. Honors the existing MCP ownership model: only servers AllAgents added are tracked and can be modified or removed. Pre-existing user-managed servers in `.mcp.json` / `.copilot/mcp-config.json` are preserved untouched. Auto-detects HTTP vs stdio transport from the commandOrUrl argument and rejects inconsistent flags (e.g. `--transport stdio` with a URL, or `--arg` with HTTP). Adds 20 unit tests in `tests/unit/core/mcp-servers.test.ts`. All 1178 tests pass.
- docs/reference/cli.mdx: add "MCP Commands" section covering add/remove/list/get/update with flags, examples, transport auto-detection notes, and the ownership model. - docs/reference/configuration.mdx: document the top-level mcpServers: field in workspace.yaml with field reference and example covering http, stdio, and per-server client filters. - README.md: add mcp add/list to the commands summary table.
Deploying allagents with
|
| Latest commit: |
ee4380b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ef66f5b0.allagents.pages.dev |
| Branch Preview URL: | https://feat-346-mcp-subcommand.allagents.pages.dev |
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.
Closes #346
Summary
Adds an
allagents mcpsubcommand surface with five operations for managing MCP servers independently of full plugin installs. Mirrors theclaude mcpcommand surface and persists servers in a new top-levelmcpServers:field inworkspace.yaml(parallel tomcpProxy:).New commands
allagents mcp add <name> <commandOrUrl>allagents mcp remove <name>allagents mcp listallagents mcp get <name>allagents mcp updatemcp addsupports:--transport http|stdio(auto-detected from URL if omitted)--arg <value>(repeatable, stdio only)-e/--env KEY=VALUE(repeatable, stdio only)--header KEY=VALUE(repeatable, http only)--client <csv>— limit which clients receive the server--force/-f— replace an existing server with the same name (used for updates)Architecture
src/models/workspace-config.ts— newMcpServerConfigSchema+ top-levelmcpServers:field.src/core/vscode-mcp.ts—collectMcpServersnow accepts workspace-level servers and merges them with plugin-supplied servers (workspace overrides plugin, with a warning).src/core/mcp-sync.ts— new module containingsyncMcpServers(the per-client MCP sync loop, extracted fromsync.ts::syncWorkspace) andsyncMcpOnly(standalone MCP-only pipeline used bymcp updateand by add/remove auto-sync).src/core/sync.ts—syncWorkspacenow delegates to the sharedsyncMcpServers. Removes ~100 lines of duplicated per-client MCP blocks.src/core/mcp-servers.ts— new module with CRUD helpers for the top-levelmcpServers:field, plusbuildMcpServerConfigFromFlagsfor translating CLI flags into anMcpServerConfig.src/cli/commands/mcp.ts/src/cli/metadata/mcp.ts— new CLI commands with agent-help metadata.Ownership model
Honors the existing MCP ownership rule per
CLAUDE.md: only servers AllAgents added are tracked viatrackedServersin sync state and can be modified or removed. Pre-existing user-managed servers in.mcp.json/.copilot/mcp-config.jsonare preserved untouched (verified in E2E).Tests
tests/unit/core/mcp-servers.test.tscovering add/remove/get/list, config building from flags, and KEY=VALUE parsing.Test plan
bun test— all tests passbunx tsc --noEmit— cleanbun run lint— cleanmcpsubcommand did not exist on main)/tmp/mcp-test-e2ewithclaude,copilotclientsmcp add deepwiki <https-url>→ writes to workspace.yaml, syncs to.mcp.jsonand.copilot/mcp-config.jsonmcp add gh-server npx --arg=-y --arg=@modelcontextprotocol/server-github -e GH_TOKEN=...→ stdio with args and envmcp add deepwiki ... --force --header Authorization=Bearer-token→ replaces existing server (update workflow)mcp list→ shows both servers with transport detailsmcp get deepwiki→ prints YAML dumpmcp add claude-only ... --client claude→ synced only to.mcp.json, not to copilotmcp remove gh-server→ removes from workspace.yaml and both client configsmcp update→ sync-only, shows "No MCP server changes." when nothing changed--force→ exit 1 with clear errormcp add bad https://... --transport stdio→ exit 1 ("stdio transport requires a command, not a URL")mcp get nonexistent→ exit 1 with clear error.mcp.jsonsurvivedmcp removeof a different server