Skip to content

feat(mcp): mountable generic delegate() via MCP_ENABLE_DELEGATE on the mcp bin#357

Merged
drewstone merged 1 commit into
mainfrom
feat/mcp-bin-delegate-supervisor
Jun 22, 2026
Merged

feat(mcp): mountable generic delegate() via MCP_ENABLE_DELEGATE on the mcp bin#357
drewstone merged 1 commit into
mainfrom
feat/mcp-bin-delegate-supervisor

Conversation

@drewstone

Copy link
Copy Markdown
Contributor

What

Teaches the agent-runtime-mcp bin to serve the ONE generic delegate verb — so a consumer app can mount delegate() over the SAME stdio invocation it already uses, by flipping one env var.

The gap this closes

delegate is wired into createMcpServer via McpServerOptions.delegateSupervisor, and createDelegateHandler + the DELEGATE_* constants are exported from /mcp. But the published agent-runtime mcp bin only wired coderDelegate / researcherDelegate — it never wired delegateSupervisor. So npx @tangle-network/agent-runtime mcp (the invocation @tangle-network/agent-app's buildDelegationMcpServer mounts as a sandbox stdio child) could not serve delegate at all, and there was no standalone buildDelegateMcpServer. An app had no clean way to mount the generic verb.

Change

  • New src/mcp/delegate-supervisor-provisioning.ts: resolve the delegate supervisor substrate (router brain + worker backend) from env.
    • Opt-in via MCP_ENABLE_DELEGATE=1 (default off — additive, existing consumers unaffected).
    • Brain router: TANGLE_API_KEY + the repo's resolveRouterBaseUrl convention, normalized to /v1; model from MCP_SUPERVISOR_MODELMCP_WORKER_MODELWORKER_MODEL → default.
    • Worker backend: sandbox — authored workers run as sub-sandboxes via the same SandboxClient the bin already loads (the delegate_code deployment shape). Harness from MCP_DELEGATE_WORKER_HARNESS (default opencode).
    • Fail-closed: no key / not opted in → undefined, matching the coder/researcher posture.
  • bin.ts wires it into createMcpServer({ delegateSupervisor }) and adds delegate to the sandbox-client gate.
  • Tests for the resolver (6) + the env-var doc block + the canonical-api decision-table row.

Why this shape

Mirrors how coderDelegate is already env-gated. Every consumer app then swaps delegate_codedelegate by 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).

…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 tangletools left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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

@drewstone drewstone merged commit 409fcc6 into main Jun 22, 2026
1 check passed
@drewstone drewstone deleted the feat/mcp-bin-delegate-supervisor branch June 22, 2026 09:14
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.

2 participants