fix(spawn): sub-agents inherit parent MCP server refs#482
Merged
Conversation
A spawned sub-agent silently lost access to every MCP server the parent was granted: build_sub_agent_crd_with_labels emitted spec.governance but never copied governance.mcpServerRefs, so e.g. a Playwright-MCP parent spawned children with no browser tools. The spawn path already fetches the parent CR (for label inheritance); it now also extracts the parent's effective governance.mcpServerRefs (parent_mcp_server_refs, honoring the deprecated singular mcpServerRef shim like GovernanceConfig::effective_mcp_server_refs) and overlays them onto the child's spec.governance. Refs are by-name into the child CR's namespace — the parent's namespace, where the McpServer CRs and <parent>-inference/-toolpolicy already live — so they resolve verbatim and the controller mirrors the JWKS/signing material + derives the MCP egress rule for the child exactly as it does for the parent. Tests live in the sibling mcp_inherit_test.rs submodule to keep spawn/mod.rs lean; phase0 LOC cap bumped 1400->1450 for the new logic. Also documents the inheritance in docs/mcp.md and de-pins the getting-started install to @latest so docs don't drift each release. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
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.
Problem
A spawned sub-agent silently loses access to every MCP server the parent was granted.
build_sub_agent_crd_with_labelsemitsspec.governancebut never copiesgovernance.mcpServerRefs, so e.g. a Playwright-MCP parent spawns a child sandbox with no browser tools. (Reported by Lachie: a skill run as a sub-agent couldn't reach the Playwright MCP server — labels/egressModewere inherited, but MCP access was not.)Fix
The spawn path already fetches the parent CR for label inheritance; it now also extracts the parent's effective
governance.mcpServerRefsand overlays them onto the child:parent_mcp_server_refs()readsspec.governance.mcpServerRefs, lifting the deprecated singularmcpServerRefinto plural form — mirroringGovernanceConfig::effective_mcp_server_refson the controller side.McpServerCRs and<parent>-inference/-toolpolicyalready live), so they resolve verbatim. The controller then mirrors the JWKS/signing material and derives the MCP egress rule for the child exactly as it does for the parent — no per-childMcpServerCR or manifest edit.Tests
5 new tests in a sibling
mcp_inherit_test.rssubmodule (mirrors the existingdev_profile_test.rspattern, keepsspawn/mod.rslean): plural read, singular-shim lift, plural-wins precedence, empty/absent cases, and the end-to-end child-governance overlay. All 21 spawn tests pass; clippy clean.Housekeeping
spawn/mod.rsphase0 LOC cap bumped 1400 → 1450 for the new production logic (entry already hadallow_grow: true; note updated).docs/mcp.md: new "Sub-agents inherit MCP access" section + troubleshooting row.docs/getting-started.md: de-pinned the install to@kars-runtime/cli@latestand removed the hardcodedv0.1.18so the quickstart doesn't drift every release.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com