npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@antl3x/toolrag

v0.0.3

Published

Context-aware tool retrieval for language models - unlock the full potential of LLM function calling without context window limitations or constraints.

Readme

toolrag-header

Introduction

ToolRAG provides a seamless solution for using an unlimited number of function definitions with Large Language Models (LLMs), without worrying about context window limitations, costs, or performance degradation.

🌟 Key Features

  • Unlimited Tool Definitions: Say goodbye to context window constraints. ToolRAG dynamically selects only the most relevant tools for each query.
  • Semantic Tool Search: Uses vector embeddings to find the most contextually relevant tools for a given user query.
  • Cost Optimization: Reduces token usage by only including the most relevant function definitions.
  • Performance Improvement: Prevents performance degradation that occurs when overwhelming LLMs with too many function definitions.
  • MCP Integration: Works with any Model Context Protocol (MCP) compliant servers, enabling access to a wide ecosystem of tools.
  • OpenAI Compatible: Format tools as OpenAI function definitions for seamless integration.

🔍 How It Works

  1. Tool Registration: ToolRAG connects to MCP servers and registers available tools.
  2. Embedding Generation: Tool descriptions and parameters are embedded using vector embeddings (OpenAI or Google).
  3. Query Analysis: When a user query comes in, ToolRAG finds the most relevant tools via semantic search.
  4. Tool Execution: Execute selected tools against the appropriate MCP servers.

Installation

npm install @antl3x/toolrag
# or
yarn add @antl3x/toolrag
# or
pnpm add @antl3x/toolrag

🚀 Quick Start

import { ToolRAG } from "@antl3x/toolrag";
import OpenAI from "openai";

// Initialize ToolRAG with MCP servers
const toolRag = await ToolRAG.init({
  mcpServers: [
    "https://mcp.pipedream.net/token/google_calendar",
    "https://mcp.pipedream.net/token/stripe",
    // Add as many tool servers as you need!
  ],
});

const userQuery =
  "What events do I have tomorrow? Also, check my stripe balance.";

// Get relevant tools for a specific query
const client = new OpenAI();

const response = await client.responses.create({
  model: "gpt-4o",
  input: userQuery,
  tools: await toolRag.listTools(userQuery),
});

// Execute the function calls from the LLM response
for (const call of response.output.filter(
  (item) => item.type === "function_call"
)) {
  const result = await toolRag.callTool(call.name, JSON.parse(call.arguments));
  console.log(result);
}

🏗️ Architecture

ToolRAG uses a Retrieval-Augmented Generation (RAG) approach optimized for tools:

  1. Storage: LibSQL database to store tool definitions and their vector embeddings
  2. Retrieval: Cosine similarity search to find the most relevant tools
  3. Execution: Direct integration with MCP servers for tool execution

👨‍💻 Use Cases

  • Multi-tool AI Assistants: Build assistants that can access hundreds of APIs
  • Enterprise Systems: Connect to internal tools and services without context limits
  • AI Platforms: Provide a unified interface for tool discovery and execution

🔧 Configuration Options

ToolRAG offers flexible configuration options:

  • Multiple embedding providers (OpenAI, Google)
  • Customizable relevance thresholds
  • Database configuration for persistence

📝 License

Apache License 2.0