Repository navigation
Hand MCP servers to pi's native MCP on pi 0.99 - #304
Merged
Merged
Conversation
Frames handing Claude-configured MCP servers to pi's own MCP support on pi 0.99 and later: acceptance clauses MCPN-001 to MCPN-011, micro-tasks, what native mode gives up, and the decisions taken.
pi 0.99 drops its built-in MCP support when an extension registers /mcp and warns about it on every start. When pi.registerMcpServer exists and no MCP policy is set, pi-code no longer registers /mcp or the resource tools, and hands each server it would connect to pi instead (MCPN-001 to MCPN-003). - Values are expanded by pi-code with Claude's rules and escaped for pi, so a leading ! or a $ in an env or header value is never run or expanded by pi. - sse, ws and websocket servers, servers with a headersHelper, and names pi rejects stay on pi-code's client (MCPN-005). - pi's own mcp.json files are left to pi (MCPN-006); approval and the disabled lists still decide what is registered (MCPN-007). - pi's mcp__ tools are published on the MCP tool roster each turn (MCPN-008). - When pi's /mcp is not running, everything connects on pi-code's client as before (MCPN-009).
The smoke configures a stdio MCP server and asserts pi declares its tool as mcp__smoke__echo on a pi with native MCP (smoke_echo before it) and prints no builtin:mcp replacement warning. docs/mcp.md describes native mode and what does not apply there.
fc.assert with a synchronous property returns nothing; the repo's other property tests prefix it with void for the noFloatingPromises rule.
Addresses the new-code Sonar findings: a boolean parameter selecting which config files load becomes claudeUserConfigPaths and claudeProjectConfigPaths, the bearer token ternary becomes a function, and the turn_start handler is synchronous.
|
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.



pi 0.99 ships its own MCP support and drops it when an extension registers
/mcp, printingExtension package "builtin:mcp": ... registers command /mcp, so built-in extension mcp was not loadedon every start. pi-code registered/mcp, so every pi 0.99 user saw that warning.When
pi.registerMcpServerexists and no MCP policy is set, pi-code keeps reading Claude's MCP configuration and applying approval, scopes and the disabled lists, and hands each server to pi instead of connecting it. Spec:docs/specs/mcp-native.md(MCPN-001 to MCPN-011).extensions/mcp/native.ts: translates a server config to pi'sMcpServerConfigwithexposure: "direct".${VAR}/${VAR:-default}are expanded by pi-code, and everyenvand header value is escaped ($as$$, a leading!as$!), so pi's resolver never runs or expands it. Claude'sCLAUDECODE/CLAUDE_*stdio variables, bearer tokens and theoauthfields are carried over; the timeout is pi-code's idle budget in seconds. Plugin servers register asplugin_<plugin>_<server>, so tools are namedmcp__plugin_<plugin>_<server>__<tool>as in Claude.sse,wsandwebsocketservers, servers with aheadersHelper, and names outside[A-Za-z0-9_-]stay on pi-code's client./mcpand no resource tools, does not read~/.pi/agent/mcp.jsonor.pi/mcp.json(pi reads them), republishes pi'smcp__tools on the tool roster each turn for hooks and subagent patterns, and unregisters its servers at session shutdown.managed-mcp.json,allowedMcpServersordeniedMcpServerskeep pi-code's own client for every server, since pi would connect its ownmcp.jsonservers outside those rules. When pi's/mcpis disabled (-builtin:mcp) or replaced, pi-code connects everything itself. pi before 0.99 is unchanged./mcp__server__promptcommands,@server:urimentions,mcp_toolhooks and pi-code's timeout and reconnect settings, and get the full parent environment as stdio servers (Claude's default). Documented indocs/mcp.md.scripts/e2e-smoke.shconfigures a stdio server and assertsmcp__smoke__echois declared and nobuiltin:mcpwarning is printed; both checks fail againstmain.A property test resolves escaped values with pi's own
resolveConfigValueOrThrowand gets the original text back for any mix of!,$,{and}.npm run checkpasses (Biome, strict tsc, Vitest)