Skip to main content
Glama

LLM Router MCP

Route prompts intelligently across Claude, Gemini, and GPT-4o — automatically picking the best model for every task while minimising token cost.

npm TypeScript MCP Node.js License


✨ What is this?

llm-router-mcp is a Model Context Protocol (MCP) server that acts as an intelligent dispatcher for your AI workloads. Instead of hardcoding a single LLM into your workflow, the router analyses the intent of each prompt and automatically selects the most cost-effective and capable model for that specific task type.

Your prompt ──► LLM Router ──► PLANNING      → Gemini
                            ├── SCAFFOLDING  → Gemini
                            ├── CODEGEN      → Claude
                            ├── REFACTOR     → Claude
                            ├── REVIEW       → Claude
                            ├── TESTING      → GPT-4o
                            └── IMPLEMENT    → GPT-4o

Related MCP server: ypollak2/llm-router

🚀 Features

  • Smart intent-based routing — classifies prompts into 8 task categories and dispatches to the optimal model

  • Three frontier models — integrates Claude (Anthropic), Gemini (Google), and GPT-4o (OpenAI) out of the box

  • Zero-config mock mode — works out of the box with no API keys; auto-enables mock mode when keys are absent

  • Session-aware context caching — maintains conversation context across turns within the same session

  • Explicit tool shortcuts — bypass auto-routing with dedicated plan_workflow, generate_code, and implement_feature tools

  • MCP-native — drop it into any MCP-compatible host (Claude Desktop, Cursor, VS Code Continue, etc.)


📦 Quick Start

Option A — npx (no install needed)

npx llm-router-mcp

Option B — Global install

npm install -g llm-router-mcp
llm-router-mcp

Option C — From source

git clone https://github.com/Devatva24/LLM-Router-MCP.git
cd LLM-Router-MCP
npm install
npm run build
node dist/index.js

No API keys? No problem. The server automatically falls back to mock mode and logs a helpful message. You only need keys when you want real model responses.


🗺️ Routing Logic

Task Category

Trigger Keywords

Routed To

Planning

architecture, design, system design, strategy, workflow

✦ Gemini

Scaffolding

scaffold, boilerplate, setup, folder structure

✦ Gemini

Code Generation

write a function, implement, create a class, algorithm

✦ Claude

Refactor

refactor, clean up, improve, rewrite, restructure

✦ Claude

Code Review

review, debug, explain, what's wrong, critique

✦ Claude

Testing

unit tests, Jest, Vitest, test suite, test cases

✦ GPT-4o

Implementation

implement, add endpoint, build the, create the API

✦ GPT-4o

General

anything else

✦ Claude (fallback)


⚙️ Configuration

Set your API keys as environment variables to use real models:

# Mac / Linux
export ANTHROPIC_API_KEY=sk-ant-...
export GOOGLE_API_KEY=AIza...
export OPENAI_API_KEY=sk-...

# Windows (PowerShell)
$env:ANTHROPIC_API_KEY="sk-ant-..."
$env:GOOGLE_API_KEY="AIza..."
$env:OPENAI_API_KEY="sk-..."

If any keys are missing the server auto-enables mock mode — no crash, no config needed.


🖥️ Editor Integration

Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json (Mac) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

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

Cursor

Add to your Cursor MCP settings:

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

VS Code (Continue extension)

Add to ~/.continue/config.json:

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

Ready-made config files for Cursor and Continue are included in the cursor-config/ and %USERPROFILE%/.continue/ directories of this repo.


🧰 Available MCP Tools

route_prompt

Automatically classifies and routes a prompt to the best model.

{
  "prompt": "Write a recursive function to flatten deeply nested objects",
  "session_id": "my-session"
}

plan_workflow

Explicitly routes to Gemini for high-level planning and architecture tasks.

{
  "prompt": "Design a checkout flow for an e-commerce app",
  "session_id": "my-session"
}

generate_code

Explicitly routes to Claude for complex logic, algorithms, and refactoring.

{
  "prompt": "Write a binary search tree with insert and delete",
  "session_id": "my-session"
}

implement_feature

Explicitly routes to GPT-4o for feature implementation and test generation.

{
  "prompt": "Implement the /api/products CRUD endpoints",
  "session_id": "my-session"
}

clear_context

Clears the cached conversation context for a given session.

{
  "session_id": "my-session"
}

🧪 Running Tests

