Multi-Model Orchestrator

Multi-Model Orchestrator

Automatically routes queries to the most suitable AI model based on task type, cost constraints, and performance needs, supporting multiple providers and customizable priorities.

Category
访问服务器

README

Multi-Model Orchestrator MCP Server

An intelligent Model Context Protocol (MCP) server that automatically routes queries to the most suitable AI model based on task requirements, cost constraints, and performance characteristics.

Features

  • Intelligent Routing: Automatically analyzes queries to determine task type (coding, analysis, creative writing, etc.)
  • Cost Optimization: Recommends models based on budget constraints and cost-per-token
  • Performance Tiers: Supports premium, standard, fast, and budget model tiers
  • Multi-Provider: Includes models from OpenAI, Anthropic, Google, and open-source options
  • Flexible Priorities: Optimize for cost, performance, speed, or balanced approach
  • Model Comparison: Side-by-side comparison of different models
  • Cost Estimation: Calculate estimated costs before running queries

Supported Models

Latest Generation Models (2024-2025)

Model Provider Tier Cost/1K Tokens Strengths Vision Functions
GPT-5 OpenAI Premium $0.050 Reasoning, coding, analysis, math, creative
Claude Opus 4.1 Anthropic Premium $0.015 Reasoning, analysis, creative, coding, math
Claude Sonnet 4.5 Anthropic Premium $0.003 Coding, reasoning, analysis, creative, chat
Gemini 2.5 Pro Google Premium $0.00375 Reasoning, coding, analysis, math, creative

Previous Generation Models

Model Provider Tier Cost/1K Tokens Strengths Vision Functions
GPT-4 OpenAI Premium $0.030 Reasoning, coding, analysis, math
GPT-3.5 Turbo OpenAI Fast $0.002 Chat, summarization, translation
Claude 3 Opus Anthropic Premium $0.015 Reasoning, analysis, creative, coding
Claude 3 Sonnet Anthropic Standard $0.003 Coding, analysis, chat
Claude 3 Haiku Anthropic Fast $0.00025 Chat, summarization, fast responses
Gemini Pro Google Standard $0.00125 Reasoning, coding, analysis
Llama 2 70B Meta Budget $0.0008 Chat, coding, summarization

Installation

  1. Install dependencies:
pip install -r requirements.txt
  1. Make the script executable:
chmod +x multi_model_orchestrator.py

Configuration

Claude Desktop Configuration

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "multi-model-orchestrator": {
      "command": "python",
      "args": [
        "/path/to/multi_model_orchestrator.py"
      ]
    }
  }
}

VS Code Configuration

Add to your MCP settings:

{
  "mcp.servers": {
    "multi-model-orchestrator": {
      "command": "python",
      "args": ["/path/to/multi_model_orchestrator.py"]
    }
  }
}

Available Tools

1. recommend_model

Get AI model recommendations based on your query and requirements.

Parameters:

  • query (required): The user query or task description
  • priority (optional): What to optimize for - "balanced", "cost", "performance", or "speed" (default: "balanced")
  • max_cost_per_1k (optional): Maximum acceptable cost per 1k tokens

Example:

{
  "query": "Write a complex Python function to optimize database queries",
  "priority": "performance"
}

Response:

{
  "analysis": {
    "task_type": "coding",
    "estimated_tokens": 150,
    "complexity": "high",
    "requires_vision": false,
    "requires_function_calling": false
  },
  "recommendation": {
    "recommended_model": "claude-3-opus",
    "provider": "Anthropic",
    "tier": "premium",
    "estimated_cost_per_1k": 0.015,
    "strengths": ["reasoning", "analysis", "creative", "coding"],
    "reason": "optimized for coding, premium tier performance",
    "alternatives": [...]
  }
}

2. compare_models

Compare multiple AI models side by side.

Parameters:

  • models (required): Array of model names to compare

Example:

{
  "models": ["gpt-4", "claude-3-opus", "claude-3-sonnet"]
}

3. analyze_task

Analyze a query without making a recommendation.

Parameters:

  • query (required): The query to analyze

Example:

{
  "query": "Translate this document from English to Spanish"
}

4. list_models_by_criteria

Filter models by specific criteria.

Parameters:

  • task_type (optional): Filter by task type
  • tier (optional): Filter by performance tier
  • max_cost (optional): Maximum cost per 1k tokens
  • requires_vision (optional): Requires vision capabilities

Example:

{
  "task_type": "coding",
  "max_cost": 0.01,
  "tier": "standard"
}

5. estimate_cost

Calculate the estimated cost for running a query.

Parameters:

  • model (required): Model name
  • input_tokens (required): Estimated input tokens
  • output_tokens (required): Estimated output tokens

Example:

{
  "model": "claude-3-sonnet",
  "input_tokens": 500,
  "output_tokens": 1000
}

