feat(mcp): add shared bundled runtime scope#95591
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 26, 2026, 9:52 AM ET / 13:52 UTC. Summary PR surface: Source +162, Tests +434, Docs +14, Generated 0, Other 0. Total +610 across 12 files. Reproducibility: yes. source-level: current main and the latest release still key bundled MCP runtimes by session id, while the PR body provides real stdio terminal proof that default session scope starts separate processes/list calls and shared scope reuses one runtime/process/list call. Review metrics: 2 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land one maintainer-approved shared-runtime implementation with Do we have a high-confidence way to reproduce the issue? Yes, source-level: current main and the latest release still key bundled MCP runtimes by session id, while the PR body provides real stdio terminal proof that default session scope starts separate processes/list calls and shared scope reuses one runtime/process/list call. Is this the best way to solve the issue? Unclear as a final product choice. Workspace/config-keyed sharing in the runtime manager is the right implementation layer for the fan-out, but the best merge path requires maintainer acceptance of the new config/security boundary and the canonical branch choice versus #79882. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1cd6f81a46ae. Label changesLabel justifications:
Evidence reviewedPR surface: Source +162, Tests +434, Docs +14, Generated 0, Other 0. Total +610 across 12 files. View PR surface stats
Security concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
7c3e8d9 to
b9cd27f
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
b9cd27f to
4dda92b
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
ac88c99 to
b221481
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
b221481 to
f86e61a
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
d885b22 to
eff2e30
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
eff2e30 to
6c321ce
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
What Problem This Solves
Fixes #95506. Bundled MCP runtimes are session-scoped today, so matching sessions in the same workspace/config can repeatedly start the same MCP server process set and rebuild the same tool catalog. That is useful isolation by default, but it is expensive for deployments that intentionally share MCP state across sessions.
Why This Change Was Made
This adds an opt-in
mcp.runtimeScopeconfig with the default preserved assession. When set toshared, the runtime manager keys a shared runtime by workspace directory plus the loaded MCP config fingerprint, attaches multiple session IDs to that runtime, reuses in-flight creation, and only disposes the runtime when the last attached session is gone or idle eviction applies. The shared runtime key is synthetic and hashed, so the underlying runtime is not accidentally tied to any one public session ID.User Impact
Existing configurations keep per-session isolation. Users who opt into
mcp.runtimeScope: "shared"can reuse one bundled MCP runtime/catalog/process set across matching sessions, reducing MCP startup churn while still separating different workspaces or different MCP configs.Evidence
node scripts/run-vitest.mjs src/agents/agent-bundle-mcp-runtime.test.tspassed: 40 tests, including real stdio MCP proof that default session scope starts two server processes/list calls for two sessions while shared scope reuses one runtime/server process/list call.node scripts/run-vitest.mjs src/config/schema.test.ts src/config/schema.hints.test.ts src/config/schema.help.quality.test.ts src/config/doc-baseline.test.ts src/config/doc-baseline.integration.test.tspassed: 2 shards, 31 tooling tests + 62 runtime-config tests.corepack pnpm config:docs:checkpassed.corepack pnpm tsgo:corepassed.git diff --checkpassed.af2b0a611: re-rannode scripts/run-vitest.mjs src/agents/agent-bundle-mcp-runtime.test.ts(44 tests),node --import tsx scripts/generate-config-doc-baseline.ts --check,corepack pnpm tsgo:core, andgit diff --check; all passed.node --import tsxinvoked the productiongetOrCreateSessionMcpRuntimepath with a real stdio MCP child process and two session IDs against the same workspace/config. Redacted terminal output:corepack pnpm tsgo:test:srcwas attempted locally but produced no diagnostics and was interrupted after several minutes; not counted as passing evidence.