Repository navigation
MCP server integration for agent-host sessions - #320854
Merged
Connor Peet (connor4312) merged 6 commits intoJun 10, 2026
Merged
Conversation
# Conflicts: # src/vs/platform/agentHost/node/copilot/copilotAgent.ts # src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts # src/vs/workbench/services/agentHost/browser/editorRemoteAgentHostServiceClient.ts
* Wire MCP servers and sampling from agent-host sessions over the Agent Host Protocol. CopilotAgentSession advertises the standard MCP app capabilities (sampling + resources) and routes notifications by channel scheme. Seeds the inventory from `rpc.mcp.list` at subscription time so restored sessions and eagerly-configured servers populate without waiting for live events. * Expose MCP servers through a new `getMcpServers` method on `IAgentHostCustomizationService` (workbench layer) and `IAgentHostSessionsProvider` (sessions layer). Returns rich `IAgentHostMcpServer` objects that encapsulate the `SessionCustomizationToggled` dispatch so callers don't depend on the low-level action protocol. * Extend `MCP: List Servers` to default to the agent-host session's servers when an agent-host chat is focused, with a "Show locally configured servers..." back entry to switch to the local picker. Adds a per-server detail picker with an enable/disable toggle, registered as `workbench.mcp.agentHostServerOptions`. * Move the active-client claim from session-open paths to the first turn so that opening a session doesn't dispossess another client that's mid-turn elsewhere. Update affected tests to assert the new "claim on first turn" semantics. * Rework agent plugin caching to use per-nonce subdirectories so multiple revisions of the same plugin can coexist on disk. A long-running session can keep referencing an older nonce while a newer one is materialized; stale nonces are evicted opportunistically once they're no longer locked. Includes tests for the new layout and the locked-directory retry path. * Include MCP-only plugins (no prompt files) in the customization refs so their servers are still synced to the harness. Compute plugin nonces from `fileService.stat` mtime to keep the client-side fingerprint stable across syncs. * Refresh `SessionCustomizationDiscovery` non-recursive watchers to use `e.contains` so they fire on the watched URI itself. Adds tests for: MCP seeding (success + failure), per-nonce plugin materialization and eviction, MCP-only plugin inclusion, and the new active-client claim timing. Co-authored-by: Copilot <[email protected]>
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Anthony Kim (@anthonykim1)Matched files:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR integrates agent-host session MCP servers into VS Code’s MCP UI and Agent Host Protocol, enabling session-scoped server listing/status/toggling, MCP request routing over mcp:// channels, and safer on-disk plugin revision caching.
Changes:
- Add
mcp://side-channel support to Agent Host Protocol (request routing + broadcast notifications) and expose session MCP servers to the workbench MCP UI. - Include MCP-only plugins in customization refs and introduce per-nonce plugin materialization with opportunistic eviction.
- Defer active-client claiming until first turn; expand coverage with new/updated tests.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/services/agentHost/browser/editorRemoteAgentHostServiceClient.ts | Surface MCP notification event from the remote agent host client. |
| src/vs/workbench/contrib/terminal/test/browser/agentHostPty.test.ts | Update terminal agent-host test mock to satisfy new MCP event shape. |
| src/vs/workbench/contrib/mcp/common/mcpCommandIds.ts | Add command id for agent-host MCP server options. |
| src/vs/workbench/contrib/mcp/browser/mcpCommands.ts | Extend “List Servers” to prefer agent-host session servers and add toggle UX. |
| src/vs/workbench/contrib/mcp/browser/mcp.contribution.ts | Register the new agent-host MCP server options command. |
| src/vs/workbench/contrib/chat/test/browser/agentSessions/resolveCustomizationRefs.test.ts | Add tests for MCP-only plugin inclusion and dedup behavior. |
| src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts | Update active-client semantics tests (“claim on first turn”). |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts | Defer active-client claim until turn start. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostLocalCustomizations.ts | Add MCP-only plugin refs + per-plugin nonce computation (mtime). |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostCustomizationService.ts | Add workbench API for reading/toggling agent-host MCP servers. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostActiveClientService.ts | Wire fileService into customization ref resolution. |
| src/vs/sessions/services/agentHost/browser/agentHostCustomizationService.ts | Forward MCP servers from sessions providers to the shared customization API. |
| src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteAgentHostCustomizationHarness.test.ts | Update provider test harness for new MCP-server API. |
| src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts | Expose session MCP servers and dispatch toggles back to host. |
| src/vs/sessions/common/agentHostSessionsProvider.ts | Extend provider interface with getMcpServers. |
| src/vs/platform/agentPlugins/common/pluginParsers.ts | Ensure parsed MCP server customizations advertise default MCP app capabilities. |
| src/vs/platform/agentHost/test/node/shared/mcpCustomizationController.test.ts | Add unit tests for MCP customization controller inventory/state behavior. |
| src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts | Update mock agent service for MCP request/notification plumbing. |
| src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts | Add tests for MCP inventory seeding success/failure paths. |
| src/vs/platform/agentHost/test/node/agentPluginManager.test.ts | Add tests for per-nonce materialization + locked-dir eviction behavior. |
| src/vs/platform/agentHost/node/shared/mcpCustomizationController.ts | New controller translating SDK MCP state into AHP customization actions + channel parsing. |
| src/vs/platform/agentHost/node/protocolServerHandler.ts | Route mcp:// requests via params.channel and broadcast MCP notifications. |
| src/vs/platform/agentHost/node/copilot/sessionCustomizationDiscovery.ts | Adjust refresh scheduling based on recursive vs non-recursive watch roots. |
| src/vs/platform/agentHost/node/copilot/copilotSessionWrapper.ts | Add SDK event hooks for MCP server inventory + tool refresh notifications. |
| src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts | Implement MCP request routing to SDK, inventory seeding, and notification fanout. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Plumb MCP notifications + MCP request handling through the agent provider surface. |
| src/vs/platform/agentHost/node/agentService.ts | Add MCP channel routing and aggregate MCP notifications across providers. |
| src/vs/platform/agentHost/node/agentPluginManager.ts | Materialize plugins per nonce and implement stale-nonce cleanup/eviction. |
| src/vs/platform/agentHost/electron-browser/localAgentHostService.ts | Relay MCP notifications from local agent host service to clients. |
| src/vs/platform/agentHost/common/state/protocol/mcpAppDefaults.ts | Define default MCP app capability declaration for server customizations. |
| src/vs/platform/agentHost/common/agentService.ts | Add MCP notification type + MCP request API + connection event plumbing. |
| src/vs/platform/agentHost/browser/remoteAgentHostProtocolClient.ts | Detect and emit MCP notifications received over JSON-RPC notifications. |
| src/vs/platform/agentHost/browser/nullAgentHostService.ts | Add no-op MCP notification event to null agent host service. |
Copilot's findings
- Files reviewed: 33/33 changed files
- Comments generated: 4
- copilotAgentSession: guard _seedMcpServersFromRpc against missing rpc.mcp surface (fixes copilotAgent.test.ts crash) and pass the error as a separate argument so the stack trace is preserved. - agentHostLocalCustomizations: drop the unnecessary async on addPluginRef; the async work is in a nested IIFE. - agentPluginManager: _evictIfNeeded now retains entries whose directory cannot be deleted (e.g. locked) and advances to the next LRU candidate instead of orphaning them. Added a test covering the locked-head/unlocked-tail case. Co-authored-by: Copilot <[email protected]>
…-mcp-integration # Conflicts: # src/vs/platform/agentHost/node/copilot/copilotAgent.ts
roblourens
approved these changes
Jun 10, 2026
Connor Peet (connor4312)
deleted the
connor4312/agent-host-mcp-integration
branch
June 10, 2026 23:59
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
When a Copilot CLI (or any agent-host) session is running MCP servers, those servers are now visible and controllable from the workbench. They show up in MCP: List Servers and run through VS Code's standard MCP UI, alongside locally-configured servers.
What this changes
MCP: List Serversnow defaults to the focused agent-host session's MCP servers when one is open. Each server shows its live status (Starting / Running / Error / etc.) and can be enabled or disabled in place. A trailingShow locally configured servers…entry switches back to the existing local picker.CopilotAgentSessionadvertises the standard MCP app capabilities (sampling + resources) and routes server notifications by channel scheme. The inventory is seeded fromrpc.mcp.listat subscription time so restored sessions and eagerly-configured servers populate immediately.EBUSYfailures when a long-running session was holding files open from an older revision. Stale revisions are evicted opportunistically once their locks release.Tests
118 → 119 in
CopilotAgentSession(MCP seed success + failure paths). Added 3 plugin-manager tests (per-nonce materialization, locked-dir retention, startup-time eviction), 4resolveCustomizationRefstests (MCP-only plugin inclusion + dedup), and refreshed 2 active-client tests for the newclaim on first turnsemantics.