Expand description
In-memory index for progressive tool disclosure.
§Problem
Dumping the full JSON schema of every MCP tool to an external client (e.g.
VS Code Copilot) on every tools/list call costs 100 k+ tokens at 100+
tools and causes context-window timeouts. The Progressive Disclosure
pattern fixes this by exposing three meta-tools instead of the full
registry:
| Meta-tool | Purpose |
|---|---|
search_tools | Keyword search; returns lightweight summaries |
get_tool_schema | Lazily fetches one tool’s full JSON schema |
invoke_tool | Forwards execution to the upstream MCP server |
§Design
ToolIndex is a pure-data, allocation-once structure built from the
complete McpTool list that the McpService already holds in memory.
It lives in gglib-core so that every frontend (CLI, Axum, Tauri) can
share the same type without depending on gglib-mcp.
The index intentionally does not cache itself inside AppState.
Rebuilding from the in-memory McpService on each search_tools or
get_tool_schema call is microseconds and automatically reflects MCP
server start / stop events.
Structs§
- Tool
Index - An in-memory index over all tools from all running MCP servers.
- Tool
Summary - A lightweight, schema-free description of a single MCP tool.
Constants§
- SEARCH_
RESULTS_ CAP - Maximum number of
ToolSummaryentries returned by a singleToolIndex::searchcall.