Skip to content

agentHost: preserve plugin MCP scope for projected agents - #342868

Draft
nfrank-ni wants to merge 2 commits into
microsoft:mainfrom
nfrank-ni:fix/plugin-agent-mcp-startup
Draft

nfrank-ni wants to merge 2 commits into
microsoft:mainfrom
nfrank-ni:fix/plugin-agent-mcp-startup

Conversation

@nfrank-ni

@nfrank-ni nfrank-ni commented Oct 20, 2026 •

Copy link
Copy Markdown

Summary

Fixes #342860.

plugin agent → SDK customAgents entry
  instructions + authored agent tool allowlist
+ owning plugin's enabled plugin-discovered MCP definitions
+ preserved server-level tool allowlists

The explicit SDK agent catalog loses native plugin-agent MCP association. Preserve that scope during projection using the existing MCP converter. Definitions remain authoritative inside the plugin; no global MCP configuration or manual Start requests are added.

Disabled servers are excluded, same-named servers stay scoped to their owning plugin's agents, and servers already registered through session config keep their existing path.

Preserve server-level tools through parsing and shared Copilot conversion: restricted lists stay restricted, [] exposes no tools, and omitted lists retain the existing ['*'] default. Malformed lists are rejected using the parser's existing invalid-entry behavior. This also preserves tool lists when reading supported CLI configuration entries.

Evidence

  • Startup regression before: projected agents have no mcpServers; 51 passing, 1 failing. After the initial fix: 52 passing.
  • Allowlist regression before: a test reading a plugin .mcp.json through agent projection reports 52 passing, 1 failing, with restricted and empty server lists incorrectly emitted as ['*']. After the follow-up: 116 passing across the converter, plugin parser, and shared Copilot configuration suites.
  • The new allowlist regression asserts literal expected lists independently of the converter, with an unrestricted agent. Covers stdio, HTTP, SSE, restricted, empty, wildcard, omitted, and malformed lists. Existing ownership, disabled-server, session-config exclusion, and agent allowlist coverage remains green.
  • npm run build-fast -- --client-only, targeted ESLint, and git diff --check pass.
  • A sanitized native-runtime startup reproduction fails without the MCP projection and passes with it on SDK releases 1.0.19-unstable.38345923974.g3754b70 and 1.0.23-preview.5. Actual compiled patched converter output connects the server and exposes probe-read on the first model request without MCP Start requests or root server registration.
  • An additional current-pinned-runtime probe uses an unrestricted agent and a two-tool synthetic server: ['*'] exposes both tools, ['read'] exposes only read, and [] exposes neither. The server connects in all three cases.

Validation limits: native probes ran on Windows with a loopback synthetic model, not a complete Linux Agent Host/Insiders UI session. Full typecheck-client was rerun but remains blocked by missing Electron/original-fs declarations after native dependency installation failed; no diagnostics were reported for the changed files. The fast build transpiles rather than type-checks.

Recheck:

npm run build-fast -- --client-only
npm run test-node -- --run src/vs/platform/agentHost/test/node/copilotPluginConverters.test.ts --run src/vs/platform/agentPlugins/test/common/pluginParsers.test.ts --run src/vs/platform/mcp/test/common/mcpCopilotConfiguration.test.ts
npm run eslint -- src/vs/platform/agentHost/node/copilot/copilotPluginConverters.ts src/vs/platform/agentHost/test/node/copilotPluginConverters.test.ts src/vs/platform/agentPlugins/common/pluginParsers.ts src/vs/platform/mcp/common/mcpPlatformTypes.ts src/vs/platform/mcp/common/mcpCopilotConfiguration.ts src/vs/platform/mcp/test/common/mcpCopilotConfiguration.test.ts

Merge Danger

Door: two-way

Reversible projection and shared configuration conversion changes; no protocol or persisted configuration migration.

Blast Radius: Copilot

Affects projected plugin custom agents with plugin-discovered MCP servers and shared Copilot server configuration conversion. Existing behavior is unchanged when no server tool list is authored. Malformed authored tool lists now reject the server entry instead of silently becoming unrestricted. Kept draft for maintainer confirmation of intended SDK registration/lifecycle ownership and full host integration verification.

Carry enabled plugin-discovered MCP definitions into each owning SDK custom agent. Keep session-config servers on their existing registration path and preserve the authored tool allowlist.

Fixes microsoft#342860

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 20, 2026 12:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Projection loses server-level tool restrictions, and runtime lifecycle ownership still needs maintainer confirmation.

1 open issue
What changed in this PR

Preserves plugin-owned MCP definitions when projecting agents into the Copilot SDK catalog, addressing #342860.

Changes:

  • Attaches enabled, plugin-discovered MCP servers to their owning agents.
  • Adds regression coverage for ownership, disabled servers, session-config exclusion, and agent tool allowlists.
File Description
src/​vs/​platform/​agentHost/​test/​node/​copilotPluginConverters.test.ts Tests plugin-scoped MCP projection.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotPluginConverters.ts Includes owning-plugin MCP definitions in projected agents.

Review effort: Balanced

Comment on lines +256 to +258
const mcpServers = toSdkMcpServers((plugin.mcpServers ?? []).filter(server =>
server.sdkRegistration === 'pluginDiscovery' && !plugin.disabledMcpServers?.includes(server.name)
));

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and addressed in 6b8b52e. The parser discarded the authored server tools list, and shared Copilot conversion then hard-coded ['*'].

Server lists now survive parsing and conversion for stdio, HTTP, and SSE. Explicit [] remains empty; omitted lists retain the existing wildcard default. Malformed lists reject the server entry rather than falling back to wildcard access.

Added one regression reading a real in-memory .mcp.json through agent projection, with no agent-level restriction and literal expected server tool lists (not expectations derived from the converter). Observed 52 passing / 1 failing before the fix; 116 tests now pass across the three affected suites. Updated the existing CLI parsing expectation as well. Fast build, targeted lint, and whitespace checks pass.

Also checked actual compiled converter output with the current pinned native runtime and a two-tool synthetic server: wildcard exposes both tools, ['read'] exposes only read, and [] exposes no MCP tools. Full typechecking remains blocked by the checkout's missing Electron/original-fs declarations, with no diagnostics for changed files. Leaving the PR draft for maintainer confirmation of registration/lifecycle ownership.

@nfrank-ni

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Emerson"

Keep authored server tool restrictions through plugin parsing and shared Copilot conversion instead of replacing them with wildcard access. Preserve empty allowlists and reject malformed restrictions.

Add one regression from a plugin MCP file through agent projection, covering restricted, empty, wildcard, omitted, and malformed tool lists. Update the existing CLI configuration read expectation.

Refs microsoft#342860

Co-authored-by: Copilot <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent Host: selected plugin agent does not auto-start its plugin-owned MCP servers

3 participants