Usage Examples

Example 1: Cost-Optimized Query

# Query: "Summarize this article in 3 bullet points"
# Priority: cost
# Result: claude-3-haiku (lowest cost, optimized for summarization)

Example 2: Performance-Optimized Complex Task

# Query: "Analyze this codebase and suggest architectural improvements"
# Priority: performance
# Result: gpt-4 or claude-3-opus (premium tier, strong reasoning)

Example 3: Speed-Optimized Simple Chat

# Query: "What's the weather like?"
# Priority: speed
# Result: gpt-3.5-turbo or claude-3-haiku (fast response)

Example 4: Budget Constraint

# Query: "Write a blog post about AI"
# Priority: balanced
# max_cost_per_1k: 0.005
# Result: claude-3-sonnet or gemini-pro (within budget, good quality)

Task Type Detection

The orchestrator automatically detects task types:

  • Coding: Keywords like "code", "function", "debug", "programming"
  • Analysis: Keywords like "analyze", "compare", "evaluate"
  • Creative: Keywords like "write", "story", "poem", "creative"
  • Math: Keywords like "calculate", "math", "solve"
  • Translation: Keywords like "translate", "translation"
  • Summarization: Keywords like "summarize", "summary", "brief"
  • Reasoning: Keywords like "reasoning", "logic", "explain why"
  • Chat: Default for general conversation

Resources

The server provides two resources:

  1. models://catalog - Complete model catalog with capabilities
  2. models://routing-rules - Current routing rules and logic

Customization

Adding New Models

Edit the MODELS dictionary in multi_model_orchestrator.py:

MODELS = {
    "your-model-name": ModelInfo(
        name="your-model-name",
        provider="YourProvider",
        tier=ModelTier.STANDARD,
        cost_per_1k_tokens=0.005,
        strengths=["coding", "analysis"],
        max_tokens=8192,
        supports_vision=False,
        supports_function_calling=True
    )
}

Adjusting Routing Logic

Modify the recommend_model() method to adjust scoring:

# Increase weight for task type matching
if task_type.value in model_info.strengths:
    score += 50  # Adjust this value

Architecture

┌─────────────────────────────────────────────────┐
│           MCP Client (Claude Desktop)           │
└────────────────────┬────────────────────────────┘
                     │
                     │ MCP Protocol
                     │
┌────────────────────▼────────────────────────────┐
│         Multi-Model Orchestrator Server         │
│                                                  │
│  ┌────────────────────────────────────────┐    │
│  │       Query Analysis Engine             │    │
│  │  - Task type detection                  │    │
│  │  - Complexity assessment                │    │
│  │  - Requirement extraction               │    │
│  └────────────────────────────────────────┘    │
│                                                  │
│  ┌────────────────────────────────────────┐    │
│  │       Model Recommendation Engine       │    │
│  │  - Score-based selection                │    │
│  │  - Cost optimization                    │    │
│  │  - Performance matching                 │    │
│  └────────────────────────────────────────┘    │
│                                                  │
│  ┌────────────────────────────────────────┐    │
│  │          Model Database                 │    │
│  │  - Capabilities                         │    │
│  │  - Costs                                │    │
│  │  - Performance tiers                    │    │
│  └────────────────────────────────────────┘    │
└─────────────────────────────────────────────────┘

Future Enhancements

  • [ ] Real-time cost tracking
  • [ ] Usage analytics and reporting
  • [ ] A/B testing between models
  • [ ] Custom routing rules via configuration
  • [ ] Integration with actual API providers
  • [ ] Model performance benchmarking
  • [ ] Historical query analysis
  • [ ] Rate limiting support
  • [ ] Multi-model ensemble responses

Testing

Test the server manually:

# Run the server
python multi_model_orchestrator.py

# In another terminal, test with MCP Inspector
npx @modelcontextprotocol/inspector python multi_model_orchestrator.py

Troubleshooting

Server won't start

  • Ensure Python 3.10+ is installed
  • Check that all dependencies are installed: pip install -r requirements.txt
  • Verify the script path in your configuration

No models recommended

  • Check that your query is being analyzed correctly
  • Try different priority modes
  • Verify max_cost constraints aren't too restrictive

Tool calls failing

  • Ensure proper JSON format for parameters
  • Check the MCP client logs for detailed error messages

Contributing

To extend this MCP server:

  1. Add new models to the MODELS dictionary
  2. Enhance task type detection in analyze_query()
  3. Adjust scoring logic in recommend_model()
  4. Add new tools to handle additional use cases

License

MIT License - Feel free to use and modify for your needs.

Author

Created as a demonstration of MCP server capabilities for intelligent model routing.


Note: This is a routing and recommendation tool. It does not actually call the AI model APIs. You would need to integrate with the respective provider SDKs to execute queries on the recommended models.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选