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

@reaatech/llm-router-mcp

v1.0.0

Published

MCP server integration for llm-router

Readme

@reaatech/llm-router-mcp

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

MCP server integration for llm-router. Exposes three MCP tools — route_request, get_model_info, and get_cost_report — enabling AI agents and orchestration frameworks to route LLM requests through the router via the Model Context Protocol.

Installation

npm install @reaatech/llm-router-mcp @modelcontextprotocol/sdk
# or
pnpm add @reaatech/llm-router-mcp @modelcontextprotocol/sdk

Feature Overview

  • Three MCP tools — route LLM requests, query model metadata, and generate cost reports
  • Dual transports — stdio for desktop clients (Claude Desktop, VS Code) and Streamable HTTP for remote agents
  • Pluggable router interfaceRouterInterface decouples the server from the router implementation
  • Zero additional MCP tooling — all tool schemas and handlers are self-contained
  • Auto-startserver.start() detects the transport environment and activates the right transport

Quick Start

import { createMCPServer } from "@reaatech/llm-router-mcp";
import type { RouterInterface } from "@reaatech/llm-router-mcp";

// Implement the router interface
const router: RouterInterface = {
  async route(request) {
    const result = await myLLMRouter.route(request);
    return {
      model: result.model,
      strategy: result.strategy,
      cost: result.cost,
      confidence: result.confidence,
      latencyMs: result.latencyMs,
      result: result.result,
    };
  },
  getModels() {
    return myLLMRouter.getModels();
  },
  getBudget(budgetId) {
    return myLLMRouter.getBudget(budgetId);
  },
};

// Create and start the MCP server
const server = createMCPServer({ name: "llm-router", version: "1.0.0" });
server.setRouter(router);
await server.start();

Claude Desktop Configuration

{
  "mcpServers": {
    "llm-router": {
      "command": "npx",
      "args": ["@reaatech/llm-router-mcp"]
    }
  }
}

API Reference

createMCPServer(config?): MCPServer

Factory function for creating an MCP server instance.

MCPServerConfig

| Field | Type | Default | Description | |-------|------|---------|-------------| | name | string | "llm-router" | Server name reported to MCP clients | | version | string | "1.0.0" | Server version | | description | string | — | Optional human-readable description |

MCPServer (class)

Methods

| Method | Returns | Description | |--------|---------|-------------| | setRouter(router) | void | Attach the router implementation that tools delegate to | | start() | Promise<void> | Starts the server, auto-detecting stdio vs HTTP transport | | stop() | Promise<void> | Gracefully shuts down the server | | getTools() | Tool[] | Returns the registered MCP tool schemas |

RouterInterface

Your router must implement this contract for the MCP tools to function:

interface RouterInterface {
  route(request: RoutingRequest): Promise<RouterRouteSummary>;
  getModels(): ModelDefinition[];
  getBudget(budgetId?: string): BudgetInfo | null;
}

| Method | Description | |--------|-------------| | route(request) | Route a single LLM request through the router | | getModels() | Return all registered model definitions | | getBudget(budgetId?) | Return a budget's current state (daily limit, remaining, spent today) |

MCP Tools

route_request

Routes a prompt through the LLM router and returns the routing decision, selected model, execution result, cost, and latency.

Input parameters:

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | prompt | string | Yes | The text to route through an LLM | | strategy | string | No | Strategy to use (cost-optimized, latency-optimized, judgment-based, capability-based) | | maxTokens | number | No | Maximum output tokens | | requiredCapabilities | string[] | No | Required model capabilities (code, reasoning, etc.) | | budgetId | string | No | Budget to count this request against | | confidenceThreshold | number | No | Minimum confidence for strategy acceptance |

get_model_info

Returns detailed information about a specific model: capabilities, pricing, max tokens, and provider.

Input parameters:

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | modelId | string | Yes | The model ID to look up |

get_cost_report

Generates a cost report for a budget within a time period.

Input parameters:

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | budgetId | string | Yes | Budget to report on | | period | string | No | Time period: today, week, or month (default: today) |

Transport Selection

The server auto-detects its transport at startup:

| Condition | Transport | Client Examples | |-----------|-----------|-----------------| | stdin is not a TTY | StdioServerTransport | Claude Desktop, VS Code Copilot | | PORT env var is set | StreamableHTTPServerTransport | Remote agents, web-based MCP clients | | Neither | StdioServerTransport (default) | — |

Integration with the Engine

import { LLMRouter, loadRouterConfig } from "@reaatech/llm-router-engine";
import { createMCPServer } from "@reaatech/llm-router-mcp";

const router = LLMRouter.fromConfig(loadRouterConfig("llm-router.config.yaml"));

const server = createMCPServer({ name: "llm-router", version: "1.0.0" });

server.setRouter({
  async route(request) {
    const result = await router.route(request);
    return { model: result.model, strategy: result.strategy, cost: result.cost, confidence: result.confidence, latencyMs: result.latencyMs, result: result.result };
  },
  getModels: () => router.getModels(),
  getBudget: (id) => router.getBudget(id),
});

await server.start();

Related Packages

License

MIT