Repository navigation
feat(subagents): connect mcp.json servers with a profile's mcp: on (#1053) - #1187
Merged
Merged
Conversation
…1053) A profile with `mcp: on` (frontmatter, or the Agents panel's "Connect MCP servers" switch) gives its children `builtin:tool-search` and `builtin:mcp` with an MCP host of their own, so they connect the servers in mcp.json under the same trust rules as a normal session. Missing means off. - The built-ins load through `additionalExtensionPaths` (the CLI's `-e builtin:<name>`), which works under `noExtensions` and keeps the `builtin:mcp` path the host only activates for. That path also skips `-builtin:` settings, so each factory reads its switch on every load. - An allowlist admits MCP tools by name (`mcp__*` and the resource tools), plus `tool_search` when the child has no Code mode, whose `codemode` servers then register as `deferred`. - `createSubagentMcpPolicyExtension()` blocks MCP-named tools of extensions the profile's `ext:` selectors left out, and, while the child's built-in tools are read-only (Explore, Plan), every MCP tool without `readOnlyHint`, codemode scripts included. - Runs prompt the SDK session directly, so they wait for `direct` servers through the wrapper's new `prepareMcpForRun()`. abortSubagent, the parent's Stop and Stop in the child's chat all end the wait and abort the run before it starts. - The snapshot keeps `mcp: true` for reload, resume and RPC reopen. A chat-only profile rejects `mcp: on`; the panel disables the switch there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
…gegr#1053) (agegr#1187) A profile with `mcp: on` (frontmatter, or the Agents panel's "Connect MCP servers" switch) gives its children `builtin:tool-search` and `builtin:mcp` with an MCP host of their own, so they connect the servers in mcp.json under the same trust rules as a normal session. Missing means off. - The built-ins load through `additionalExtensionPaths` (the CLI's `-e builtin:<name>`), which works under `noExtensions` and keeps the `builtin:mcp` path the host only activates for. That path also skips `-builtin:` settings, so each factory reads its switch on every load. - An allowlist admits MCP tools by name (`mcp__*` and the resource tools), plus `tool_search` when the child has no Code mode, whose `codemode` servers then register as `deferred`. - `createSubagentMcpPolicyExtension()` blocks MCP-named tools of extensions the profile's `ext:` selectors left out, and, while the child's built-in tools are read-only (Explore, Plan), every MCP tool without `readOnlyHint`, codemode scripts included. - Runs prompt the SDK session directly, so they wait for `direct` servers through the wrapper's new `prepareMcpForRun()`. abortSubagent, the parent's Stop and Stop in the child's chat all end the wait and abort the run before it starts. - The snapshot keeps `mcp: true` for reload, resume and RPC reopen. A chat-only profile rejects `mcp: on`; the panel disables the switch there. Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
…gegr#1053) (agegr#1187) A profile with `mcp: on` (frontmatter, or the Agents panel's "Connect MCP servers" switch) gives its children `builtin:tool-search` and `builtin:mcp` with an MCP host of their own, so they connect the servers in mcp.json under the same trust rules as a normal session. Missing means off. - The built-ins load through `additionalExtensionPaths` (the CLI's `-e builtin:<name>`), which works under `noExtensions` and keeps the `builtin:mcp` path the host only activates for. That path also skips `-builtin:` settings, so each factory reads its switch on every load. - An allowlist admits MCP tools by name (`mcp__*` and the resource tools), plus `tool_search` when the child has no Code mode, whose `codemode` servers then register as `deferred`. - `createSubagentMcpPolicyExtension()` blocks MCP-named tools of extensions the profile's `ext:` selectors left out, and, while the child's built-in tools are read-only (Explore, Plan), every MCP tool without `readOnlyHint`, codemode scripts included. - Runs prompt the SDK session directly, so they wait for `direct` servers through the wrapper's new `prepareMcpForRun()`. abortSubagent, the parent's Stop and Stop in the child's chat all end the wait and abort the run before it starts. - The snapshot keeps `mcp: true` for reload, resume and RPC reopen. A chat-only profile rejects `mcp: on`; the panel disables the switch there. Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Closes #1053.
Problem
Built-in subagents never loaded pi-web's
mcpbuilt-in or an MCP host, so they could not reach the servers inmcp.json. #1097 added Code mode for subagents, but MCP was still listed as later work in ADR 0006.Change
A profile can set
mcp: on | off(missing means off;truereads as on). The Agents panel has a "Connect MCP servers" switch under Resources.mcp: onloadsbuiltin:tool-searchandbuiltin:mcpwith anMcpHostof its own (createSubagentMcpExtensions()). They come in throughadditionalExtensionPaths, the CLI's-e builtin:<name>, which works undernoExtensionsand keeps thebuiltin:mcppath the host only activates for. That path also skips-builtin:settings, so each factory reads its switch on every load, as the child's Code mode does. Normal sessions keep their own wiring;createMcpBuiltins()is now shared by both.mcp__*and the resource tools). Without Code mode,codemodeservers register asdeferredandtool_searchjoins the allowlist; with Code mode, scripts reach them andtool_searchstays out of requests.createSubagentMcpPolicyExtension()): blocks MCP-named tools of extensions the profile'sext:selectors left out (the concern feat(subagents): add opt-in codemode support #1097 fixed for scripts). While the child's built-in tools are read-only (Explore, Plan), it also blocks every MCP tool withoutreadOnlyHint: true, codemode scripts included. A profile of extension tools alone is not read-only.directservers through the wrapper'sprepareMcpForRun(), as a sent prompt does. abortSubagent, the parent's Stop and Stop in the child's own chat all end that wait, and the run is aborted before it starts.steer_subagentduring the wait (at most 10 s) is refused, as for any non-running child.mcp: true, so reload, resume and RPC reopen load the same; older snapshots load no MCP.mcp: onat spawn, and the panel disables the switch for a chat-only draft (it can still turn an existingonoff).mcpkey; a request without the field keeps the file's value.docs/agents/subagents.md,tools.md,mcp-runtime.md, ADR 0006.Not in this PR:
mcp: inherit, and choosing which servers a profile connects. Each child connects its own servers, so stdio servers start once more per child; the wrapper disposes the host when it closes, and idle release applies.Verification
lib/subagent-mcp.integration.test.mjs(11 tests) runs realAgentSessions and the real wrapper against the stdio fixture server: a direct MCP call; the read-only block and areadOnlyHinttool allowed;tool_searchloading acodemodeserver without Code mode; a script calling one with Code mode; another extension'smcp__tool blocked underext:selectors; no MCP without the key; chat-only rejection; resume after the child closed (RPC reopen keeps MCP and the read-only scope); and each of the three Stops during the wait against a server that never answers.tsc --noEmitand the full suite (2616 tests, 0 failures, 1 skipped) pass; eslint passes on the changed files (the fulleslint .was not run to completion).mcp: onfrom the file, is disabled with its hint on a chat-only profile and enabled once a tool is ticked, and saving writesmcp: 'off'/mcp: 'on'.🤖 Generated with Claude Code