Last month we shared how to set up an AI development assistant using a Mac mini and OpenClaw. But OpenClaw's real power isn't in chatting — it's the MCP plugin system that lets AI call custom tools for genuine automation.
What Is MCP?
MCP (Model Context Protocol) is an open protocol proposed by Anthropic that defines how AI models communicate with external tools. Think of it as "USB for AI" — any MCP-compliant tool can be plugged in and used by AI models instantly.
OpenClaw supports MCP natively, which means you can:
- Write custom tools that let AI read/write databases, call APIs
- Combine multiple tools into workflows
- Trigger complex operations with natural language
Real-World Scenarios
Scenario 1: One-Line Deployments
In our projects, each deployment involves 5-6 steps: pulling code, installing dependencies, building, running database migrations, restarting services, and verifying health checks. Manual execution is error-prone, and rigid scripts lack flexibility.
Custom MCP Tool:
{
"name": "deploy",
"description": "Deploy a project to production",
"parameters": {
"project": { "type": "string", "description": "Project name" },
"branch": { "type": "string", "default": "main" },
"skip_migration": { "type": "boolean", "default": false }
}
}
The implementation is simply an HTTP service or local script that accepts JSON and returns JSON:
# deploy_tool.py
import subprocess
def handle(params):
project = params["project"]
branch = params.get("branch", "main")
steps = [
f"cd /apps/{project} && git pull origin {branch}",
f"cd /apps/{project} && pnpm install --frozen-lockfile",
f"cd /apps/{project} && pnpm build",
]
if not params.get("skip_migration"):
steps.append(f"cd /apps/{project} && pnpm prisma migrate deploy")
steps.append(f"pm2 restart {project}")
results = []
for step in steps:
result = subprocess.run(step, shell=True, capture_output=True, text=True)
results.append({
"command": step,
"success": result.returncode == 0,
"output": result.stdout[-500:] if result.stdout else result.stderr[-500:]
})
if result.returncode != 0:
return {"success": False, "steps": results, "error": "Deployment interrupted"}
return {"success": True, "steps": results}
Once configured in OpenClaw, conversations look like this:
Me: "Deploy the website project using the release branch, skip migrations"
OpenClaw: [calls deploy tool] "Deployment complete! All 5 steps succeeded, service restarted."
Scenario 2: Intelligent Log Analysis
When production breaks, the most painful part is sifting through logs. We built a log query tool that lets AI do the analysis:
# log_query_tool.py
def handle(params):
service = params["service"]
minutes = params.get("minutes", 30)
level = params.get("level", "error")
logs = read_pm2_logs(service, minutes, level)
return {
"service": service,
"time_range": f"Last {minutes} minutes",
"total_entries": len(logs),
"logs": logs[:50] # Limit entries to avoid token overflow
}
Actual conversation:
Me: "Any errors in the API service in the last hour? If so, analyze the cause."
OpenClaw: [calls log_query tool]
"Found 3 error entries, all database connection timeouts.
Concentrated between 14:30-14:35, coinciding with MySQL slow queries.
Recommend checking if a bulk data import was running during that period."
AI doesn't just search logs — it correlates context to provide analysis. That's far more powerful than grep.
Scenario 3: Scheduled Health Checks
Combined with OpenClaw's scheduling feature, we set up automatic daily inspections at 9 AM:
# health_check_tool.py
import requests
import psutil
def handle(params):
checks = {}
services = {"api": 3001, "web": 3000, "admin": 3002}
for name, port in services.items():
try:
resp = requests.get(f"http://localhost:{port}/health", timeout=5)
checks[name] = {"status": "healthy", "response_ms": resp.elapsed.microseconds // 1000}
except Exception as e:
checks[name] = {"status": "down", "error": str(e)}
checks["system"] = {
"cpu_percent": psutil.cpu_percent(),
"memory_percent": psutil.virtual_memory().percent,
"disk_percent": psutil.disk_usage('/').percent
}
return checks
Every morning on Telegram:
OpenClaw: "Good morning! Daily health report:
✅ API service healthy (23ms response)
✅ Web service healthy (15ms response)
✅ Admin service healthy (18ms response)
💻 System: CPU 12%, Memory 45%, Disk 38%
All systems normal. Have a great day!"
MCP Tool Development Tips
1. Keep Tools Single-Purpose
Each tool does one thing. Don't build an "all-in-one ops tool" — split into deploy, log_query, health_check, db_backup, etc. AI will compose them on its own.
2. Return Structured Data
Tools return JSON; let AI handle the human-friendly formatting:
# Good: structured data
return {"cpu": 45.2, "memory": 67.8, "disk": 38.1}
# Avoid: pre-formatted strings
return "CPU: 45.2%, Memory: 67.8%, Disk: 38.1%"
3. Limit Output Size
AI context windows are finite. Always cap the number of entries returned:
logs = query_logs(service, minutes)
return {
"total": len(logs),
"showing": min(len(logs), 50),
"logs": logs[:50]
}
4. Enforce Permissions
MCP tools execute system operations — security matters:
ALLOWED_PROJECTS = ["web", "api", "admin"]
def handle(params):
project = params["project"]
if project not in ALLOWED_PROJECTS:
return {"error": f"Operation not allowed for project: {project}"}
# ...
Tool Registration
Register MCP tools in the OpenClaw config:
{
"mcp_servers": [
{
"name": "devops",
"command": "python3",
"args": ["/path/to/mcp_server.py"],
"tools": ["deploy", "log_query", "health_check", "db_backup"]
}
]
}
You can also use community MCP servers:
- mcp-server-sqlite: Let AI query SQLite databases directly
- mcp-server-github: Let AI manage GitHub (create issues, review PRs)
- mcp-server-filesystem: Enhanced file system operations
Why This Matters for Small Teams
If your team has 1-3 developers, OpenClaw + MCP is a perfect fit:
| Scenario | Traditional | OpenClaw + MCP |
|---|---|---|
| Deployment | Run 5 commands manually | "Deploy the website" |
| Log investigation | grep + manual reading | "Any errors? Analyze them" |
| Health monitoring | Self-host Grafana | Auto-push daily reports |
| Database backup | crontab scripts | "Back up the database" |
| SSL certificates | Remember when they expire | Auto-check + early alerts |
Core value: Transform ops knowledge from "in someone's head" and "scattered scripts" into AI-callable tools, lowering the operations barrier for your entire team.
Conclusion
OpenClaw's MCP plugin system essentially gives AI "hands and feet." You define the tools; AI decides when and how to use them.
For small teams, this means:
- Ops doesn't depend on one person — AI knows how to use every tool
- Full audit trail — every AI action is logged in the conversation
- Incremental automation — start with one tool, expand over time
Next time, we'll compare OpenClaw and Claude Code — two very different approaches to AI-assisted programming — to help you choose the right fit.
About the author: ekent, tech lead at ek Studio, focused on AI toolchains and developer productivity.