ToolRAG
TypeScript library that uses semantic search over MCP tool definitions to give LLMs only the tools relevant to each query.
At a Glance
ToolRAG core library released under the Apache License 2.0; free to use, modify and distribute. Embedding providers (OpenAI, Google) and LLM usage are external costs.
Engagement
Available On
Listed Oct 2026
About ToolRAG
ToolRAG is an open-source TypeScript library published by the GitHub user antl3x. It connects to Model Context Protocol (MCP) servers, embeds their tool definitions, and returns only the tools relevant to a user query, formatted as OpenAI function definitions. The project is licensed under Apache 2.0.
What It Is
ToolRAG applies a retrieval-augmented generation approach to tool selection. Instead of passing every function definition to a language model, it stores tool definitions and their vector embeddings, then retrieves the best matches for each query. The README says this lets developers work with an unlimited number of tools while avoiding context window limits, extra token costs, and the performance drop that comes from overloading a model with definitions.
How the Workflow Runs
A developer initializes ToolRAG with a list of MCP server URLs. ToolRAG registers the tools those servers expose and generates embeddings from tool descriptions and parameters, using OpenAI or Google embedding providers. When a query arrives, listTools(query) returns the most relevant tools through cosine similarity search. These can be passed to an LLM call such as the OpenAI Responses API. The function calls the model returns are then run with callTool, which executes them against the matching MCP servers.
Architecture and Configuration
Tool definitions and embeddings are stored in a LibSQL database. Configuration options include the embedding provider, customizable relevance thresholds, and database settings for persistence. The README lists multi-tool AI assistants, enterprise systems connecting to internal tools, and unified tool discovery platforms as intended use cases.
Setup Path
The package is installed from npm as @antl3x/toolrag with npm, yarn, or pnpm. The quick start initializes ToolRAG with MCP server URLs and passes the retrieved tools to an OpenAI model.
Community Discussions
Be the first to start a conversation about ToolRAG
Share your experience with ToolRAG, ask questions, or help others learn from your insights.
Pricing
Open Source
ToolRAG core library released under the Apache License 2.0; free to use, modify and distribute. Embedding providers (OpenAI, Google) and LLM usage are external costs.
- Licensed under Apache License 2.0
- Unlimited tool definitions via semantic tool retrieval
- MCP server integration
- OpenAI-compatible function definitions
- LibSQL storage for tool definitions and embeddings
Capabilities
Key Features
- Dynamic selection of relevant tools per query
- Semantic tool search using vector embeddings
- Reduced token usage by including only relevant function definitions
- Works with MCP-compliant servers
- Formats tools as OpenAI function definitions
- Executes selected tools against MCP servers
- LibSQL storage for tool definitions and embeddings
- Multiple embedding providers (OpenAI, Google)
- Customizable relevance thresholds
- Database configuration for persistence