The test suite validates all routing decisions in mock mode — no API keys needed:

npm test

Expected output:

🧪 LLM Router — mock test suite

  ✅ planning → Gemini
  ✅ codegen → Claude
  ✅ testing → GPT-4o
  ✅ review → Claude
  ✅ explicit plan_workflow
  ✅ explicit implement_feature
  ✅ context cache — 2nd turn
  ✅ clear_context

──────────────────────────────────────────
  8 passed  0 failed (8 total)

📁 Project Structure

LLM-Router-MCP/
├── src/
│   ├── index.ts          # MCP server entrypoint & routing logic
│   ├── classifier.ts     # Prompt intent classifier
│   ├── context-cache.ts  # Session-aware context management
│   ├── mock.ts           # Mock responses for zero-cost testing
│   └── logger.ts         # Lightweight logger
├── dist/                 # Compiled JavaScript (after npm run build)
├── cursor-config/        # Ready-made Cursor MCP config
├── test-router.cjs       # End-to-end test suite (mock mode)
├── tsconfig.json
└── package.json

🤝 Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request for:

  • Adding support for additional LLM providers

  • Improving routing classification accuracy

  • Adding streaming response support

  • Writing more test coverage


📄 License

MIT — see LICENSE for details.

Available Tools

5 tools
clear_contextB

Clears the context cache for a session, starting fresh.

ParametersJSON Schema
NameRequiredDescriptionDefault
session_idNo

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the context cache is cleared but does not state whether the operation is irreversible, what exactly is removed, whether it affects other sessions, or what the outcome is. The tool is a mutation, and these details are important for an agent to anticipate side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no unnecessary words. It communicates the core action and scope immediately, making it easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple—one optional parameter and no output schema—but the description omits behavioral details like side effects and return behavior. Given its simplicity, the description is minimally viable but leaves room for more context, such as what 'starting fresh' entails and what the agent should expect afterward.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has one parameter, session_id, with no description and 0% schema description coverage. The description mentions 'session' but does not explicitly link it to session_id, nor does it explain the expected format, optionality, or behavior when omitted. More parameter detail was needed in the description to compensate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Clears the context cache') and the scope ('for a session'), with a helpful qualifier ('starting fresh'). It is easily distinguished from sibling tools that route, plan, generate, or implement, as it is a utility to reset state.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'starting fresh' implies a usage scenario, but there is no explicit guidance on when to use this tool versus alternatives, nor any exclusions. The context is simple enough that no alternatives conflict, but the description does not proactively explain when clearing context is appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

generate_codeB

Always uses Claude for complex code generation, logic-heavy tasks, or refactoring.

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYes
session_idNo

TDQS

B3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description must carry the behavioral disclosure burden. It reveals that the tool 'always uses Claude', which is a useful behavioral trait, but it says nothing about side effects, output format, error conditions, or required permissions. This is insufficient for a code generation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence with no fluff. It clearly communicates the core context, though the phrase 'Always uses Claude' is placed first, which is a minor structural inefficiency but not a significant issue.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given there is no output schema, no annotations, and only two parameters with zero schema descriptions, the tool is relatively simple. However, the description fails to explain return values, usage caveats, or how it relates to the sibling 'implement_feature'. The provided context is minimal and leaves key gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, and the description does not compensate. It makes no mention of the 'prompt' or 'session_id' parameters, leaving their meaning and usage entirely to the schema. The description adds no value for understanding the parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool is for 'complex code generation, logic-heavy tasks, or refactoring', giving a clear sense of what it does. While the verb 'uses Claude' is indirect, the resource and tasks are clear enough. It does not explicitly distinguish from sibling 'implement_feature', but the scope is reasonably defined.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use the tool: 'complex code generation, logic-heavy tasks, or refactoring'. However, it does not mention when to avoid this tool or name alternatives, so it falls short of explicit when/when-not guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

implement_featureC

Always uses GPT-4o for feature implementation, test generation, or repetitive coding tasks.

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYes
session_idNo

TDQS

