openclaw-mcp
π¦ MCP server for OpenClaw - secure bridge between Claude.ai and your self-hosted OpenClaw assistant with OAuth2 authentication
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Badge for your README
Markdown
[](/listings/freema--openclaw-mcp)HTML
<a href="/listings/freema--openclaw-mcp"><img src="/api/listings/freema--openclaw-mcp/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
Docker (Recommended)
Pre-built images are published to GitHub Container Registry on every release.
docker pull ghcr.io/freema/openclaw-mcp:latest
Create a `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_AGENT_ID=${OPENCLAW_AGENT_ID:-}
- OPENCLAW_MODEL=openclaw
- AUTH_ENABLED=true
- MCP_CLIENT_ID=openclaw
- MCP_CLIENT_SECRET=${MCP_CLIENT_SECRET}
- MCP_ISSUER_URL=${MCP_ISSUER_URL:-}
- MCP_REDIRECT_URIS=https://claude.ai/api/mcp/auth_callback,https://claude.com/api/mcp/auth_callback
- TRUST_PROXY=1
- CORS_ORIGINS=https://claude.ai
extra_hosts:
- "host.docker.internal:host-gateway"
read_only: true
security_opt:
- no-new-privilegesGenerate secrets and start:
export MCP_CLIENT_SECRET=$(openssl rand -hex 32) export OPENCLAW_GATEWAY_TOKEN=your-gateway-token docker compose up -d
Then in Claude.ai add a custom MCP connector pointing to `https://your-domain.com/mcp` with `MCP_CLIENT_ID=openclaw` and your `MCP_CLIENT_SECRET`.
> **Important:** The connector URL **must end with `/mcp`** β that's the Streamable HTTP endpoint. A bare domain (`https://your-domain.com`) hits the server root and returns 404 after OAuth completes.
> **Tip:** Pin a specific version instead of `latest` for production: `ghcr.io/freema/openclaw-mcp:1.1.0`
Local (Claude Desktop)
npx openclaw-mcp
Add to your Claude Desktop config:
{
"mcpServers": {
"openclaw": {
"command": "npx",
"args": ["openclaw-mcp"],
"env": {
"OPENCLAW_URL": "http://127.0.0.1:18789",
"OPENCLAW_GATEWAY_TOKEN": "your-gateway-token",
"OPENCLAW_AGENT_ID": "main",
"OPENCLAW_MODEL": "openclaw",
"OPENCLAW_TIMEOUT_MS": "300000"
}
}
}
}Remote (Claude.ai) without Docker
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 http --port 3000
> **Important:** When running behind a reverse proxy (Caddy, nginx, Traefik, Cloudflare Tunnel, etc.) you **must** set: > - `MCP_ISSUER_URL` (or `--issuer-url`) to your public HTTPS URL β otherwise OAuth metadata advertises `http://localhost:3000` and clients fail to authenticate. > - `TRUST_PROXY=1` (or `--trust-proxy 1`) β otherwise `express-rate-limit` rejects the proxy's `X-Forwarded-For` header and `/token` crashes with `ERR_ERL_UNEXPECTED_X_FORWARDED_FOR`.
> **Recommended:** Set `MCP_REDIRECT_URIS=https://claude.ai/api/mcp/auth_callback,https://claude.com/api/mcp/auth_callback` so authorization codes can only be delivered to Claude's callbacks. Note the exact `/api/mcp/auth_callback` path β matching is exact, and getting it wrong fails OAuth with `Unregistered redirect_uri` (see [Troubleshooting](docs/deployment.md#invalid_request--unregistered-redirect_uri-on-authorize)).
See [Installation Guide](docs/installation.md) for details.
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
.claude-plugin/marketplace.json Β· Manifest Β· 23 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.
- {
- "$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
- "name": "openclaw-mcp",
- "description": "Bridge Claude.ai to your self-hosted OpenClaw AI agent via the Model Context Protocol. Chat, manage sessions, and run async tasks.",
- "owner": {
- "name": "Tomas Grasl"
- },
- "plugins": [
- {
- "name": "openclaw",
- "source": "./plugins/claude/openclaw",
- "description": "OpenClaw AI assistant integration. Chat, manage sessions, access memory, and run async tasks through your OpenClaw instance.",
- "version": "0.1.0",
- "author": {
- "name": "Tomas Grasl"
- },
- "repository": "https://github.com/freema/openclaw-mcp",
- "license": "MIT",
- "keywords": ["openclaw", "mcp", "ai-agent", "claude", "orchestration", "async-tasks"],
- "category": "integration"
- }
- ]
- }
README.md Β· README Β· 410 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.
- <!-- mcp-name: io.github.freema/openclaw-mcp -->
- # OpenClaw MCP Server
- [](https://www.npmjs.com/package/openclaw-mcp)
- [](https://github.com/freema/openclaw-mcp/actions/workflows/ci.yml)
- [](https://opensource.org/licenses/MIT)
- [](https://github.com/freema/openclaw-mcp/pkgs/container/openclaw-mcp)
- [](https://openclaw-mcp.cloud)
- <a href="https://glama.ai/mcp/servers/@freema/openclaw-mcp">
- <img width="380" height="200" src="https://glama.ai/mcp/servers/@freema/openclaw-mcp/badge" />
- </a>
- π¦ Model Context Protocol (MCP) server for [OpenClaw](https://github.com/openclaw/openclaw) AI assistant integration.
- ## Demo
- <p align="center">
- <img src="docs/assets/claude-ai-demo.gif" alt="OpenClaw MCP in Claude.ai" width="720" />
- </p>
- ## Why I Built This
- Hey! I created this MCP server because I didn't want to rely solely on messaging channels to communicate with OpenClaw. What really excites me is the ability to connect OpenClaw to the Claude web UI. Essentially, my chat can delegate tasks to my Claw bot, which then handles everything else β like spinning up Claude Code to fix issues for me.
- Think of it as an AI assistant orchestrating another AI assistant. Pretty cool, right?
- ## Quick Start
- ### Docker (Recommended)
- Pre-built images are published to GitHub Container Registry on every release.
- ```bash
- docker pull ghcr.io/freema/openclaw-mcp:latest
- ```
- Create a `docker-compose.yml`:
- ```yaml
- services:
- mcp-bridge:
- image: ghcr.io/freema/openclaw-mcp:latest
- container_name: openclaw-mcp
- restart: unless-stopped
- ports:
- - "127.0.0.1:3000:3000" # loopback only, reached through your reverse proxy
- environment:
- - OPENCLAW_URL=http://host.docker.internal:18789
- - OPENCLAW_GATEWAY_TOKEN=${OPENCLAW_GATEWAY_TOKEN}
- - OPENCLAW_AGENT_ID=${OPENCLAW_AGENT_ID:-}
- - OPENCLAW_MODEL=openclaw
- - MCP_CLIENT_ID=openclaw
- - MCP_CLIENT_SECRET=${MCP_CLIENT_SECRET}
- - MCP_ISSUER_URL=${MCP_ISSUER_URL:-}
- - MCP_REDIRECT_URIS=https://claude.ai/api/mcp/auth_callback,https://claude.com/api/mcp/auth_callback
- - TRUST_PROXY=1
- - CORS_ORIGINS=https://claude.ai
- extra_hosts:
- - "host.docker.internal:host-gateway"
- read_only: true
- cap_drop:
- - ALL
- security_opt:
- - no-new-privileges
- ```
- The port is published on `127.0.0.1` only: the bridge speaks plain HTTP and is
- meant to sit behind a TLS-terminating reverse proxy on the same host (see
- [Deployment](docs/deployment.md#reverse-proxy-https)).
- Generate secrets and start:
- ```bash
- export MCP_CLIENT_SECRET=$(openssl rand -hex 32)
- export OPENCLAW_GATEWAY_TOKEN=your-gateway-token
- docker compose up -d
- ```
- Then in Claude.ai add a custom MCP connector pointing to `https://your-domain.com/mcp` with `MCP_CLIENT_ID=openclaw` and your `MCP_CLIENT_SECRET`.
- > **Important:** The connector URL **must end with `/mcp`** β that's the Streamable HTTP endpoint. A bare domain (`https://your-domain.com`) hits the server root and returns 404 after OAuth completes.
- > **Tip:** Pin a specific version instead of `latest` for production: `ghcr.io/freema/openclaw-mcp:1.8.1`
- > **Use a least-privilege agent.** Set `OPENCLAW_AGENT_ID` to a dedicated OpenClaw agent that only has the tools you want Claude to reach β not your main agent with shell access. See [Security](#security).
- ### Local (Claude Desktop)
- ```bash
- npx openclaw-mcp
- ```
- Add to your Claude Desktop config:
- ```json
- {
- "mcpServers": {
- "openclaw": {
- "command": "npx",
- "args": ["openclaw-mcp"],
- "env": {
- "OPENCLAW_URL": "http://127.0.0.1:18789",
- "OPENCLAW_GATEWAY_TOKEN": "your-gateway-token",
- "OPENCLAW_AGENT_ID": "main",
- "OPENCLAW_MODEL": "openclaw",
- "OPENCLAW_TIMEOUT_MS": "300000"
- }
- }
- }
- }
- ```
- ### Remote (Claude.ai) without Docker
- ```bash
- 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 http --port 3000
- ```
- > **Important:** When running behind a reverse proxy (Caddy, nginx, Traefik, Cloudflare Tunnel, etc.) you **must** set:
- > - `MCP_ISSUER_URL` (or `--issuer-url`) to your public HTTPS URL β otherwise OAuth metadata advertises `http://localhost:3000` and clients fail to authenticate.
- > - `TRUST_PROXY=1` (or `--trust-proxy 1`) β otherwise `express-rate-limit` rejects the proxy's `X-Forwarded-For` header and `/token` crashes with `ERR_ERL_UNEXPECTED_X_FORWARDED_FOR`.
- > **Recommended:** Set `MCP_REDIRECT_URIS=https://claude.ai/api/mcp/auth_callback,https://claude.com/api/mcp/auth_callback` so authorization codes can only be delivered to Claude's callbacks. Note the exact `/api/mcp/auth_callback` path β matching is exact, and getting it wrong fails OAuth with `Unregistered redirect_uri` (see [Troubleshooting](docs/deployment.md#invalid_request--unregistered-redirect_uri-on-authorize)).
- See [Installation Guide](docs/installation.md) for details.
- ## Architecture
- ```
- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- β 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) β
- βββββββββββββββββββ
- ```
- ## Available Tools
- ### Sync Tools
- | Tool | Description |
- |------|-------------|
- | `openclaw_chat` | Send messages to OpenClaw and get responses |
- | `openclaw_status` | Check OpenClaw gateway health |
- | `openclaw_instances` | List all configured OpenClaw instances |
- ### Async Tools (for long-running operations)
- | Tool | Description |
- |------|-------------|
- | `openclaw_chat_async` | Queue a message, get task_id immediately |
- | `openclaw_task_status` | Check task progress and get results |
- | `openclaw_task_list` | List your tasks with filtering |
- | `openclaw_task_cancel` | Cancel a pending task |
- Tasks belong to whoever created them. In HTTP mode that is the authenticated
- OAuth client, so a client can poll its tasks from a new MCP session, and
- another client's `task_id` reads as "not found" even if it is known. Without
- an authenticated client (stdio) tasks are scoped to the connection.
- ## Multi-Instance Mode
- Orchestrate multiple OpenClaw gateways from a single MCP server. One bridge, many claws β route requests to prod, staging, dev, or whatever you name them (lobster-supreme and the-claw-abides are perfectly valid names).
- ```
- ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- β 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 β
- ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
- ```
- ### Setup
- ```bash
- 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"}
- ]'
- ```
- ### Usage
- All tools accept an optional `instance` parameter to target a specific gateway:
- ```
- # 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"
- ```
- When `instance` is omitted, the default instance is used. Each instance has its own auth token, timeout, and URL β fully isolated.
- ### Key Features
- - **Zero-migration upgrade** β existing single-instance deployments work without any config change
- - **Per-instance isolation** β separate auth tokens, timeouts, and URLs
- - **Dynamic routing** β Claude picks the right instance per request
- - **Task tracking** β async tasks remember which instance they target
- - **Security** β tokens are never exposed via `openclaw_instances`
- See [Configuration β Multi-Instance Mode](docs/configuration.md#multi-instance-mode) for the full reference.
- ## Documentation
- - [Installation](docs/installation.md) β Setup for Claude Desktop & Claude.ai
- - [Configuration](docs/configuration.md) β Environment variables & options
- - [Deployment](docs/deployment.md) β Docker & production setup
- - [Threat Model](docs/threat-model.md) β What Claude can/can't trigger, trust boundaries & attack surfaces
- - [Logging](docs/logging.md) β What gets logged, where, and what is never logged
- - [Development](docs/development.md) β Contributing & adding tools
- - [Security](SECURITY.md) β Security policy & best practices
- ## Security
- β οΈ **Always enable authentication in production!**
- ```bash
- # Generate secure client secret
- export MCP_CLIENT_SECRET=$(openssl rand -hex 32)
- # Run with auth enabled
- MCP_CLIENT_ID=openclaw MCP_CLIENT_SECRET=$MCP_CLIENT_SECRET \
- openclaw-mcp --transport http
- ```
- CORS is disabled unless you opt in. Set `CORS_ORIGINS` only when a browser
- client needs to reach the server directly:
- ```bash
- CORS_ORIGINS=https://claude.ai,https://your-app.com
- ```
- See [Configuration](docs/configuration.md) for all security options.
- ### Give the bridge a least-privilege agent
- The bridge passes text to an OpenClaw agent and cannot judge what that text
- makes the agent do. Anything Claude reads β a web page, an email, a document β
- can end up in an `openclaw_chat` call, so prompt injection into an agent that
- can run shell commands is the biggest real-world risk of this setup, and OAuth
- does not help against it. Do not point the bridge at your main agent: create a
- dedicated OpenClaw agent with only the tools it needs, sandboxed, and select it
- with `OPENCLAW_AGENT_ID`. Details in [SECURITY.md](SECURITY.md#prompt-injection-and-the-openclaw-agent)
- and the [Threat Model](docs/threat-model.md).
- ### Upgrading to 1.8.1
- A security and maintenance release; no configuration changes are required.
- - **`docker-compose.yml` now publishes the port on `127.0.0.1` only.** If you
- use the compose file from this repository and reach port 3000 directly from
- another machine (no reverse proxy on the same host), it stops being
- reachable after you update the file. Put a reverse proxy in front, or set
- `BIND_ADDRESS=0.0.0.0` to restore the old binding. A compose file you
- maintain yourself, and `docker run`, are not affected. The compose file also
- drops all Linux capabilities (`cap_drop: [ALL]`).
- - **MCP SDK 1.32.2** with its security fixes; the Docker image runs on
- Node.js 24. The npm package still supports Node.js β₯ 20.
- - **Request bodies** on `/mcp` and `/messages` are limited to 4 MiB and parsed
- only after authentication. Long non-ASCII messages that used to fail with
- `413` under the old implicit 100 kB limit now work; JSON-RPC batches are
- capped at 100 messages by the SDK.
- See the [changelog](CHANGELOG.md) for the full list.
- ### Upgrading to 1.8.0
- **OAuth is now mandatory for the HTTP transport.** Before 1.8.0 HTTP mode ran
- without authentication unless `AUTH_ENABLED=true` was set, so a bare
- `docker run` of the image exposed every tool to anyone who could reach the
- port. Now:
- - Without `MCP_CLIENT_ID` and `MCP_CLIENT_SECRET` the server refuses to start.
- `AUTH_ENABLED=true` still works but is no longer needed.
- - `AUTH_ENABLED=false` / `--no-auth` refuses to start instead of silently
- disabling auth. If you really need an unauthenticated server (e.g. a proxy
- in front already authenticates every request), set
- `MCP_DANGEROUSLY_DISABLE_AUTH=true` (`--dangerously-disable-auth`).
- - stdio is unchanged.
- **Async tasks now belong to the OAuth client, not the MCP connection.** A
- client that opens a new MCP session between tool calls can poll the tasks it
- created ([#44](https://github.com/freema/openclaw-mcp/issues/44)). The bridge
- is single-tenant β whoever holds the client secret already has full access to
- the same OpenClaw gateway β so the OAuth client is the isolation boundary.
- Dynamically registered clients each get their own namespace. Without auth,
- tasks stay scoped to the connection.
- **New `ALLOWED_HOSTS`** for a loopback bind behind a reverse proxy that
- preserves the public `Host` header (Tailscale Serve, nginx with
- `proxy_set_header Host $host`), which previously failed with `403 Invalid Host`
- ([#41](https://github.com/freema/openclaw-mcp/issues/41)). See
- [configuration](docs/configuration.md#server-settings-http-transport).
- ### Upgrading to 1.7.0
- Two defaults changed for security. Both only affect HTTP mode; stdio is
- unchanged.
- - **CORS is now off by default.** Previously an unset `CORS_ORIGINS` sent
- `Access-Control-Allow-Origin: *`. If a browser client depends on that, set
- the origins explicitly (`CORS_ORIGINS=https://your-app.com`), or
- `CORS_ORIGINS=*` to restore the old behaviour.
- - **Async tasks are scoped to the connection that created them.** A client
- that used to poll a `task_id` queued by a different connection will now get
- "not found". (1.8.0 relaxes this to the authenticated OAuth client.)
- ## Migrating from SSE to HTTP transport
- Starting with v1.5.0, the primary transport is **Streamable HTTP** (`--transport http`). The legacy SSE transport (`--transport sse`) is deprecated but still works for backward compatibility.
- ### What changed
- | Before | After |
- |--------|-------|
- | `--transport sse` | `--transport http` (recommended) |
- | Primary endpoint: `GET /sse` | Primary endpoint: `POST/GET/DELETE /mcp` |
- | Health: `"transport": "sse"` | Health: `"transport": "streamable-http"` |
- ### Migration steps
- 1. **CLI / Docker**: Replace `--transport sse` with `--transport http`
- ```bash
- # Before
- openclaw-mcp --transport sse --port 3000
- # After
- openclaw-mcp --transport http --port 3000
- ```
- 2. **Claude.ai connector URL**: No change needed β Claude.ai already uses `/mcp` (Streamable HTTP)
- 3. **Legacy clients**: The `/sse` and `/messages` endpoints still work. A deprecation warning is logged on each SSE connection.
- 4. **Dockerfile ENTRYPOINT**: Updated automatically if using the official Docker image
- > **Note:** `--transport sse` will continue to work as a deprecated alias. Both transports are served simultaneously regardless of which flag you use.
- ## Requirements
- - Node.js β₯ 20
- - OpenClaw gateway running with HTTP API enabled:
- ```json5
- // openclaw.json
- { "gateway": { "http": { "endpoints": { "chatCompletions": { "enabled": true } } } } }
- ```
- ## License
- MIT
- ## Author
- Created by [TomΓ‘Ε‘ Grasl](https://www.tomasgrasl.cz/)
- ## Related Projects
- - [OpenClaw](https://github.com/openclaw/openclaw) β The AI assistant this MCP connects to
- - [MCP Specification](https://spec.modelcontextprotocol.io/) β Model Context Protocol docs
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If itβs helped, pass it on.