Skip to main content

OpenClaw Integration

OpenClaw is an open-source personal AI assistant that you run on your own devices and talk to through the messaging apps you already use. You can configure it to route its Claude API calls through the LeanMCP AI Gateway for monitoring, cost tracking, and content filtering.

About OpenClaw

OpenClaw is an open-source personal AI assistant created by Austrian developer Peter Steinberger as a playground project in late 2025 , originally released under the name Clawdbot and briefly renamed Moltbot before settling on OpenClaw in late January 2026 after trademark concerns from Anthropic’s legal team over the original “Clawd” pun on “Claude” . Rather than living in a browser tab, OpenClaw runs locally on your machine and answers you on channels you already use like WhatsApp, Telegram, Slack, Discord, Google Chat, Signal, iMessage, Microsoft Teams, Matrix, LINE, and many more , with persistent memory stored in local Markdown files, a skills system, scheduled wakeups, and integrations for browser control, voice, and canvas rendering. The project went viral almost immediately: it drew 2 million visitors in a single week shortly after launch, reached around 247,000 stars and 47,700 forks on GitHub by early March 2026 , and surpassed 250,000 stars on March 3, 2026, overtaking React to become one of the fastest-growing projects in GitHub history . In February 2026, Steinberger announced he was joining OpenAI and that OpenClaw would move to a foundation to stay open and independent , and the project continues to ship weekly releases driven by its community.

Monitoring OpenClaw with LeanMCP

Because OpenClaw makes its Claude calls through a standard Anthropic-compatible client, you can point it at the LeanMCP AI Gateway instead of the Anthropic API directly. Every request then flows through LeanMCP, where it gets logged, scanned for sensitive data, attributed to a user, and counted against your spending limits — without changing anything about how you talk to your assistant from Discord, Telegram, or WhatsApp.

Prerequisites

1

Enable Billing

Before anything else, sign in at app.leanmcp.com and enable billing on your account. Until billing is enabled, gateway requests will be rejected even if you have an API key. Add a payment method and top up credits from the Billing section of the dashboard.
2

Create an API Key

Create an API key at app.leanmcp.com/api-keys with SDK permissions. Your key will start with leanmcp_.
3

Install OpenClaw

If you don’t already have OpenClaw running, install it and run the onboarding wizard:
    npm install -g openclaw@latest
    openclaw onboard --install-daemon

Configuration

Environment Variables

Point OpenClaw at the LeanMCP AI Gateway by setting the Anthropic environment variables on the host running the OpenClaw gateway:
# AI Gateway Configuration (instead of direct Anthropic)
ANTHROPIC_API_KEY=leanmcp_your_api_key_here
ANTHROPIC_BASE_URL=https://aigateway.leanmcp.com/v1/anthropic
Add these to ~/.openclaw/.env (or your shell profile) and restart the gateway:
openclaw gateway

Configuration File

If you prefer to configure OpenClaw via its config file rather than environment variables:
{
  "anthropic": {
    "apiKey": "leanmcp_your_api_key_here",
    "baseUrl": "https://aigateway.leanmcp.com/v1/anthropic"
  }
}

How It Works

Discord / Telegram / WhatsApp / iMessage user message
        |
        v
    OpenClaw (local gateway on your machine)
        |
        v
  LeanMCP AI Gateway  <-- Logs request, checks for sensitive data, enforces limits
        |
        v
   Anthropic API
        |
        v
  Claude Response
        |
        v
  Reply on the originating channel

Benefits for OpenClaw Users

User Monitoring

Track which messaging users are talking to your assistant and how much

Cost Control

Set spending limits to prevent runaway costs from heavy usage or loops

Content Filtering

Block sensitive prompts before they reach Claude

Usage Analytics

Understand how OpenClaw is being used across all your channels

Adding Per-User Tracking

OpenClaw runs across many channels. To attribute usage to the right person and channel, attach identifying headers when OpenClaw calls the Anthropic SDK:
const response = await anthropic.messages.create({
  model: 'claude-sonnet-4-5-20250929',
  messages: messages,
}, {
  headers: {
    'X-User-ID': message.author.id,
    'X-Channel': 'discord', // or telegram, whatsapp, imessage, ...
    'X-Server-ID': message.guild?.id,
  }
});
This enables per-user usage tracking, per-user limits, and the ability to block specific users from your dashboard.

Verifying the Setup

  1. Restart your OpenClaw gateway after changing environment variables.
  2. Send a message to your assistant on any connected channel (Discord, Telegram, WhatsApp, etc.).
  3. Open the LeanMCP Dashboard and confirm the request appears in the logs.

Setting Up Rate Limits

Protect your assistant from runaway loops or abusive users:
await leanmcp.gateway.setRateLimit({
  scope: 'per_user',
  limits: {
    requestsPerMinute: 5,
    requestsPerHour: 50,
    tokensPerDay: 100000,
  }
});

Troubleshooting

  • Check that the OpenClaw gateway daemon is running (openclaw status)
  • Verify your LeanMCP API key is valid and billing is enabled
  • Tail the gateway logs for errors
  • Ensure the base URL ends with /v1/anthropic (no trailing slash)
  • Verify your API key starts with leanmcp_
  • Confirm billing is enabled and you have remaining credits at app.leanmcp.com
  • Confirm OpenClaw is actually using the custom base URL (check the env vars inside the running process)
  • Restart the gateway after configuration changes
  • Make sure you’re looking at the same workspace in the dashboard that owns the API key

Resources

Next Steps

Set Up Alerts

Get notified of unusual usage

Optimize Costs

Reduce token usage