Skip to content

feat: defer large MCP tool sets behind tool_search - #45

Merged
wowi42 merged 2 commits into
mainfrom
feat/mcp-tool-search
Nov 20, 2026
Merged

wowi42 merged 2 commits into
mainfrom
feat/mcp-tool-search

Conversation

@wowi42

@wowi42 wowi42 commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Closes #42.

Servers with more than [mcp] tool_search_threshold tools (default 20, 0 disables) keep their tools out of every request. The model gets a single tool_search tool; keyword matches (name hits first, then descriptions) activate as regular mcp:<server>:<tool> wrappers with their schemas echoed in the result, callable immediately on the next turn. Permissions, approval, and /mcp enable|disable behave exactly as for directly-registered tools; /mcp lists 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, and tool_search itself 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).

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.
@wowi42
wowi42 merged commit c7080ab into main Nov 20, 2026
2 checks passed
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.

feat: tool_search to defer large MCP tool sets

1 participant