OpenClaw MCP Server Guide: Connect Any API in Under 10 Minutes
The Model Context Protocol (MCP) is the secret sauce that makes OpenClaw so powerful. While skills provide procedural knowledge, MCP servers provide live connectivity to external data and services. In this guide, I'll show you how to connect any API to your OpenClaw agent in under 10 minutes.
Why MCP Matters for OpenClaw
Before MCP, connecting an agent to a new service meant writing custom tool definitions, handling authentication manually, and managing API responses. MCP standardizes this. Once you have an MCP server running, OpenClaw can automatically discover its tools, resources, and prompts without any additional configuration.
I use MCP servers daily to bridge the gap between my agent's reasoning and the real-world data living in my databases, CRMs, and custom internal tools.
The Anatomy of an MCP Connection
An MCP connection consists of three parts:
- The Server: A process (Node.js, Python, etc.) that implements the MCP spec.
- The Transport: Usually standard input/output (stdio) or HTTP/SSE.
- The Client: OpenClaw, which connects to the server and executes tools.
Step 1: Setting Up Your First MCP Server
The fastest way to get started is using a community-built server or a simple Node.js implementation. Let's build a basic "Weather MCP" server as an example.
# Create a new directory
mkdir my-mcp-server && cd my-mcp-server
# Initialize npm
npm init -y
# Install the MCP SDK
npm install @modelcontextprotocol/sdkNow, create a file named index.js with a basic tool implementation:
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
const server = new Server({
name: "my-weather-server",
version: "1.0.0",
}, {
capabilities: {
tools: {},
},
});
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [{
name: "get_weather",
description: "Get current weather for a city",
inputSchema: {
type: "object",
properties: {
city: { type: "string" },
},
required: ["city"],
},
}],
}));
server.setRequestHandler(CallToolRequestSchema, async (request) => {
if (request.params.name === "get_weather") {
const { city } = request.params.arguments;
// In a real app, you'd fetch from an API here
return {
content: [{ type: "text", text: `The weather in ${city} is sunny, 72°F.` }],
};
}
throw new Error("Tool not found");
});
const transport = new StdioServerTransport();
await server.connect(transport);Step 2: Configuring OpenClaw
To tell OpenClaw about your new server, you need to add it to your openclaw.jsonconfiguration file. This file is typically located at ~/.openclaw/openclaw.json.
{
"mcpServers": {
"weather": {
"command": "node",
"args": ["/absolute/path/to/my-mcp-server/index.js"]
}
}
}Once you save this file, OpenClaw will automatically launch the server whenever it starts up and register the get_weather tool.
Step 3: Usage in Conversations
You don't need to do anything special to use the tool. Just ask your agent!
"What's the weather like in San Francisco?"
OpenClaw will see the get_weather tool in its available toolkit, see that it matches your intent, and call the MCP server to get the data.
Advanced Patterns: Resources and Prompts
MCP is more than just tools. You can also expose Resources (static or dynamic files/data) and Prompts (pre-defined templates).
- Resources: Great for giving the agent access to logs, documentation, or database snapshots.
- Prompts: Useful for standardizing how the agent handles specific tasks like code reviews or bug reports.
Troubleshooting Common Issues
If your MCP server isn't appearing in OpenClaw, check these three things:
- Absolute Paths: Always use absolute paths in
openclaw.json. OpenClaw might run from a different working directory. - Environment Variables: If your server needs API keys, ensure they are passed in the
envsection of the config. - Logs: Check the OpenClaw logs (usually via
openclaw status) to see if the server failed to start.
Frequently Asked Questions
Can I use MCP servers written in Python?
Yes! The MCP protocol is language-agnostic. There is a robust Python SDK available at @modelcontextprotocol/python-sdk. You just need to point OpenClaw to your python script or executable.
How do I handle authentication with external APIs?
Authentication should be handled inside your MCP server. You can pass API keys via environment variables in the openclaw.json config file.
Can one MCP server provide multiple tools?
Absolutely. A single server can register as many tools, resources, and prompts as you need. It's often better to group related functionality into one server.
Is there a limit to how many MCP servers I can connect?
There is no hard limit, but keep in mind that each server consumes some system resources and contributes to the total number of tools available to the agent, which can impact performance if it becomes too large.
Where can I find existing MCP servers to use?
The best place to start is the official MCP GitHub repository, which contains dozens of community-maintained servers for everything from Google Search to Slack.
Internal Links
Ready to dive deeper? Check out these related guides:
- Building Custom Skills: A Complete Guide
- Mastering Browser Automation with OpenClaw
- Security Hardening Guide for Production Agents
The Bottom Line
MCP is the bridge that turns an LLM into an agent. By connecting your own APIs via MCP, you unlock the ability to automate complex workflows that require real-time data access. Start small, connect one API, and watch your agent's utility skyrocket.
Ready to build?
Get the OpenClaw Starter Kit — config templates, 5 production-ready skills, deployment checklist. Go from zero to running in under an hour.
$14 $6.99
Get the Starter Kit →Also in the OpenClaw store
Get the free OpenClaw quickstart guide
Step-by-step setup. Plain English. No jargon.