Skip to main content
Glama

๐Ÿš€ MCP Router

Intelligent Model Context Protocol Router for Cursor IDE

Automatically selects the optimal LLM model for each task based on query analysis, complexity, and your preferred strategy.

License: MIT Python 3.10+ MCP Compatible


๐Ÿ“ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ CURSOR IDE โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ User Query โ”‚ โ”‚ โ”‚ โ”‚ "Refactor this authentication system across multiple files" โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ MCP Router Server โ”‚ โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ Query Analyzer โ”‚โ”€โ”€โ”€โ–ถโ”‚ Model Scorer โ”‚โ”€โ”€โ–ถโ”‚ Routing Decision โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ€ข Task Type โ”‚ โ”‚ โ€ข Quality Score โ”‚ โ”‚ โ€ข Selected Model โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ€ข Complexity โ”‚ โ”‚ โ€ข Cost Score โ”‚ โ”‚ โ€ข Confidence โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ€ข Requirements โ”‚ โ”‚ โ€ข Speed Score โ”‚ โ”‚ โ€ข Reasoning โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ€ข Token Estimate โ”‚ โ”‚ โ€ข Strategy Weight โ”‚ โ”‚ โ€ข Alternatives โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Model Registry (17 Models) โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ FLAGSHIP โ”‚ โ”‚ REASONING โ”‚ โ”‚ NATIVE/FAST โ”‚ โ”‚ BUDGET/LEGACY โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ€ข GPT-5.2 โ”‚ โ”‚ โ€ข o3 โ”‚ โ”‚ โ€ข Composer1 โ”‚ โ”‚ โ€ข GPT-4o-mini โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ€ข Claude4.5 โ”‚ โ”‚ โ€ข o3-mini โ”‚ โ”‚ โ€ข Gemini 3 โ”‚ โ”‚ โ€ข Claude Haiku โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ Opus โ”‚ โ”‚ โ€ข Claude3.7 โ”‚ โ”‚ Pro/Flash โ”‚ โ”‚ โ€ข DeepSeek V3 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ€ข Claude4.5 โ”‚ โ”‚ Sonnet โ”‚ โ”‚ โ”‚ โ”‚ โ€ข DeepSeek R1 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ Sonnet โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Cursor Executes Query โ”‚ โ”‚ โ”‚ โ”‚ (Using its own API keys for selected model) โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Data Flow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Query โ”‚โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚ Analyze โ”‚โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚ Score โ”‚โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚ Recommend โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ–ผ โ–ผ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Task Type: โ”‚ โ”‚ Apply โ”‚ โ”‚ Model: โ”‚ โ”‚ โ€ข reasoning โ”‚ โ”‚ Strategy: โ”‚ โ”‚ Claude 4.5 โ”‚ โ”‚ โ€ข code_gen โ”‚ โ”‚ โ€ข balanced โ”‚ โ”‚ Sonnet โ”‚ โ”‚ โ€ข edit โ”‚ โ”‚ โ€ข quality โ”‚ โ”‚ โ”‚ โ”‚ Complexity: โ”‚ โ”‚ โ€ข speed โ”‚ โ”‚ Confidence: โ”‚ โ”‚ โ€ข medium โ”‚ โ”‚ โ€ข cost โ”‚ โ”‚ 88.45% โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœจ Features

Feature

Description

๐Ÿค– Intelligent Routing

Automatically selects the best model based on query analysis

๐Ÿง  Context-Aware Routing

Uses chat history and conversation context for smarter model selection

๐Ÿ“Š 4 Routing Strategies

balanced / cost / speed / quality

๐Ÿ” Query Analysis

Detects task type, complexity, and special requirements

๐Ÿ’ฌ Chat History Analysis

Analyzes conversation patterns, topics, files, languages, and complexity

๐Ÿ’ฐ Cost Estimation

Estimates costs before execution

โšก 17 Models

Latest 2025 models from OpenAI, Anthropic, Google, Cursor, DeepSeek

