[v0.8 MCP 5] enforce project MCP trust boundaries - #1337
Open
sethkarten wants to merge 2 commits into
Open
Conversation
Reconstruct the unique net delta from PR #1263, excluding propagation merges.
This was referenced Aug 13, 2026
Register every supported MCP child command and describe declaration tests as offline previews.
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.
Replacement scope
This PR reconstructs and supersedes the unique implementation delta reviewed in #1263 without rewriting that historical branch. The original PR remains the immutable discussion record: #1263
core02-host-request-dispatcherv080/mcp-split-m5-project-trusta3ef6b6697d867a6740eaf8e8592ca85487b4f8677b188b92dc91365cb2bc41bdb46a50669d104a8) is the shared foundation. For reconstructed deltas it is a proven tree-compatible base, not an ancestry claim about the historical PR stack.Validation
tsgo --noEmit: passNo original PR was retargeted, closed, merged, or otherwise mutated.
Note
High Risk
Changes security-sensitive project filesystem access, trust policy, and MCP wiring at CLI/SDK startup; misconfiguration or stale bindings fail closed by omitting project declarations rather than surfacing errors in some paths.
Overview
Introduces declarative MCP endpoint records (name, HTTP(S) URL, enabled) separate from legacy
mcpServers, plus a newprime-agent mcpcommand family for list/inspect/preview/test/add/enable/disable/remove on user or--projectscope. Commands only mutate declarations, redact sensitive output, andtestreturns an offline initialize probe—no runtime or auth.Project scope is gated by a global
mcpProjectTrustPolicy(allowed directories + revision). The CLI loads global settings only before admitting project work; denied or malformed policy never opens project settings. Admitted access uses opaque admission tokens, a pinned-directory trust authority (retained root FD + binding validation), and descriptor-relative reads/writes of.prime/agent/settings.jsonvia a bounded Python helper.Session/SDK startup composes admission before full
SettingsManagerproject load, builds an immutable runtime declaration snapshot (user first; project merged only when admission stays valid; name/endpoint collisions drop the whole project contribution), and passes it toMcpManagerviagetDeclarationSnapshot()while host handlers still use global-only legacy servers. InjectedMcpManagerinstances are left untouched.Reviewed by Cursor Bugbot for commit 15f003a. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Enforce MCP project trust boundaries with admission-gated declaration snapshots
McpProjectTrustAuthoritythat pins project directories via retained file descriptors and issues opaque, revocable bindings; bindings are validated before and after use to detect identity changes (ABA, symlink swaps, root replacement).ProjectMcpDeclarationAdmissionas a capability token gating all project MCP declaration reads and writes; admission is derived from a global trust policy and released after session initialization.McpRuntimeDeclarationSnapshotcombining user and (admission-gated) project declarations, with collision detection, deterministic code-point ordering, and a SHA-256 revision digest;McpManagerexposes this viagetDeclarationSnapshot().ProjectSettingsOpenatclass that reads/writes.prime/agent/settings.jsonthrough a sandboxed stdlib-only Python helper over a dirfd, enforcing size/time limits and cooperative locking without exposing project paths.mcpcommand group (list,inspect,preview,test,add,enable,disable,remove) that enforces project trust policy for--projectscope and outputs redacted JSON.Macroscope summarized 15f003a.