Skip to content

Add enterprise allowedMcpServers / deniedMcpServers governance policies for MCP servers - #326226

Merged
Vijay Upadya (vijayupadya) merged 4 commits into
mainfrom
vijayu/allowMcpServer
Jul 17, 2026
Merged

Vijay Upadya (vijayupadya) merged 4 commits into
mainfrom
vijayu/allowMcpServer

Conversation

@vijayupadya

@vijayupadya Vijay Upadya (vijayupadya) commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes https://github.com/microsoft/vscode-internalbacklog/issues/7930

Summary

Adds enterprise-managed per-server MCP allow/deny lists so administrators can control which MCP servers may be installed and run. Servers are matched by name, remote URL pattern (with * wildcards), or exact local command invocation. Enforced at both install time and runtime, and delivered via enterprise policy (governance-only; not surfaced in the Settings UI).

Settings / policies

  • chat.mcp.allowedServers (policy ChatAllowedMcpServers) — when set, only matching servers are permitted; omit to allow all.
  • chat.mcp.deniedServers (policy ChatDeniedMcpServers) — matching servers are always blocked; deny takes precedence over allow.
  • Both are arrays of { serverName } | { serverUrl } | { serverCommand } matchers, included: false (policy-only), delivered through the managed-settings pipeline (server managed_settings, native MDM, or file).

Behavior

  • Composes with the existing coarse chat.mcp.access gate — controls are ANDed; the most restrictive wins. chat.mcp.access: none still blocks everything, and registry continues to be enforced independently.
  • allowedServers unset ⇒ no allow restriction; [] ⇒ block all. deniedServers [] ⇒ no-op.
  • URL matching is host-aware: * wildcards in the authority (scheme/host/port) never cross / into the path, so an authority wildcard cannot admit an untrusted host.
  • Install-time enforcement runs inside the install operation itself (both direct install and gallery install), evaluated against the fully resolved server configuration — not only the canInstall UI check — so the management APIs can't be used to bypass it.
  • Runtime enforcement is reactive: tightening the policy stops an already-running server, and a blocked server never connects, its cached tools/prompts are suppressed, and tool execution is rejected.
  • To avoid over-eager blocking, evaluation is deferred while a server's launch is unresolved (definition not yet loaded, or unresolved ${...} variables) and decided authoritatively once resolved.
  • Blocked servers surface a clear error state in the MCP UI (distinct messages for "not allowed" vs "blocked by policy") directing the user to their administrator; they never connect or expose tools.

Copilot AI review requested due to automatic review settings July 16, 2026 20:52
@vijayupadya Vijay Upadya (vijayupadya) changed the title Add enterprise allowedMcpServers / deniedMcpServers governance polici… Add enterprise allowedMcpServers / deniedMcpServers governance policiy Jul 16, 2026
@vijayupadya Vijay Upadya (vijayupadya) changed the title Add enterprise allowedMcpServers / deniedMcpServers governance policiy Add enterprise allowedMcpServers / deniedMcpServers governance policies for MCP servers Jul 16, 2026

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.

Pull request overview

Adds enterprise governance policies for per-server MCP allow/deny lists across installation and runtime.

Changes:

  • Adds managed policy definitions and normalization.
  • Implements name, URL-pattern, and command matching.
  • Adds runtime enforcement, UI error states, and tests.
Show a summary per file
File Description
build/lib/policies/policyData.jsonc Exports both policies.
src/vs/platform/mcp/common/allowedMcpServers.ts Implements matcher validation and evaluation.
src/vs/platform/mcp/common/allowedMcpServersService.ts Applies configured governance rules.
src/vs/platform/mcp/common/mcpManagement.ts Defines policy settings and service API.
src/vs/platform/mcp/test/common/allowedMcpServers.test.ts Tests matcher behavior.
src/vs/platform/mcp/test/common/allowedMcpServersService.test.ts Tests service enforcement.
src/vs/platform/policy/common/copilotManagedSettings.ts Normalizes new managed-setting keys.
src/vs/workbench/contrib/chat/browser/chat.shared.contribution.ts Registers policy-only configurations.
src/vs/workbench/contrib/mcp/common/mcpServer.ts Adds runtime policy checks and error state.
src/vs/workbench/services/accounts/browser/managedSettings.ts Types server-managed matcher payloads.
src/vs/workbench/services/accounts/test/browser/managedSettings.test.ts Tests payload adaptation.

Review details

  • Files reviewed: 11/11 changed files
  • Comments generated: 8
  • Review effort level: Medium

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@vijayupadya
Vijay Upadya (vijayupadya) marked this pull request as ready for review July 17, 2026 01:16
@vijayupadya
Vijay Upadya (vijayupadya) enabled auto-merge (squash) July 17, 2026 02:24
@vijayupadya
Vijay Upadya (vijayupadya) merged commit e1b1837 into main Jul 17, 2026
29 checks passed
@vijayupadya
Vijay Upadya (vijayupadya) deleted the vijayu/allowMcpServer branch July 17, 2026 02:48
@vs-code-engineering vs-code-engineering Bot added this to the 1.130.0 milestone Jul 17, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Aug 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants