feat(agent-core): unify the v1 MCP management plane - #2858
Open
7Sageer wants to merge 21 commits into
Open
Conversation
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.
Related Issue
No GitHub issue — the requirement comes from an internal design doc ("Agent Core V1 MCP 管理面统一", Feishu doc
J3jQd3BAaoQNkaxA4PScl8Frn0e). The problem is summarized below.Problem
v1 has two MCP server sources that only merge at session start: global servers (three-layer
mcp.jsonfiles + SDK caller injection) and plugin servers (manifestmcpServers+ install state). The management plane only sees the user-level file, so:needs-authuntil a manual reconnect.oauth-authorized, and a mid-session 401 is reported as a generic connection failure.What changed
Unified config registry (
packages/agent-core/src/mcp/registry.ts): every server — global (layered files), plugin (manifests), caller (SDK injection) — is exposed withsource/origin/mutableand its final effective config; the plugin rename / env-injection / cwd-constraint transforms stay insidePluginManager.mcpServerEntries(). All management lookups go through the registry: queries cover plugin servers, mutations on read-only entries are rejected with an actionable error, andgetGlobalMcpServerexposes the effective config. Global CRUD and plugin install/enable/disable/remove/reload now push into every live session (upsert / remove / reconnect-on-change).Interface extensions (name + full config):
testGlobalMcpServeraccepts an inline unsaved config; newaddSessionMcpServer(name + full config +persistflag);reconnectMcpServeraccepts a replacement config, and a name-only reconnect re-resolves the current config from the registry.OAuth conduction & status semantics: one process-wide
McpOAuthServiceshared by core and all sessions; token writes are stamped withobtained_atso expiry is computable; refresh runs ahead of expiry and single-flight per credential; credential events (saved / invalidated / refresh-failed) are pushed into affected sessions automatically. Mid-session 401s classify asneeds-auth;listGlobalMcpServerAuthStatusessupportsverify(online probe) and the newoauth-expiredstate.SDK: the surface is exposed on both clients (
getMcpServer,testMcpServerConfig, sessionaddMcpServer,reconnectMcpServer(name, config),cwd/verifyoptions, source-tagged list entries). v2-client limitations (nosource/configtags on session entries, workspace-shared session adds) are documented in its header comment and pinned in the parity test'sKNOWN_DIFFS.Relationship to #2856: this PR's second commit absorbs that PR's v1 side —
inspectAppMcpServers, the locator-addressed OAuth RPCs, andreconnectAndJoinare ported and implemented over the unified registry (itsMcpOAuthCoordinatorandPluginManager.mcpServers()are superseded by the service's built-in credential events andmcpServerEntries(); the inspection also reports dead grants asoauth-expiredrather thanoauth-required). What remains unique to #2856 after this: the v2-engine credential propagation (IMcpAuthCoordinatordriving workspace MCP reconnects), which is orthogonal and can land separately.Checklist
test/mcp/registry.test.ts,test/mcp/oauth-service.test.ts,test/rpc/mcp-rpc.test.ts, connection-manager / session-config / node-sdk / parity suites; full repo suite green: 18327 passed.)gen-changesetsskill, or this PR needs no changeset. (.changeset/v1-mcp-management-plane.md)gen-docsskill, or this PR needs no doc update. (docs/{en,zh}/customization/mcp.md: plugin server changes now take effect in open sessions immediately.)