Skip to main content
Instead of injecting all tools at once, you can let the LLM discover and load tools on-demand using BM25 or semantic search.

ToolRouter

Methods:
  • getFilteredTools() - Get tools based on current strategy
  • searchTools(query, topK?, options?) - Search via BM25 + embeddings, optionally scoped by exact serverId or fragment-based serverName
  • searchToolsRegex(pattern, topK?) - Search via regex pattern
  • listServers(options?) - List connected indexed servers with tool counts
  • listTools(options?) - Deterministically list indexed tools, optionally scoped by server and paginated with cursor
  • refresh() - Re-index tools from all connected clients
  • setStrategy(strategy) - Change tool selection strategy at runtime
Use the ToolRouter with adapters like AIAdapter:

ToolIndex

Lightweight in-memory search index used internally by ToolRouter, or directly for specific custom discovery flows.

SchemaCompressor

Utility for yielding compact tool representations (name + description + inline parameterHint) without the full inputSchema.