OpenClaw with MCP Tools: Extending Your AI Agent
OpenClaw MCP tools let you connect any MCP-compatible server to your AI agent, extending its capabilities beyond built-in skills. Here's how it works.
OpenClaw supports MCP (Model Context Protocol) tools, which means you can connect any MCP-compatible server to your DenchClaw agent and give it new capabilities without writing custom skills from scratch. MCP is an open standard for connecting AI agents to external tools, data sources, and services — and the ecosystem is growing fast. This guide covers how to connect, configure, and use MCP tools with OpenClaw.
Before diving in, check what DenchClaw is and follow the setup guide if you haven't already.
What Is MCP?#
Model Context Protocol (MCP) is an open standard that defines how AI agents discover and call external tools. Think of it like USB — instead of writing a custom integration for every service, you write to the MCP standard once and it works with any MCP-compatible agent.
An MCP server exposes:
- Tools — functions the agent can call (e.g., "search the web", "read a file", "query a database")
- Resources — data the agent can read (e.g., a file system, a database table, a calendar)
- Prompts — pre-built prompt templates for common tasks
OpenClaw implements the MCP client side. You connect it to MCP servers, and your agent gains access to everything those servers expose.
The mcporter CLI#
DenchClaw includes the mcporter CLI for managing MCP connections. It handles:
- Listing available MCP servers
- Connecting to stdio and HTTP MCP servers
- Calling individual tools for testing
- Managing configuration
Read the mcporter skill to get the full reference:
cat ~/.nvm/versions/node/v22.21.0/lib/node_modules/openclaw/skills/mcporter/SKILL.mdOr load it in chat: "Load the mcporter skill and help me connect to an MCP server."
Step 1: Find MCP Servers#
The MCP ecosystem has servers for nearly everything. Some useful starting points:
Official Anthropic MCP servers:
@anthropic/mcp-server-filesystem— read/write local files@anthropic/mcp-server-github— GitHub operations@anthropic/mcp-server-postgres— PostgreSQL queries@anthropic/mcp-server-brave-search— web search
Community servers:
mcp-server-sqlite— SQLite database accessmcp-server-notion— Notion APImcp-server-slack— Slack messagingmcp-server-google-maps— location lookups
Find more at mcp.so or search npm for mcp-server-.
Step 2: Install an MCP Server#
Most MCP servers are npm packages. Install the ones you want to use:
# Filesystem server
npm install -g @anthropic/mcp-server-filesystem
# GitHub server
npm install -g @anthropic/mcp-server-github
# Brave Search server
npm install -g @anthropic/mcp-server-brave-searchSome servers are binaries or Python packages:
# Python-based MCP server
pip install mcp-server-sqlite
# Binary (example)
curl -L https://github.com/example/mcp-server/releases/latest/download/mcp-server \
-o ~/.local/bin/mcp-server && chmod +x ~/.local/bin/mcp-serverStep 3: Configure MCP Servers in OpenClaw#
OpenClaw reads MCP server configuration from its config file. Add your servers:
# List current MCP config
mcporter config list
# Add a stdio server (most npm MCP servers run over stdio)
mcporter config add filesystem \
--command "node /path/to/mcp-server-filesystem/dist/index.js" \
--args "/Users/kumareth/Documents"
# Add an HTTP server (some servers expose an HTTP API)
mcporter config add my-server \
--url "http://localhost:3001/mcp"The config is stored in ~/.openclaw-dench/workspace/.openclaw/mcp-config.json:
{
"servers": {
"filesystem": {
"type": "stdio",
"command": "node",
"args": [
"/usr/local/lib/node_modules/@anthropic/mcp-server-filesystem/dist/index.js",
"/Users/kumareth/Documents"
]
},
"github": {
"type": "stdio",
"command": "node",
"args": ["/usr/local/lib/node_modules/@anthropic/mcp-server-github/dist/index.js"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
},
"brave-search": {
"type": "stdio",
"command": "node",
"args": ["/usr/local/lib/node_modules/@anthropic/mcp-server-brave-search/dist/index.js"],
"env": {
"BRAVE_API_KEY": "${BRAVE_API_KEY}"
}
}
}
}Environment variables (like ${GITHUB_TOKEN}) are resolved from your shell environment at runtime.
Step 4: Discover Available Tools#
Once connected, you can see what tools each MCP server exposes:
# List all tools from a server
mcporter tools list filesystem
# List all tools from all configured servers
mcporter tools list --allExample output for the filesystem server:
filesystem:
read_file Read the contents of a file at a given path
write_file Write content to a file at a given path
list_directory List files and directories at a given path
create_directory Create a new directory
move_file Move or rename a file
search_files Search for files matching a pattern
get_file_info Get metadata about a file
Step 5: Test Tools Directly#
Before relying on the agent to call tools, test them directly with mcporter:
# Test the read_file tool
mcporter call filesystem read_file \
--input '{"path": "/Users/kumareth/Documents/test.txt"}'
# Test the GitHub list_repos tool
mcporter call github list_repos \
--input '{"owner": "yourusername", "type": "public"}'
# Test brave search
mcporter call brave-search search \
--input '{"query": "OpenClaw DenchClaw", "count": 5}'If a tool works via mcporter call, it will work when your agent calls it too.
Step 6: Use MCP Tools in Agent Sessions#
Once servers are configured, your agent automatically has access to their tools. Just ask:
Search the web for recent news about DenchClaw using Brave Search.
Read the file at ~/Documents/client-contracts/acme.pdf and summarize the key terms.
List all open issues in the github.com/yourorg/yourrepo repository
and add any that mention "bug" to my CRM as tasks.
The agent queries the available MCP servers, discovers the relevant tools, and calls them as needed. You don't have to specify which MCP server to use — the agent figures it out from context.
Step 7: Build a Custom MCP Server#
If no existing MCP server covers your use case, you can build one. The MCP SDK makes this straightforward.
Minimal MCP server in Node.js#
// my-mcp-server.js
const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
const server = new Server({
name: 'my-custom-server',
version: '1.0.0',
}, {
capabilities: { tools: {} }
});
// Register a tool
server.setRequestHandler('tools/list', async () => ({
tools: [{
name: 'get_crm_stats',
description: 'Get summary statistics from the CRM database',
inputSchema: {
type: 'object',
properties: {},
required: []
}
}]
}));
server.setRequestHandler('tools/call', async (request) => {
if (request.params.name === 'get_crm_stats') {
// Call your database, API, or service
const stats = await getCRMStats();
return {
content: [{
type: 'text',
text: JSON.stringify(stats, null, 2)
}]
};
}
throw new Error(`Unknown tool: ${request.params.name}`);
});
async function getCRMStats() {
// Example: query DuckDB
const { execSync } = require('child_process');
const result = execSync(`duckdb ~/.openclaw-dench/workspace/workspace.duckdb \
"SELECT COUNT(*) as contacts FROM objects WHERE type='contact'"`);
return { contacts: parseInt(result.toString().trim()) };
}
const transport = new StdioServerTransport();
server.connect(transport);Register it in mcporter:
mcporter config add my-crm-stats \
--command "node /path/to/my-mcp-server.js"MCP vs Skills: When to Use Each#
DenchClaw has two ways to extend agent capabilities: Skills (markdown files) and MCP servers. Here's when to use each:
| Skills | MCP Servers | |
|---|---|---|
| Best for | Instructions and workflows that use existing tools | New tools that don't exist in OpenClaw's built-ins |
| How defined | Markdown file | Code (Node.js, Python, binary) |
| Complexity | Low — just write instructions | Higher — requires coding |
| Sharing | Easy — just copy the markdown | Requires packaging and distribution |
| External integrations | Via exec + curl | Via dedicated server code |
| Real-time data | Fetched per-request | Can maintain connections |
For most integrations, a skill is sufficient. MCP makes sense when you need a persistent connection, complex bidirectional communication, or capabilities that can't be expressed as shell commands.
Security Considerations#
MCP servers run with your user's permissions. A filesystem MCP server can read and write files. A database server can modify records. Audit what each server can do before connecting it.
Review server source code. Before installing a community MCP server, review its source. The --input you pass gets executed server-side — malicious servers could exfiltrate data.
Use environment variables for credentials. Never hardcode API keys in the MCP config. Use ${ENV_VAR} references as shown above.
Restrict filesystem access. When configuring the filesystem server, pass a specific directory path, not / or ~. The server will only operate within that root.
FAQ#
Q: Does DenchClaw support all MCP servers, or just specific ones? A: DenchClaw implements the standard MCP client protocol, so it works with any spec-compliant MCP server. Servers that deviate from the spec may need minor configuration.
Q: Can I run multiple MCP servers simultaneously?
A: Yes. Each server runs as a separate process. Configure as many as you need in mcp-config.json.
Q: How does the agent know which MCP tool to use? A: The agent sees a list of all available tools (from both built-in capabilities and MCP servers) and chooses based on context and tool descriptions. Clear, descriptive tool names matter.
Q: Can MCP servers call back into OpenClaw? A: Not directly in the standard protocol. MCP is currently a request-response model where the agent calls the server. For bidirectional communication, use the webhook pattern described in the webhook handling guide.
Q: Is there a performance overhead to MCP? A: Minimal for stdio servers — a few milliseconds of process startup. HTTP servers have network overhead. For latency-sensitive tools, prefer stdio servers running locally.
Ready to try DenchClaw? Install in one command: npx denchclaw. Full setup guide →
