This commit introduces the OpenClaw Model Context Protocol (MCP) server integration for Cursor IDE, enabling users to leverage OpenClaw's AI capabilities directly within the IDE. Key features include session management, multi-channel messaging, and built-in code assistance prompts. The integration is documented in the new `cursor-mcp.md` file and includes a changelog for version 2026.1.29. New files added: - `cursor-mcp.md`: Documentation for MCP integration. - `CHANGELOG.md`: Changelog for the integration. - `index.ts`: Main plugin file for MCP server. - `openclaw.plugin.json`: Plugin configuration. - `README.md`: Detailed usage instructions. - `src/gateway-client.ts`: WebSocket client for gateway communication. - `src/server.ts`: MCP server implementation. - `src/types.ts`: Type definitions for the MCP server. - `tsconfig.json`: TypeScript configuration. - `package.json`: Plugin dependencies and scripts. |
||
|---|---|---|
| .. | ||
| src | ||
| CHANGELOG.md | ||
| index.ts | ||
| openclaw.plugin.json | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
OpenClaw Cursor MCP Integration
This extension provides Model Context Protocol (MCP) server integration for Cursor IDE, enabling OpenClaw as an AI backend within Cursor's Composer Agent.
Features
- Chat with OpenClaw Agent: Use OpenClaw's AI capabilities directly in Cursor
- Session Management: Create, list, and manage conversation sessions
- Multi-Channel Messaging: Send messages through WhatsApp, Telegram, Discord, Slack, and more
- Model Selection: Choose from any AI model configured in OpenClaw
- Code Assistance Prompts: Built-in prompts for code review, debugging, test generation, and more
Quick Start
Prerequisites
-
OpenClaw installed and gateway running:
npm install -g openclaw openclaw gateway run -
Cursor IDE installed
Setup in Cursor
Option 1: Cursor Settings UI
- Open Cursor Settings → Features → MCP
- Click "+ Add New MCP Server"
- Configure:
- Name:
openclaw - Type:
stdio - Command:
openclaw - Arguments:
mcp serve
- Name:
Option 2: Manual Configuration
Create or edit ~/.cursor/mcp.json:
{
"mcpServers": {
"openclaw": {
"command": "openclaw",
"args": ["mcp", "serve"],
"env": {
"OPENCLAW_GATEWAY_URL": "ws://127.0.0.1:18789"
}
}
}
}
Authentication (Optional)
If your gateway requires authentication, add credentials to the environment:
{
"mcpServers": {
"openclaw": {
"command": "openclaw",
"args": ["mcp", "serve"],
"env": {
"OPENCLAW_GATEWAY_URL": "ws://127.0.0.1:18789",
"OPENCLAW_GATEWAY_TOKEN": "your-token-here",
"OPENCLAW_GATEWAY_PASSWORD": "your-password-here"
}
}
}
}
Available Tools
| Tool | Description |
|---|---|
openclaw_chat |
Chat with the OpenClaw AI agent |
openclaw_list_sessions |
List all active chat sessions |
openclaw_get_session |
Get details about a specific session |
openclaw_clear_session |
Clear a session's conversation history |
openclaw_execute_command |
Execute OpenClaw control commands |
openclaw_send_message |
Send messages through channels |
openclaw_get_status |
Get gateway and channel status |
openclaw_list_models |
List available AI models |
Available Resources
| URI | Description |
|---|---|
openclaw://status |
Gateway and channel status |
openclaw://models |
Available AI models |
openclaw://sessions |
Active chat sessions |
openclaw://config |
Current configuration (sanitized) |
Available Prompts
| Prompt | Description |
|---|---|
code_review |
Review code for issues and improvements |
explain_code |
Explain how code works |
generate_tests |
Generate tests for code |
refactor_code |
Suggest refactoring improvements |
debug_help |
Help debug issues |
send_notification |
Send notification via channels |
Usage Examples
Chat with OpenClaw
In Cursor's Composer, the Agent can use OpenClaw tools:
User: Use openclaw to help me debug this Python code
Agent: [Uses openclaw_chat tool to send your code to OpenClaw]
Send a Message
User: Send "Build completed successfully" to my Telegram
Agent: [Uses openclaw_send_message with target and channel]
Check Status
User: What's the status of my OpenClaw channels?
Agent: [Uses openclaw_get_status tool]
CLI Commands
# Start MCP server (usually done automatically by Cursor)
openclaw mcp serve
# Show configuration help
openclaw mcp info
# With custom options
openclaw mcp serve --url ws://localhost:18789 --session agent:main:cursor
Environment Variables
| Variable | Description | Default |
|---|---|---|
OPENCLAW_GATEWAY_URL |
Gateway WebSocket URL | ws://127.0.0.1:18789 |
OPENCLAW_GATEWAY_TOKEN |
Authentication token | - |
OPENCLAW_GATEWAY_PASSWORD |
Authentication password | - |
OPENCLAW_SESSION_KEY |
Default session key | agent:main:cursor |
Troubleshooting
Gateway Connection Failed
-
Ensure the OpenClaw gateway is running:
openclaw gateway run -
Check the gateway URL in your configuration
-
Verify authentication credentials if required
Tools Not Appearing in Cursor
- Restart Cursor after adding the MCP server
- Check Cursor's MCP logs for errors
- Ensure
openclawis in your PATH
Session Issues
Clear and restart a session:
User: Clear my OpenClaw session
Agent: [Uses openclaw_clear_session tool]
Development
# Install dependencies
cd extensions/cursor-mcp
pnpm install
# Build
pnpm build
# Test locally
node bin/server.js
Architecture
┌─────────────────┐ MCP Protocol ┌──────────────────┐
│ Cursor IDE │◄───────────────────►│ OpenClaw MCP │
│ (MCP Client) │ (stdio) │ Server │
└─────────────────┘ └────────┬─────────┘
│
│ WebSocket
▼
┌──────────────────┐
│ OpenClaw │
│ Gateway │
└────────┬─────────┘
│
┌─────────────────────────────┼─────────────────────────────┐
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ WhatsApp │ │ Telegram │ │ Discord │
└───────────────┘ └───────────────┘ └───────────────┘
License
MIT - Part of the OpenClaw project.