OpenClaw MCP服务器
](https://www.npmjs.com/package/openclaw-mcp)    
🦞 模型上下文协议(MCP)服务器 开爪 AI助手集成。
演示
我为什么建造这个
嘿!我创建了这个MCP服务器,因为我不想仅仅依靠消息传递渠道与OpenClaw通信。真正让我兴奋的是将OpenClaw连接到Claude web UI的能力。本质上,我的聊天可以将任务委托给我的Claw机器人,然后它会处理其他所有事情——比如启动Claude Code来为我解决问题。
把它想象成一个人工智能助手在指挥另一个人工智慧助手。很酷,对吧?
快速开始
Docker(推荐)
每次发布时,预构建的映像都会发布到GitHub容器注册表中。
docker pull ghcr.io/freema/openclaw-mcp:latest创建一个 docker-compose.yml:
services:
mcp-bridge:
image: ghcr.io/freema/openclaw-mcp:latest
container_name: openclaw-mcp
restart: unless-stopped
ports:
- "3000:3000"
environment:
- OPENCLAW_URL=http://host.docker.internal:18789
- OPENCLAW_GATEWAY_TOKEN=${OPENCLAW_GATEWAY_TOKEN}
- OPENCLAW_MODEL=openclaw
- AUTH_ENABLED=true
- MCP_CLIENT_ID=openclaw
- MCP_CLIENT_SECRET=${MCP_CLIENT_SECRET}
- MCP_ISSUER_URL=${MCP_ISSUER_URL:-}
- CORS_ORIGINS=https://claude.ai
extra_hosts:
- "host.docker.internal:host-gateway"
read_only: true
security_opt:
- no-new-privileges生成机密并开始:
export MCP_CLIENT_SECRET=$(openssl rand -hex 32)
export OPENCLAW_GATEWAY_TOKEN=your-gateway-token
docker compose up -d然后在Claude.ai中添加一个指向服务器的自定义MCP连接器 MCP_CLIENT_ID=openclaw 和你的 MCP_CLIENT_SECRET.
提示: 固定特定版本,而不是latest用于生产:ghcr.io/freema/openclaw-mcp:1.1.0
本地(克劳德桌面)
npx openclaw-mcp添加到您的Claude Desktop配置中:
{
"mcpServers": {
"openclaw": {
"command": "npx",
"args": ["openclaw-mcp"],
"env": {
"OPENCLAW_URL": "http://127.0.0.1:18789",
"OPENCLAW_GATEWAY_TOKEN": "your-gateway-token",
"OPENCLAW_MODEL": "openclaw",
"OPENCLAW_TIMEOUT_MS": "300000"
}
}
}
}无Docker的远程(Claude.ai)
AUTH_ENABLED=true MCP_CLIENT_ID=openclaw MCP_CLIENT_SECRET=your-secret \
MCP_ISSUER_URL=https://mcp.your-domain.com \
CORS_ORIGINS=https://claude.ai OPENCLAW_GATEWAY_TOKEN=your-gateway-token \
npx openclaw-mcp --transport sse --port 3000重要提示: 当在反向代理(Caddy、nginx等)后面运行时,您 必须 集MCP_ISSUER_URL(或--issuer-url)到您的公共HTTPS URL。如果没有这个,OAuth元数据将进行广告http://localhost:3000客户端将无法进行身份验证。
看 安装指南 了解详情。
建筑
┌─────────────────────────────────────────────────────────────────┐
│ Your Server │
│ │
│ ┌─────────────────┐ ┌─────────────────────────┐ │
│ │ OpenClaw │ │ OpenClaw MCP │ │
│ │ Gateway │◄────►│ Bridge Server │ │
│ │ :18789 │ │ :3000 │ │
│ │ │ │ │ │
│ │ OpenAI-compat │ │ - OAuth 2.1 auth │ │
│ │ /v1/chat/... │ │ - CORS protection │ │
│ └─────────────────┘ │ - Input validation │ │
│ └──────────┬──────────────┘ │
│ │ │
└──────────────────────────────────────┼──────────────────────────┘
│ HTTPS + OAuth 2.1
▼
┌─────────────────┐
│ Claude.ai │
│ (MCP Client) │
└─────────────────┘可用工具
同步工具
| 工具 | 说明 |
|---|---|
openclaw_chat | 向OpenClaw发送消息并获得回复 |
openclaw_status | 检查OpenClaw网关运行状况 |
openclaw_instances | 列出所有已配置的OpenClaw实例 |
异步工具(用于长时间运行的操作)
| 工具 | 说明 |
|---|---|
openclaw_chat_async | 排队消息,立即获取task_id |
openclaw_task_status | 检查任务进度并获得结果 |
openclaw_task_list | 列出所有具有筛选功能的任务 |
openclaw_task_cancel | 取消待处理的任务 |
多实例模式
从单个MCP服务器协调多个OpenClaw网关。一座桥,多个爪子——将请求路由到prod、staging、dev或任何你称之为的名称(龙虾至尊和爪子持久是完全有效的名称)。
┌──────────────────────────────────────────────────────────────────────┐
│ Claude.ai / Claude Desktop │
│ (MCP Client) │
└──────────────────────┬───────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────────┐
│ OpenClaw MCP Bridge Server │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Instance │ │ Instance │ │ Instance │ │
│ │ Registry │ │ Resolver │ │ Validator │ │
│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
│ │ │ │ │
│ ┌──────┴─────────────────┴──────────────────┴───────┐ │
│ │ Per-Instance OpenClaw Clients │ │
│ │ (separate auth, timeout, URL per instance) │ │
│ └────────┬──────────────┬──────────────┬────────────┘ │
└───────────┼──────────────┼──────────────┼────────────────────────────┘
│ │ │
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ 🦞 prod │ │ 🦞 staging │ │ 🦞 dev │
│ (default) │ │ │ │ │
│ :18789 │ │ :18789 │ │ :18789 │
│ OpenClaw GW │ │ OpenClaw GW │ │ OpenClaw GW │
└──────────────┘ └──────────────┘ └──────────────┘设置
OPENCLAW_INSTANCES='[
{"name": "prod", "url": "http://prod:18789", "token": "tok1", "default": true},
{"name": "staging", "url": "http://staging:18789", "token": "tok2"},
{"name": "dev", "url": "http://dev:18789", "token": "tok3"}
]'用法
所有工具都接受可选 instance 针对特定网关的参数:
# Chat with staging instance
openclaw_chat message="Deploy status?" instance="staging"
# Check health of prod
openclaw_status instance="prod"
# List all configured instances
openclaw_instances
# Async task targeting dev
openclaw_chat_async message="Run tests" instance="dev"当 instance 如果省略,则使用默认实例。每个实例都有自己的身份验证令牌、超时和URL——完全隔离。
主要特点
- 零迁移升级 --现有的单实例部署无需更改任何配置即可工作
- 每实例隔离 --单独的身份验证令牌、超时和URL
- 动态路由 --Claude为每个请求选择正确的实例
- 任务跟踪 --异步任务记住它们针对的是哪个实例
- 安全 --令牌永远不会通过以下方式暴露
openclaw_instances
看 配置——多实例模式 以获取完整参考。
文档
- 安装 --Claude Desktop和Claude.ai的设置
- 配置 --环境变量和选项
- 部署 --Docker和生产设置
- 威胁模型 --克劳德能/不能触发什么,信任边界和攻击面
- 日志记录 --什么被记录,在哪里,什么从未被记录
- 发展 --贡献和添加工具
- 安全 --安全政策和最佳实践
安全
⚠️ 始终在生产中启用身份验证!
# Generate secure client secret
export MCP_CLIENT_SECRET=$(openssl rand -hex 32)
# Run with auth enabled
AUTH_ENABLED=true MCP_CLIENT_ID=openclaw MCP_CLIENT_SECRET=$MCP_CLIENT_SECRET \
openclaw-mcp --transport sse配置CORS以限制访问:
CORS_ORIGINS=https://claude.ai,https://your-app.com看 配置 所有安全选项。
需求
- Node.js≥20
- OpenClaw网关在启用HTTP API的情况下运行:
// openclaw.json
{ "gateway": { "http": { "endpoints": { "chatCompletions": { "enabled": true } } } } }许可证
麻省理工学院
作者
由...创建 托马斯 格拉斯尔
