feat(mcp): mountable generic delegate() via MCP_ENABLE_DELEGATE on the mcp bin#357
Merged
Merged
Conversation
…e mcp bin The agent-runtime mcp bin served delegate_code / delegate_research from env but never wired delegateSupervisor, so the published `agent-runtime mcp` invocation (which agent-app's buildDelegationMcpServer mounts as a sandbox stdio child) could not serve the generic `delegate` verb at all — there was no clean way for a consumer app to mount delegate() as an MCP. Teach the bin to resolve the delegate supervisor from env (opt-in, MCP_ENABLE_DELEGATE=1): router brain from the platform key + resolveRouterBaseUrl convention, workers on a sandbox backend via the same loaded SandboxClient (the delegate_code deployment shape). Additive and fail-closed: existing consumers are unaffected; no key -> no delegate. Apps now swap delegate_code -> delegate by flipping env on the SAME bin mount.
tangletools
approved these changes
Jun 22, 2026
tangletools
left a comment
Contributor
There was a problem hiding this comment.
✅ Auto-approved PR — 3fd84879
Blanket team auto-approval is enabled for this reviewer service.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.
tangletools · auto-approval · reason: blanket_auto_approve · 2026-06-22T09:11:30Z
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.
What
Teaches the
agent-runtime-mcpbin to serve the ONE genericdelegateverb — so a consumer app can mountdelegate()over the SAME stdio invocation it already uses, by flipping one env var.The gap this closes
delegateis wired intocreateMcpServerviaMcpServerOptions.delegateSupervisor, andcreateDelegateHandler+ theDELEGATE_*constants are exported from/mcp. But the publishedagent-runtime mcpbin only wiredcoderDelegate/researcherDelegate— it never wireddelegateSupervisor. Sonpx @tangle-network/agent-runtime mcp(the invocation@tangle-network/agent-app'sbuildDelegationMcpServermounts as a sandbox stdio child) could not servedelegateat all, and there was no standalonebuildDelegateMcpServer. An app had no clean way to mount the generic verb.Change
src/mcp/delegate-supervisor-provisioning.ts: resolve thedelegatesupervisor substrate (router brain + worker backend) from env.MCP_ENABLE_DELEGATE=1(default off — additive, existing consumers unaffected).TANGLE_API_KEY+ the repo'sresolveRouterBaseUrlconvention, normalized to/v1; model fromMCP_SUPERVISOR_MODEL→MCP_WORKER_MODEL→WORKER_MODEL→ default.sandbox— authored workers run as sub-sandboxes via the sameSandboxClientthe bin already loads (thedelegate_codedeployment shape). Harness fromMCP_DELEGATE_WORKER_HARNESS(defaultopencode).undefined, matching the coder/researcher posture.bin.tswires it intocreateMcpServer({ delegateSupervisor })and addsdelegateto the sandbox-client gate.Why this shape
Mirrors how
coderDelegateis already env-gated. Every consumer app then swapsdelegate_code→delegateby flipping env on the SAME bin mount it already has — no app-specific entrypoint, no new sandbox image. (Pilot: the legal-agent swap that proved this —tangle-network/legal-agent#211.)Verify
pnpm run build— green.pnpm run typecheck— clean.pnpm exec vitest run tests/mcp/— 294 pass (incl. the 6 new resolver tests).pnpm run lint— clean.pnpm run docs:check— OK (version pin + decision-table row updated).Version bump 0.71.0 → 0.71.1 (additive).