Repository navigation
Defer native MCP servers behind tool_search by default - #408
Merged
Merged
Conversation
Every server handed to pi was registered with exposure "direct", so all of its tool definitions went out with every request. Claude Code defers MCP tools behind tool search by default and declares them upfront only for a server with alwaysLoad: true or when ENABLE_TOOL_SEARCH is false. toNativeServer now registers a server as "deferred" unless it sets alwaysLoad: true or ENABLE_TOOL_SEARCH is "false". true, auto and auto:N defer, as pi has no context-size threshold. pi activates tool_search for deferred servers and names them in its mcp_servers prompt section. The smoke run now checks that the deferred server is listed for tool_search and its tool is not declared, that an alwaysLoad server's tool is declared, and that an unapproved project's server is neither declared nor listed. Closes #406
|
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.



Every server pi-code hands to pi's native MCP was registered with
exposure: "direct", so all of its tool definitions went out with every request: two plugin servers with 46 tools added about 39k characters to each one. Claude Code defers MCP tools behind tool search by default ("Tool search is enabled by default: MCP tools are deferred and discovered on demand", code.claude.com/docs/en/mcp#configure-tool-search).extensions/mcp/native.ts): a server is registered as"deferred". pi activatestool_searchfor it and names it in themcp_serversprompt section; its tools are declared oncetool_searchloads them.alwaysLoad: trueon the server, orENABLE_TOOL_SEARCH=false, registers it as"direct".alwaysLoadis now part of the server config types (extensions/mcp/config.ts).ENABLE_TOOL_SEARCHset totrue,autoorauto:Nregisters"deferred"; pi has no context-size threshold to load tools under.alwaysLoadno longer have their tools declared in the first request; the model reaches them throughtool_search.alwaysLoad: trueorENABLE_TOOL_SEARCH=falserestores upfront declaration.A tool's own
_meta["anthropic/alwaysLoad"]is not read, since pi-code does not connect the server in native mode;docs/mcp.mdsays so. Spec clause MCPN-012 added, MCPN-003 updated.The e2e smoke run checks that the deferred server is listed for
tool_searchandmcp__smoke__echois not declared, that analwaysLoadserver'smcp__loaded__echois declared, and that an unapproved project's server is neither declared nor listed. On the previous"direct"registration the first two checks fail.Closes #406
npm run checkpasses (Biome, strict tsc, Vitest)