mcp: enforce URL policy after variable resolution - #336849
Dmitriy Vasyura (dmitrivMS) wants to merge 2 commits into
Conversation
Distinguish preliminary definition checks from authoritative resolved launch checks. Validate the local resolved connection before starting its transport, and re-evaluate active connections whenever policy changes. Add regression coverage for literal variable markers, resolved URL allow/deny rules, permitted unresolved definitions, and policy changes affecting running servers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Preliminary checks still defer literal markers, and reactive denial loses its blocked state after clearing unresolved connections.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Enforces MCP URL policy against resolved runtime connections and reacts to policy changes.
Changes:
- Separates definition-time and resolved-runtime policy checks.
- Rechecks resolved connections before transport startup.
- Adds regression coverage for URL resolution and policy updates.
| File | Description |
|---|---|
allowedMcpServersService.ts |
Splits preliminary and authoritative checks. |
mcpManagement.ts |
Documents policy-check phases. |
mcpServer.ts |
Adds resolver-aware checks and reactive enforcement. |
allowedMcpServersService.test.ts |
Tests URL policy semantics. |
mcpService.test.ts |
Tests runtime resolution and policy updates. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Keep resolved policy blocks effective after disposing a connection, including suppression of cached tools and prompts. Settle startup waits on explicit stop or disposal so policy restoration permits a retry without regressing normal transport restarts. Share configuration-variable parsing with preliminary MCP checks so literal incomplete markers do not defer allow/deny enforcement. Add regression coverage for retained blocks, definition changes, preliminary checks, and cancelled startup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0052d68
Screenshot ChangesBase: Changed (2)1 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Definition updates can revive stale identities, bypass renamed-server policies, and leave cached metadata exposed under access or name restrictions.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Resolved since last review (2)
| if (resolved && definition && McpServerDefinition.equals(resolved.definition, definition)) { | ||
| return this._evaluatePolicy(resolved.identity); |


MCP URL rules must be enforced against the fully resolved launch, even if the resulting URL still contains text that resembles a configuration variable. Policy updates must also recheck existing connections and keep blocked servers from exposing cached tools or prompts.