C2.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It discloses that GPT-4o is always used, but omits important behavioral details such as whether the tool modifies the codebase, requires specific permissions, or has side effects. The mention of 'repetitive coding tasks' hints at scope but is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence with no wasted words. It front-loads the key information about the tool's function (using GPT-4o for coding tasks), though it sacrifices necessary detail for brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's two parameters, no output schema, and sibling tools, the description is inadequate. It fails to explain the input prompt's structure, the tool's role relative to 'generate_code', or any expected outcomes, leaving the agent without sufficient context to invoke it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for the two parameters 'prompt' and 'session_id'. It implies that 'prompt' is the task description, but provides no explicit explanation of the parameters or their formats. This minimal compensation leaves significant semantic gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool uses GPT-4o for feature implementation, test generation, or repetitive coding tasks, providing a specific function. However, it does not differentiate from the sibling tool 'generate_code', which likely overlaps in purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is given on when to use this tool versus alternatives like 'generate_code' or 'plan_workflow'. The description only mentions the model used and task types, without context for selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

plan_workflowC

Always uses Gemini to plan a high-level workflow or architecture for a feature.

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYes
session_idNo

TDQS

C2.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose behavioral traits, but it only mentions 'Always uses Gemini'. It does not explain what happens to the prompt, whether context is updated, return format, or any side effects, which is insufficient for a planning tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence. However, 'Always uses Gemini' is a minor filler that does not aid purpose clarity, preventing a perfect score.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite having only 2 parameters and no output schema, the description omits critical context: what the plan looks like, how session_id affects behavior, and how this tool relates to siblings like generate_code or implement_feature. The agent is left without enough guidance for correct use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% for both parameters. The description vaguely implies the 'prompt' describes a feature, but gives no detail on expected content or format, and 'session_id' is entirely unexplained. The description fails to compensate for the lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'plan' and the resource 'high-level workflow or architecture for a feature', making the core purpose evident. It does not explicitly distinguish from sibling tools like generate_code or implement_feature, but the planning focus is implicitly different.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It does not mention any prerequisites, timing, or when not to use it, leaving the agent to infer from the tool name and siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

route_promptA

Routes a coding prompt to the best LLM (Claude, Gemini, GPT-4o) based on task type. Automatically classifies the task and selects the cheapest/most capable model.

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYesThe user's coding prompt or question
session_idNoOptional session ID for context continuity (default: 'default')

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It does reveal that the tool automatically classifies tasks and selects a model based on cost/capability, which is useful. However, it is ambiguous whether the tool actually executes the prompt or merely returns a model name/decision, and it does not mention output format, side effects, or whether network calls are made. This leaves key behavioral details undisclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a concise, two-sentence explanation that immediately states the tool's purpose and key behavior. It front-loads the action and avoids unnecessary words, earning its place with no wasted detail.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has moderate complexity with two parameters, no output schema, and no annotations. The description explains the core purpose and decision heuristic but does not clarify what is returned to the caller, which is a notable omission. It is adequate but incomplete for an agent that needs to understand the full contract of the tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the parameters are already fully documented in the schema. The description adds little beyond reinforcing that 'prompt' is a coding prompt; it does not explain 'session_id' or add semantic context beyond the schema. Baseline 3 is appropriate because the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb ('Routes'), a resource ('a coding prompt'), and a clear objective (to the best LLM based on task type). This clearly distinguishes it from sibling tools like generate_code or implement_feature, which perform generation or implementation rather than routing/selection.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies when to use the tool—when you need an LLM selected for a coding prompt—but it does not explicitly state when not to use it or name alternatives. Sibling tools like generate_code are distinct, but no direct comparison or exclusion is provided, leaving usage guidance somewhat implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 5 tool updatesv1.0.1
    • First observedclear_context
    • First observedgenerate_code
    • First observedimplement_feature
    • First observedplan_workflow
    • First observedroute_prompt

TDQS

B3.2/5.0
Disambiguation2/5

route_prompt overlaps heavily with plan_workflow, generate_code, and implement_feature, as those three are just specialized routing tools with predetermined models. Additionally, generate_code and implement_feature are similar enough (complex vs repetitive coding) that an agent may struggle to choose between them.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern (route_prompt, plan_workflow, clear_context, generate_code, implement_feature). The naming is predictable and clearly indicates the action and target.

Tool Count5/5

With 5 tools, the server is well-scoped for a specialized LLM routing purpose. Each tool has a distinct name and fits within the expected 3-15 range, making the tool surface easy to grasp.

Completeness4/5

The core workflow of routing, planning, generating, and implementing is covered, along with a context reset. Minor gaps exist, such as no tool to list available models or customize routing rules, but agents can work around these by using route_prompt for general tasks.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Devatva24/LLM-Router-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server