Repository navigation
agentHost: fix MCP routing activation and sign-in fallback - #343241
Merged
Martin Aeschlimann (aeschli) merged 2 commits intoOct 21, 2026
Merged
Martin Aeschlimann (aeschli) merged 2 commits into
Martin Aeschlimann (aeschli) merged 2 commits into
Conversation
Advertise actual per-chat routing registrations so servers without routing tools retain sign-in hints. Await shared server activation and tool readiness, and settle activation when authentication is cancelled without aborting the turn. Cover routing availability transitions, authentication cancellation, retries, and metadata validation with regression tests. 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
readMcpRoutingServers returns the underlying array stored in _meta. Because arrays are mutable, a… · New This equality check is order-sensitive. If proxy insertion order can vary (e.g., async registration… · New Disposing the CancellationTokenSource withtruewill cancel the token even after a successful… · New
What changed in this PR
Fixes experimental MCP tool routing behavior to (1) keep proactive MCP sign-in hints accurate based on actual routing tool registrations per chat, and (2) ensure routing waits for MCP server readiness/tools and shares activation across concurrent calls.
Changes:
- Advertise/consume per-chat MCP routing registrations via session
_meta(vscode.mcpRoutingServers) to drive sign-in hint behavior. - Add shared MCP routing activation that waits for server readiness/tools (including cancellation handling) before tool discovery.
- Add/adjust regression tests and update the routing setting description.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts | Extends test harness to simulate routing registration meta; adds coverage for sign-in hint behavior under routing registration changes. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts | Always wires MCP auth prompting, but suppresses/resurfaces hints based on actual per-chat routing registrations. |
| src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts | Adds routing activation/ready-tool-waiting/concurrency/cancellation tests; adjusts expectations for tool discovery calls. |
| src/vs/platform/agentHost/test/common/agentMetaReaders.test.ts | Adds tests for routing server meta validation and opaque metadata preservation. |
| src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts | Implements per-chat routing registration emission and shared routing server activation (waits for readiness/tools, handles cancellation). |
| src/vs/platform/agentHost/common/meta/vscode/mcpCustomizationMeta.ts | Introduces readMcpRoutingServers / withMcpRoutingServers metadata helpers. |
| src/vs/platform/agentHost/common/meta/mcpCustomizationMeta.ts | Re-exports new routing meta helpers. |
| src/vs/platform/agentHost/common/agentHostStarter.config.contribution.ts | Updates experimental setting description to reflect tool-search dependency and new hint/activation behavior. |
Review effort: Lite
roblourens
previously approved these changes
Oct 21, 2026
Read SDK-global configurations before session launch so uncached, unauthenticated servers have routing tools on the first request. Preserve configuration precedence, enablement, and SDK ownership.\n\nReturn independent routing metadata snapshots and normalize registration ordering. Document why activation cleanup cancels its private token. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Martin Aeschlimann (aeschli)
enabled auto-merge (squash)
October 21, 2026 16:10
TylerLeonhardt
approved these changes
Oct 21, 2026
Martin Aeschlimann (aeschli)
deleted the
aeschli/agents/mcp-routing-tools-auth-implementation
branch
October 21, 2026 18:48
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
Fix three gaps in experimental MCP tool routing:
mcp.config.list()API, so a newly configured server such as Atlassian has a routing tool even before its first authentication and without cached tool metadata. This does not start servers eagerly or copy SDK-owned configurations into session registration. Existing configuration precedence and disabled-server filtering are preserved.Authentication cancellation settles routing activation without aborting the turn. Sign-in hints can reappear if routing is registered and subsequently removed, while unrelated hint deduplication remains intact.
Routing metadata readers return independent snapshots, and registration metadata uses stable ordering to avoid order-only updates. Activation cleanup deliberately cancels its private token to release the listener retained by
waitForState.Includes regression tests for first-use SDK-global routing on create/resume, activation without a client-provided server definition, configuration precedence and disabled names, metadata isolation, and stable registration ordering. The feature remains experimental and disabled by default.
Validation
Passed:
npm run build-fast -- --client-onlynpm run typecheck-clientgit diff --checkFollow-up changed-file ESLint:
Focused unit tests: 261 passing:
./scripts/test.sh --reporter dot \ --run src/vs/platform/agentHost/test/common/agentMetaReaders.test.ts \ --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts \ --run src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts \ --grep 'client tool calls|MCP server|MCP (authentication|sources|provenance)|MCP lifecycle|user configuration lookup|publishes user MCP|registered MCP routing|mcp authentication|cancelled OAuth|cancel.*authentication|cancel.*auth|shared.*auth'Live validation used Code OSS's default user-data directory with routing enabled and an unauthenticated SDK-global Atlassian server:
Full integration and smoke suites were not run.