๐Ÿ”ง Cursor Native

Zero API keys needed - Cursor handles execution


๐Ÿ† Supported Models (2025)

Tier 1: Flagship Models (Complex Architecture & Refactoring)

Model

Provider

Context

Cost (in/out)

Quality

GPT-5.2

OpenAI

256K

$5.00/$15.00

0.99/0.98

Claude 4.5 Opus

Anthropic

200K

$25.00/$75.00

0.99/0.99

Claude 4.5 Sonnet

Anthropic

200K

$5.00/$25.00

0.97/0.98

Tier 2: Reasoning Models (Chain of Thought)

Model

Provider

Context

Cost (in/out)

Quality

o3

OpenAI

200K

$10.00/$40.00

0.99/0.95

o3-mini (High)

OpenAI

128K

$1.50/$6.00

0.95/0.92

Claude 3.7 Sonnet

Anthropic

200K

$4.00/$20.00

0.96/0.96

Tier 3: Native & Fast Models

Model

Provider

Context

Cost (in/out)

Quality

Composer 1

Cursor

128K

$0.10/$0.30

0.88/0.92

Gemini 3 Pro

Google

2M

$2.00/$8.00

0.96/0.94

Gemini 3 Flash

Google

1M

$0.10/$0.40

0.88/0.90

Tier 4: Budget/Legacy Models

Model

Provider

Context

Quality

GPT-4o / GPT-4o-mini

OpenAI

128K

0.95/0.85

Claude 3.5 Sonnet/Haiku

Anthropic

200K

0.96/0.88

Gemini 2.0 Pro/Flash

Google

2M/1M

0.94/0.85

DeepSeek V3

DeepSeek

128K

0.92/0.94

DeepSeek R1

DeepSeek

128K

0.96/0.92


๐Ÿš€ Quick Start

1. Install

git clone https://github.com/AI-Castle-Labs/mcp-router.git cd mcp-router pip install -r requirements.txt pip install mcp # MCP SDK for Cursor integration

2. Configure Cursor

Add to ~/.cursor/mcp.json:

{ "version": "1.0", "mcpServers": { "mcp-router": { "command": "python3", "args": ["/path/to/mcp-router/src/mcp_server.py"], "env": {} } } }

Note: No API keys needed! Cursor handles all API calls with its own keys.

3. Restart Cursor

The MCP router will appear in your agent tools. Use it with:

  • @mcp-router get_model_recommendation "your task description"

  • @mcp-router analyze_query "your query"

  • @mcp-router list_models


๐Ÿ’ป CLI Usage

# Route a query (shows which model would be selected) python main.py route "Explain how neural networks work" # Route with strategy python main.py route "Refactor this codebase" --strategy quality # List all registered models python main.py list # Show routing statistics python main.py stats

Example Output

============================================================ Routing Decision ============================================================ Query: Refactor this complex authentication system... Selected Model: Claude 4.5 Sonnet Model ID: claude-4.5-sonnet Provider: anthropic Confidence: 88.45% Reasoning: Model is optimized for code_edit tasks; Selected for highest quality Alternatives: - Composer 1 (composer-1) - Claude 3.5 Haiku (claude-3-5-haiku-20241022) - GPT-4o-mini (gpt-4o-mini)

๐ŸŽฏ Routing Strategies

Strategy

Description

Best For

balanced

Optimizes for cost, speed, and quality equally

General use

quality

Prioritizes highest capability models

Complex tasks, refactoring

speed

Prioritizes fastest response time

Quick edits, simple tasks

cost

Prioritizes cheapest models

Budget-conscious usage


๐Ÿ Python API

from src.router import MCPRouter # Initialize router (loads 17 default models) router = MCPRouter() # Route a query decision = router.route( "Analyze this codebase architecture", strategy="quality" ) print(f"Selected: {decision.selected_model.name}") print(f"Model ID: {decision.selected_model.model_id}") print(f"Confidence: {decision.confidence:.1%}") print(f"Reasoning: {decision.reasoning}") # Get alternatives for alt in decision.alternatives[:3]: print(f" Alternative: {alt.name}")

