Skip to content

MCP 配置

JarvisClaw 暴露了一个 MCP(Model Context Protocol)服务器。可从 Claude Code、Cursor、Windsurf 或任何 MCP 客户端连接,将 AI 模型作为工具使用。

认证

方式请求头使用场景
API KeyAuthorization: Bearer sk-...预付费账户
x402 USDCPAYMENT-SIGNATURE: ...无需账户,钱包直接支付

发现方法(initializetools/listresources/list)免费 — 无需认证。只有 tools/call 需要付费。

Claude Code

添加到 ~/.claude.json

json
{
  "mcpServers": {
    "jarvisclaw": {
      "type": "url",
      "url": "https://api.jarvisclaw.ai/mcp",
      "headers": {
        "Authorization": "Bearer sk-your-api-key"
      }
    }
  }
}

配置后,以下工具会自动出现:

工具说明
list_models列出所有可用 AI 模型
chat调用任意模型(OpenAI 兼容)
search_apis搜索用户发布的 API
get_api_detail获取 API 端点详情
discover_agents发现其他已注册的 Agent
aip_resolve为某个意图排序候选供应商
aip_execute_with_budget在硬预算上限内执行意图
aip_list_intents列出支持的意图类型
aip_estimate_cost执行前估算成本
uapi_{slug}直接调用特定用户 API

Cursor / Windsurf

添加到项目根目录的 .cursor/mcp.json

json
{
  "mcpServers": {
    "jarvisclaw": {
      "url": "https://api.jarvisclaw.ai/mcp",
      "headers": {
        "Authorization": "Bearer sk-your-api-key"
      }
    }
  }
}

编程方式使用

MCP 使用 JSON-RPC 2.0 over HTTP。可直接连接:

python
import httpx

# 1. 初始化(无需认证)
resp = httpx.post("https://api.jarvisclaw.ai/mcp", json={
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize",
    "params": {
        "protocolVersion": "2025-03-26",
        "capabilities": {},
        "clientInfo": {"name": "my-agent", "version": "1.0"}
    }
})

# 2. 列出工具(无需认证)
resp = httpx.post("https://api.jarvisclaw.ai/mcp", json={
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/list"
})

# 3. 调用工具(需要认证)
resp = httpx.post("https://api.jarvisclaw.ai/mcp",
    headers={"Authorization": "Bearer sk-your-api-key"},
    json={
        "jsonrpc": "2.0",
        "id": 3,
        "method": "tools/call",
        "params": {
            "name": "chat",
            "arguments": {
                "model": "gpt-4o",
                "messages": [{"role": "user", "content": "你好!"}]
            }
        }
    }
)
print(resp.json()["result"]["content"][0]["text"])

通过 MCP 进行 x402 支付

拥有 USDC 钱包的 Agent 无需账户即可按次支付:

Agent                        JarvisClaw MCP
  │                                │
  │── tools/call (无认证) ────────> │
  │<── error: 需要支付 ──────────  │  (price, payTo, network)
  │                                │
  │  [签名 USDC x402 支付]         │
  │                                │
  │── tools/call + PAYMENT-SIG ──> │
  │<── 工具结果 ─────────────────  │
python
# 不带支付调用 → 获取价格信息
resp = httpx.post("https://api.jarvisclaw.ai/mcp", json={
    "jsonrpc": "2.0", "id": 3,
    "method": "tools/call",
    "params": {"name": "chat", "arguments": {"model": "gpt-4o", "messages": [...]}}
})
# → 返回错误和支付详情(amount, payTo, network)

# 签名 x402 支付,然后携带 PAYMENT-SIGNATURE 头重试
resp = httpx.post("https://api.jarvisclaw.ai/mcp",
    headers={"PAYMENT-SIGNATURE": payment_sig},
    json={...}
)

支付参数:

  • 网络: Base (eip155:8453)
  • 资产: USDC (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913)
  • Facilitator: https://api.cdp.coinbase.com/platform/v2/x402