MuiRouter

Model Context Protocol

MCP 接入指南

MuiRouter 运行一个 streamable-http 的 MCP 服务器,Claude Desktop、Claude Code、Cursor、Cline 等 AI 客户端可以直接调用——你的 AI 助手能查询余额、查看用量、列出模型、生成图片,甚至发起充值。所有调用都用你自己的 sk-gw- API Key 鉴权,第三方和 AI 客户端都无需新建账户。

1. 服务器端点
所有 MCP 客户端都连接同一个 URL,使用 Bearer 鉴权。
Endpoint
POST https://api.muirouter.com/mcp
Header
Authorization: Bearer sk-gw-xxxxxxxx

协议版本:MCP 2025-06-18,传输方式:streamable-http,无状态 JSON-RPC 2.0。

2. 在 Claude Code 中接入
编辑 ~/.claude/mcp.json,添加 muirouter 服务器。
{
  "mcpServers": {
    "muirouter": {
      "url": "https://api.muirouter.com/mcp",
      "headers": {
        "Authorization": "Bearer sk-gw-xxxxxxxx"
      }
    }
  }
}

重启 Claude Code 后,输入 /mcp 即可看到 muirouter 的工具列表。

3. 在 Cursor / Claude Desktop 中接入
填入相同的 URL 和 Authorization 请求头。

Cursor:Settings → MCP → Add new server,选择 streamable-http 类型,将 URL 设为 https://api.muirouter.com/mcp,并添加自定义请求头 Authorization: Bearer sk-gw-...。

Claude Desktop:编辑配置文件(macOS:~/Library/Application Support/Claude/claude_desktop_config.json),使用与上面 Claude Code 相同的配置。

4. 可用工具
六个工具,涵盖账户查询、定价、图片生成和充值。
get_balance

查询当前 API Key 所属用户的钱包余额、累计充值和累计消费。

{ "name": "get_balance", "arguments": {} }
get_usage

分页查询当前用户的 API 用量,可按模型和时间范围筛选。

{ "name": "get_usage", "arguments": { "limit": 20, "model": "gpt-4o" } }
list_recharges

分页查询当前用户的充值记录。

{ "name": "list_recharges", "arguments": { "limit": 20 } }
list_models

列出 MuiRouter 当前支持的所有模型及其定价(input/output、markup_rate)。

{ "name": "list_models", "arguments": {} }
create_topup_session

创建 Stripe 充值会话,返回支付链接,AI 客户端可引导用户完成支付。

{ "name": "create_topup_session", "arguments": { "amount_cents": 1000, "currency": "usd" } }
image_generation

通过 MuiRouter 调用 OpenAI 兼容的图片生成接口(消耗钱包余额)。

{ "name": "image_generation", "arguments": { "model": "gpt-image-2", "prompt": "a cute cat" } }
5. 直接调用 JSON-RPC
你也可以用 curl 直接调用,无需 MCP 客户端。
# List tools
curl -X POST https://api.muirouter.com/mcp \
  -H "Authorization: Bearer sk-gw-xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

# Call get_balance
curl -X POST https://api.muirouter.com/mcp \
  -H "Authorization: Bearer sk-gw-xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc":"2.0",
    "id":2,
    "method":"tools/call",
    "params": {"name":"get_balance","arguments":{}}
  }'
6. 安全须知

API Key 等同于密码——切勿在公开仓库或聊天记录中泄露。一旦怀疑泄露,请立即在 Keys 页面吊销。

image_generation 和 create_topup_session 会花费或转移资金。建议在 AI 客户端中将这两个工具设为需要确认。

每个请求都绑定到其 sk-gw- Key 背后的账户,并发与计费规则与直接调用 REST API 完全一致。

相关页面