๐Ÿ“ Project Structure

mcp-router/ โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ router.py # Core routing logic + 17 model definitions โ”‚ โ”œโ”€โ”€ mcp_server.py # MCP server for Cursor integration โ”‚ โ”œโ”€โ”€ client.py # API client for model execution โ”‚ โ””โ”€โ”€ cursor_wrapper.py # Cursor-specific utilities โ”œโ”€โ”€ config/ โ”‚ โ””โ”€โ”€ cursor_mcp_config.json # Template for Cursor config โ”œโ”€โ”€ scripts/ โ”‚ โ””โ”€โ”€ setup_cursor.sh # Automated setup script โ”œโ”€โ”€ docs/ โ”‚ โ”œโ”€โ”€ cursor_integration.md โ”‚ โ”œโ”€โ”€ QUICKSTART_CURSOR.md โ”‚ โ””โ”€โ”€ AGENT_SETTINGS.md โ”œโ”€โ”€ main.py # CLI entry point โ”œโ”€โ”€ requirements.txt โ””โ”€โ”€ README.md

๐Ÿ”ง Adding Custom Models

from src.router import MCPRouter, ModelCapabilities, TaskType router = MCPRouter() router.register_model(ModelCapabilities( name="My Custom Model", provider="custom", model_id="custom-model-v1", supports_reasoning=True, supports_code=True, supports_streaming=True, max_tokens=8192, context_window=32000, cost_per_1k_tokens_input=1.0, cost_per_1k_tokens_output=2.0, avg_latency_ms=600, reasoning_quality=0.85, code_quality=0.90, speed_score=0.80, preferred_tasks=[TaskType.CODE_GENERATION], api_key_env_var="CUSTOM_API_KEY" ))

๐ŸŽฎ Cursor Commands

Create .cursor/commands/route.md:

--- description: "Get model recommendation from MCP router for the current task" --- Use the MCP router to determine the best model for the task at hand. 1. Analyze the current context 2. Call `@mcp-router get_model_recommendation` with task description 3. Present the recommendation with confidence and alternatives 4. Suggest switching models if needed

๐Ÿ“Š MCP Tools Available

Tool

Description

route_query

Route a query and get model recommendation (supports chat_history)

get_model_recommendation

Get recommendation without execution (supports chat_history)

analyze_chat_summary

Analyze chat history text to extract routing signals

list_models

List all 17 registered models

get_routing_stats

Get usage statistics

analyze_query

Analyze query characteristics

Context-Aware Routing with Chat History

The router can now analyze chat history to make smarter routing decisions:

// Example: Using chat history for context-aware routing { "query": "Fix the authentication bug we discussed", "strategy": "quality", "chat_history": [ { "role": "user", "content": "I'm working on auth.py and users can't log in", "timestamp": 1704067200 }, { "role": "assistant", "content": "Let me check the authentication flow...", "timestamp": 1704067205 } ] }

The router analyzes chat history to detect:

  • Context depth: Shallow/medium/deep based on token count

  • Dominant task type: Code generation, editing, debugging, etc.

  • Programming languages: Detects Python, JavaScript, Rust, etc.

  • Files mentioned: Tracks files being worked on

  • Error patterns: Identifies debugging sessions

  • Topics: Authentication, database, API, testing, etc.

  • Complexity: Based on files, languages, and conversation depth

These signals influence model selection:

  • Deep context โ†’ Models with larger context windows

  • Debugging sessions โ†’ High-reasoning models

  • Multi-file tasks โ†’ Code-focused models

  • Multiple languages โ†’ Polyglot-capable models


๐Ÿค Contributing

  1. Fork the repository

  2. Create a feature branch

  3. Make your changes

  4. Submit a pull request


๐Ÿ“„ License

MIT License - see LICENSE for details.


-
security - not tested
F
license - not found
-
quality - not tested

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/AI-Castle-Labs/mcp-router'

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