Skip to content

fix(spawn): sub-agents inherit parent MCP server refs#482

Merged
pallakatos merged 2 commits into
mainfrom
fix/subagent-mcp-inheritance
Jun 30, 2026
Merged

fix(spawn): sub-agents inherit parent MCP server refs#482
pallakatos merged 2 commits into
mainfrom
fix/subagent-mcp-inheritance

Conversation

@pallakatos

Copy link
Copy Markdown
Collaborator

Problem

A spawned sub-agent silently loses access to every MCP server the parent was granted. build_sub_agent_crd_with_labels emits spec.governance but never copies governance.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/egressMode were 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.mcpServerRefs and overlays them onto the child:

  • New parent_mcp_server_refs() reads spec.governance.mcpServerRefs, lifting the deprecated singular mcpServerRef into plural form — mirroring GovernanceConfig::effective_mcp_server_refs on the controller side.
  • The 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. 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-child McpServer CR or manifest edit.
  • Purely additive: a parent with no MCP refs yields a child with none.

Tests

5 new tests in a sibling mcp_inherit_test.rs submodule (mirrors the existing dev_profile_test.rs pattern, keeps spawn/mod.rs lean): 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.rs phase0 LOC cap bumped 1400 → 1450 for the new production logic (entry already had allow_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@latest and removed the hardcoded v0.1.18 so the quickstart doesn't drift every release.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

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>
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@pallakatos pallakatos merged commit cb2f687 into main Jun 30, 2026
36 checks passed
@pallakatos pallakatos deleted the fix/subagent-mcp-inheritance branch June 30, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant