How to Use MCPs with OpenClaw for Automation Workflows
I wanted to automate a simple workflow: find a recipe online and add all the ingredients to my Kroger shopping cart. This should be straightforward, but connecting APIs manually is tedious. Each service has different authentication, different endpoints, different error handling.
OpenClaw’s MCP (Model Context Protocol) support changed this. Instead of writing custom integrations for each API, I could use standardized MCP servers that handle the connection complexity. Here’s how I set it up and what I learned along the way.
What MCP Actually Does
MCP provides a standard protocol for connecting AI assistants to external services. Think of it like a universal adapter - instead of writing custom code for each API, you connect an MCP server that translates between OpenClaw and the external service.
The architecture looks like this:
OpenClaw <---> MCP Server <---> External API ^ | | v Skills Tools & ResourcesOpenClaw communicates with MCP servers using JSON-RPC. The server exposes tools (functions OpenClaw can call) and resources (data OpenClaw can read). OpenClaw decides when to use which tool based on your request.
Setting Up MCP with OpenClaw
I started by checking my OpenClaw configuration. MCP servers are defined in a settings file.
Step 1: Locate the Configuration File
The configuration lives in different places depending on your system:
# macOS~/.config/openclaw/settings.json
# Linux~/.config/openclaw/settings.json
# Windows%APPDATA%\openclaw\settings.jsonOpen this file in your text editor. If it doesn’t exist, create it.
Step 2: Add an MCP Server
I added the filesystem MCP server first to test the connection:
{ "mcpServers": { "filesystem": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-filesystem", "/Users/yourname/projects" ] } }}The key fields are:
command: The executable that runs the MCP serverargs: Arguments passed to that command
Step 3: Restart OpenClaw
After saving the configuration, restart OpenClaw to load the new MCP server. You should see the server listed in OpenClaw’s MCP panel.
Real Example: Kroger Shopping Integration
Now for the actual use case. I needed to connect Kroger’s API so OpenClaw could add items to my cart.
What Didn’t Work Initially
I tried using a community-built Kroger MCP server from GitHub. It installed fine, but authentication failed every time. The error message was vague: “Authentication error” with no details.
# This installed but didn't worknpx @example/mcp-server-krogerThe problem was OAuth token refresh. Kroger’s API requires refreshing tokens periodically, and the community server didn’t handle this correctly.
What Worked: Using N8N as a Bridge
Instead of debugging the MCP server, I used N8N (a workflow automation tool) as an intermediate layer. N8N has excellent Kroger integration and can expose webhooks.
OpenClaw --> MCP Server (webhook) --> N8N --> Kroger APII created a simple webhook endpoint in N8N:
{ "nodes": [ { "type": "Webhook", "parameters": { "path": "add-to-cart", "method": "POST" } }, { "type": "Kroger", "parameters": { "operation": "addToCart", "items": "={{ $json.ingredients }}" } } ]}Then I created a minimal MCP server that calls this webhook:
#!/usr/bin/env python3import jsonimport sysimport requests
def handle_request(request): if request["method"] == "tools/call": if request["params"]["name"] == "add_to_cart": ingredients = request["params"]["arguments"]["ingredients"] response = requests.post( "http://localhost:5678/webhook/add-to-cart", json={"ingredients": ingredients} ) return {"content": [{"type": "text", "text": response.text}]}
return {"error": "Unknown method"}
# MCP protocol handlingfor line in sys.stdin: request = json.loads(line) response = handle_request(request) print(json.dumps(response), flush=True)This worked. OpenClaw could now call the add_to_cart tool, which triggers N8N, which handles Kroger authentication properly.
Testing the Integration
I tested with a real request:
Find a chicken tortilla soup recipe and add all ingredients to my cartOpenClaw:
- Used web search to find a recipe
- Extracted the ingredient list
- Called the MCP
add_to_carttool - N8N added items to my Kroger cart
The whole workflow took about 15 seconds.
Troubleshooting Common Issues
MCP Server Won’t Start
If the server doesn’t appear in OpenClaw’s MCP panel:
# Run the server command manually to see errorsnpx @modelcontextprotocol/server-filesystem /path/to/allow
# Check if the command exists in PATHwhich npxCommon fixes:
- Ensure Node.js is installed (for npx-based servers)
- Check file paths are absolute, not relative
- Verify the executable has proper permissions
Authentication Failures
For API-based MCP servers:
{ "mcpServers": { "myapi": { "command": "npx", "args": ["-y", "@example/mcp-server"], "env": { "API_KEY": "your-api-key-here" } } }}Never hardcode API keys in the args array. Use the env object instead.
Zoho Integration Issues
I also tried connecting Zoho CRM through MCP. The official Zoho MCP server had problems with pagination on large datasets. The fix was to use the REST API directly through a custom MCP server:
def list_contacts(page=1, per_page=50): """Handle Zoho pagination manually""" all_contacts = [] while True: response = zoho_api.get_contacts(page=page, per_page=per_page) all_contacts.extend(response["data"]) if not response["info"]["more_records"]: break page += 1 return {"contacts": all_contacts}Managing Multiple MCP Servers
OpenClaw supports running multiple MCP servers simultaneously. My production config looks like:
{ "mcpServers": { "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/projects"] }, "github": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" } }, "webhook-bridge": { "command": "python", "args": ["/home/mcp-servers/webhook-server.py"] } }}Each server runs as a separate process. OpenClaw handles routing requests to the appropriate server based on tool names.
Performance Considerations
MCP adds a layer of indirection. In my testing:
- Simple tool calls (like file read): 50-100ms overhead
- Complex API calls (like Kroger cart update): dominated by API latency, MCP overhead negligible
The overhead comes from:
- JSON-RPC message serialization
- Process communication (stdin/stdout)
- Permission checks
For most automation tasks, this overhead is acceptable. If you need sub-millisecond response times, MCP might not be the right tool.
Security Best Practices
MCP servers run with the same permissions as OpenClaw. This means:
- Filesystem MCP can read/write any path you allow
- API MCP servers have access to your credentials
Limit access by:
{ "mcpServers": { "filesystem": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-filesystem", "/home/projects/safe-directory" // Only this directory ] } }}Never allow access to sensitive directories like ~/.ssh or ~/.config where credentials are stored.
Skills vs MCP: When to Use Which
OpenClaw has both Skills and MCP servers. They serve different purposes:
| Feature | Skills | MCP Servers |
|---|---|---|
| Purpose | Built-in capabilities | External integrations |
| Location | Inside OpenClaw | Separate process |
| Customization | Limited | Full control |
| Use case | Common tasks (file ops, search) | API integrations, custom tools |
I use Skills for file operations and web search (built-in). I use MCP for API integrations that Skills don’t cover.
Key Takeaways
- MCP provides standardized API connections - you write one integration, it works with any MCP-compatible client
- N8N bridges work well for complex auth flows - don’t fight authentication issues in MCP directly
- Configuration lives in
settings.json- add servers to themcpServersobject - Test MCP servers manually first - run the command outside OpenClaw to debug errors
- Security matters - only allow access to necessary directories and APIs
The recipe-to-cart workflow now runs daily. OpenClaw finds recipes based on what’s in season, and automatically populates my shopping cart. MCP made this possible without maintaining custom API code.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
- 👨💻 Model Context Protocol Specification
- 👨💻 OpenClaw MCP Documentation
- 👨💻 Reddit Discussion: OpenClaw MCP
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments