Repository navigation
feat: defer large MCP tool sets behind tool_search - #45
Merged
Merged
Conversation
Closes #42. Servers exposing more than [mcp] tool_search_threshold tools (default 20, 0 disables) no longer ship their definitions in every request: the model gets a single tool_search tool, and keyword matches activate as regular tools for the rest of the session. /mcp reports the deferred count per server.
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 #42.
Servers with more than
[mcp] tool_search_thresholdtools (default 20, 0 disables) keep their tools out of every request. The model gets a singletool_searchtool; keyword matches (name hits first, then descriptions) activate as regularmcp:<server>:<tool>wrappers with their schemas echoed in the result, callable immediately on the next turn. Permissions, approval, and/mcp enable|disablebehave exactly as for directly-registered tools;/mcplists the deferred count per server.Sync logic lives in
McpManager._sync_tools: deferral is recomputed on every connect/reconnect/auth/enable cycle, activated tools stay registered, stale deferred entries are dropped when a server shrinks or disconnects, andtool_searchitself exists exactly while deferred tools do.Tests: tests/test_mcp_tool_search.py (9 cases over the stdio mock server: deferral, thresholds 20/0, activation + dispatch round-trip, description matching, empty state, disable/enable cycle) plus the readonly permission matrix. Full suite green locally after merging main (2328+ passed).