Expand description
Tool Search — Semantic tool matching for dynamic MCP tool loading
When the MCP ecosystem grows large (100+ tools), injecting all tool descriptions into the system prompt wastes context. Tool Search selects only the relevant tools per-turn based on keyword and semantic matching.
§How It Works
- All registered tools (builtin + MCP) are indexed with their name, description, and parameter schema.
- Before each LLM call, the user prompt is matched against the index.
- Only tools scoring above the threshold are included in the request.
- Builtin tools are always included (they’re small and essential).
§Usage
use a3s_code_core::tool_search::{ToolIndex, ToolSearchConfig};
let config = ToolSearchConfig::default();
let mut index = ToolIndex::new(config);
// Index tools
index.add("mcp__github__create_issue", "Create a GitHub issue", &["github", "issue", "bug"]);
index.add("mcp__postgres__query", "Run a SQL query", &["sql", "database", "query"]);
// Search
let matches = index.search("create a bug report on GitHub", 5);
// → ["mcp__github__create_issue"]Structs§
- Tool
Index - Index of all registered tools for semantic search.
- Tool
Match - A scored search result.
- Tool
Search Config - Configuration for tool search behavior.