MUI Router

Model Context Protocol

MCP 接入指南

MUI Router 提供 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 server。
{
  "mcpServers": {
    "muirouter": {
      "url": "https://api.muirouter.com/mcp",
      "headers": {
        "Authorization": "Bearer sk-gw-xxxxxxxx"
      }
    }
  }
}

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

3. 在 Cursor / Claude Desktop 中接入
同样填入上面的 URL 与 Authorization header 即可。

Cursor:Settings → MCP → Add new server, 选择 streamable-http 类型,URL 填 https://api.muirouter.com/mcp, 自定义 header 加 Authorization: Bearer sk-gw-...

Claude Desktop:编辑配置文件 (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json),与上面 Claude Code 配置一致。

4. 可用工具
共 6 个工具,覆盖账户查询、计价、图像生成、充值。
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

列出 MUI Router 当前支持的所有模型及其计价(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

通过 MUI Router 调用 OpenAI 兼容的图像生成接口(会消耗钱包余额)。

{ "name": "image_generation", "arguments": { "model": "gpt-image-2", "prompt": "a cute cat" } }
5. 直接 JSON-RPC 调用
不通过 MCP 客户端,也可以用 curl 直接调。
# 列出工具
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"}'

# 调用 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 一致。