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

model-router-mcp

v1.0.0

Published

MCP服务器,根据模式自动选择和调用不同的大语言模型

Readme

Model Router MCP

一个智能的 Model Context Protocol (MCP) 服务器,根据不同的工作模式自动选择和调用最合适的大语言模型。

🌟 特性

  • 智能路由: 根据工作模式自动选择最佳模型
  • 多模型支持: Claude Sonnet、MiniMax M2、Grok Fast
  • 完整测试: 内置连接测试和批量测试工具
  • 易于使用: 简单的 MCP 工具接口
  • 配置灵活: 支持环境变量配置
  • 一键启动: 支持通过 npx 直接启动

🎯 支持的工作模式

主脑模式 (Brain Modes)

适用于复杂的架构设计和规划

  • sparc - 架构规划
  • architect - 架构设计
  • spec-pseudocode - 规范和伪代码
  • tutorial - 教程编写

使用模型: Claude Sonnet (Requesty)

中脑模式 (Brain Core Modes)

适用于代码开发和集成

  • code - 代码编写
  • tdd - 测试驱动开发
  • integration - 系统集成
  • devops - DevOps 操作

使用模型: MiniMax M2 (Roo Cloud)

短任务模式 (Short Task Modes)

适用于快速调试和简单编辑

  • debug - 调试分析
  • docs-writer - 文档编写
  • simple-edit - 简单编辑

使用模型: Grok Fast (Roo Cloud)

🚀 快速开始

通过 npx 直接启动 (推荐)

# 直接使用 npx 启动,无需本地安装
npx model-router-mcp

本地安装

1. 安装依赖

npm install

2. 配置环境变量

复制 .env 示例文件并填入真实的 API 配置:

cp .env .env.local

编辑 .env.local 文件,填入以下配置:

# Claude Sonnet (Requesty)
REQUESTY_API_KEY=your_requesty_api_key_here
REQUESTY_BASE_URL=https://api.requesty.com

# Roo Cloud (MiniMax M2 & Grok Fast)
ROO_API_KEY=your_roo_cloud_api_key_here  
ROO_BASE_URL=https://api.roo.claude.com

3. 启动服务器

# 本地安装后启动
npm start
# 或
node index.js

🔗 MCP 客户端配置

在 MCP 客户端中添加配置

在你的 MCP 客户端配置文件中添加以下配置:

{
  "model-router": {
    "command": "npx",
    "args": ["-y", "model-router-mcp@latest"],
    "env": {}
  }
}

环境变量配置

如果需要配置 API 密钥,可以在客户端配置中设置:

{
  "model-router": {
    "command": "npx",
    "args": ["-y", "model-router-mcp@latest"],
    "env": {
      "REQUESTY_API_KEY": "your_requesty_api_key_here",
      "ROO_API_KEY": "your_roo_cloud_api_key_here"
    }
  }
}

🛠️ 可用工具

route_model

根据模式自动选择模型

输入:

{
  "mode": "code",
  "task": "编写一个待办事项应用"
}

输出:

{
  "success": true,
  "data": {
    "mode": "code",
    "task": "编写一个待办事项应用",
    "selectedModel": "minimax-m2",
    "provider": "Roo Cloud",
    "reason": "中脑模式 code 使用 Roo Cloud"
  }
}

run_llm

调用指定模型执行任务

输入:

{
  "model": "claude-sonnet",
  "prompt": "设计一个RESTful API架构"
}

输出:

{
  "success": true,
  "data": {
    "model": "claude-sonnet",
    "provider": "Claude (Requesty)",
    "response": "...",
    "usage": {}
  }
}

get_supported_modes

获取所有支持的工作模式

test_route_model

测试特定模式的路由

batch_test_routes

批量测试多个模式

test_llm_connection

测试模型连接

batch_test_models

批量测试所有模型

get_model_info

获取模型详细信息

📁 项目结构

model-router-mcp/
├── package.json          # 项目配置
├── index.js             # MCP 服务器入口
├── config.js            # 模型配置
├── tools/               # 工具目录
│   ├── route_model.js   # 模型路由工具
│   └── run_llm.js       # LLM 调用工具
├── .env                 # 环境变量示例
├── .npmignore           # npm 发布忽略文件
└── README.md            # 项目文档

⚙️ 配置说明

模型配置

| 模式类型 | 模式 | 模型 | 提供商 | 用途 | | -------- | ------------------------------------------- | ------------- | --------- | ------------------ | | 主脑 | sparc, architect, spec-pseudocode, tutorial | Claude Sonnet | Requesty | 复杂架构设计、规划 | | 中脑 | code, tdd, integration, devops | MiniMax M2 | Roo Cloud | 代码开发、测试 | | 短任务 | debug, docs-writer, simple-edit | Grok Fast | Roo Cloud | 快速调试、文档 |

环境变量

  • REQUESTY_API_KEY: Requesty API 密钥
  • REQUESTY_BASE_URL: Requesty API 地址
  • ROO_API_KEY: Roo Cloud API 密钥
  • ROO_BASE_URL: Roo Cloud API 地址

🧪 测试

测试单个模式

// 在代码中测试
import { testRouteModel } from './tools/route_model.js';
const result = testRouteModel('code');
console.log(result);

测试单个模型

import { testLLMConnection } from './tools/run_llm.js';
const result = await testLLMConnection('claude-sonnet');
console.log(result);

批量测试

import { batchTestRoutes, batchTestAllModels } from './tools/index.js';
const routes = batchTestRoutes(['code', 'debug', 'architect']);
const models = await batchTestAllModels();

🔧 开发

本地开发

npm run dev

项目特点

  • 使用 ES Module 语法
  • 基于 @modelcontextprotocol/sdk
  • 支持stdio传输协议
  • 完整的错误处理
  • 详细的日志输出

📝 使用示例

在 MCP 客户端中使用

  1. 配置 MCP 客户端连接此服务器
  2. 调用 route_model 工具获取推荐模型
  3. 调用 run_llm 工具使用推荐模型执行任务

完整工作流程

// 1. 获取推荐模型
const routeResult = await routeModel({ mode: 'code', task: '编写React组件' });

// 2. 使用推荐模型执行任务
if (routeResult.success) {
  const llmResult = await runLLM({
    model: routeResult.data.selectedModel,
    prompt: '请编写一个React待办事项组件...'
  });
  
  console.log(llmResult);
}

📦 发布到 npm

版本管理

  1. 更新版本号:

    npm version patch    # 1.0.0 -> 1.0.1
    npm version minor    # 1.0.1 -> 1.1.0  
    npm version major    # 1.1.0 -> 2.0.0
  2. 发布到 npm:

    npm publish
  3. 使用最新版本:

    npx model-router-mcp@latest

首次发布准备

  1. 确保在 npm 注册账号
  2. 在项目目录登录 npm:
    npm login
  3. 检查包名是否可用:
    npm view model-router-mcp
  4. 运行测试确保一切正常:
    npm test
  5. 发布:
    npm publish

包内容验证

发布前可以验证哪些文件会被包含在 npm 包中:

npm pack --dry-run

🚨 注意事项

  1. API 密钥安全: 确保 .env 文件不被提交到版本控制
  2. 网络连接: 需要稳定的网络连接调用外部 API
  3. 成本控制: 注意 API 调用频率和成本
  4. 错误处理: 所有工具都有完整的错误处理机制
  5. 环境变量: 使用 npx 启动时记得在客户端配置中设置环境变量

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📄 许可证

MIT License

🔗 相关链接


Model Router MCP - 让 AI 模型选择更智能!