Repository navigation
Route host-discovered MCP server enablement to the agent host - #343350
Merged
Vritant Bhardwaj (vritant24) merged 2 commits intoOct 22, 2026
Merged
Conversation
Servers from ~/.copilot/mcp-config.json are discovered by the agent host, which owns their Global decision, but the window also loads them as a local MCP collection. The customizations editor saw that local twin and wrote only the window's profile enablement, so disabling such a server never reached the agent host and the next turn started it again. When the active agent-host session server is not client-bundled, the primary toggle, its displayed state and the row menus now read and write the session server's enablement through the agent host. Client-forwarded servers and non-agent-host harnesses keep their existing behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
!server.isClientBundledtreatsundefinedastrue, which can incorrectly classify a server as… · New When multiplemenuActionGroupscontain local enablement actions,agentHostEnablementActionscan… · New Passingundefinedto trigger the default scopes is correct but obscures intent. Prefer passing an… · New
What changed in this PR
Routes enablement decisions for host-discovered MCP servers (that have a same-named “local twin”) to the agent host so global disables actually take effect, fixing the “local twin disable never reaches host” bug referenced in #343250.
Changes:
- Introduces “host-owned” server detection to ignore local enablement for host-discovered servers and to source state/actions from the agent host instead.
- Updates built-in and server-item menus to replace local enablement actions with agent-host actions when appropriate.
- Adds a dedicated test suite covering host-discovered servers with a stale local twin, client-forwarded servers, and no active agent-host session.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/aiCustomization/mcpListWidget.ts | Adds host-ownership routing logic and adjusts enablement/action selection to target the agent host for host-discovered servers. |
| src/vs/workbench/contrib/chat/test/browser/aiCustomization/mcpListWidget.test.ts | Adds/updates tests to validate routing behavior for host-owned vs client-owned servers and session/no-session cases. |
Review effort: Lite
- Append agent-host enablement actions at most once when several menu groups hold local enablement actions. - Pass the host-owned scope list explicitly instead of relying on the default parameter. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Vritant Bhardwaj (vritant24)
marked this pull request as ready for review
October 21, 2026 23:48
Vritant Bhardwaj (vritant24)
enabled auto-merge
October 21, 2026 23:49
roblourens
approved these changes
Oct 22, 2026
Vritant Bhardwaj (vritant24)
deleted the
agents/fix-mcp-server-forwarding-bug
branch
October 22, 2026 00:12
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.



Fixes one bug from #343250 (comment): disabling an MCP server that comes from
~/.copilot/mcp-config.jsonnever reached the agent host. The other bugs in that comment (per-profile storage, last-writer-wins merging, tool set switches) are not addressed here.Problem
Copilot-home servers are discovered by the agent host, which owns their Global decision. The window never forwards them (
CopilotHomeNotForwarded), but it also loads that file as a local MCP collection, so the row has a local twin (for examplecopilot.null.github).In
mcpListWidget.ts, whenever a local id existed:setPrimaryMcpServerEnablementwrote only the window's profilemcp.enablementand never calledsetCustomizationEnablement.isPrimaryMcpServerEnabledread that same local state, so the row showed "Disabled (Globally)".The host published
enablement: null, never reconciled the server off, and the next turn started it again.Change
When the active agent-host session server is not client-bundled (
isClientBundledfalse, the samechildEnablementrule the host uses to decide Global ownership), the local twin is ignored for enablement:enablement.mcp.jsonrows paired with a host-owned server, the local Global/Workspace actions are replaced by the host's.Client-forwarded
mcp.jsonservers (isClientBundledtrue) and non-agent-host harnesses keep their current behavior.The local twin is not written or migrated.
_syncClientMcpEnablementalready mirrors an accepted host Global decision onto the single same-named local server, so the host stays the single source of truth.Testing
./scripts/test.sh --run src/vs/workbench/contrib/chat/test/browser/aiCustomization/mcpListWidget.test.ts: passed (126 passing). With the source change reverted, 2 tests fail.npm run typecheck-client: passed.npm run eslint -- <changed files>: passed.github(from~/.copilot/mcp-config.json) off wrote{"global":{"mcpServers#github":false}}toagent-host-storage.json; the running session loggedReconciling MCP server 'github' enablement: disable; the next turn and a new session reportedgithubonly asdisabled (stopped)and never started it.Known trade-offs
copilot.null.github: false) from the old bug are not migrated; they now only affect the Local harness.mcp.jsonserver sharing a name with a host-discovered one now controls the host's server.