This guide walks you through protecting your MCP tool server with Aegis when using OpenClaw as your AI agent framework.
Time: ~10 minutes
- Node.js >= 18 (for
npxcommands) or download the binary - A running MCP tool server you want to protect
- OpenClaw installed with
mcporter(npm install -g mcporter) - OpenClaw gateway running (
openclaw gateway)
Before connecting your own server, try the interactive demo to see all Aegis features in action.
npx aegis-mcp-proxy demoThis starts a mock MCP server and Aegis proxy with a pre-configured policy. The terminal prints curl commands you can try.
| Command | What Happens |
|---|---|
tools/list |
5 mock tools discovered, admin_reset hidden by ACL — only 4 visible |
echo |
Passes through with no restrictions |
get_weather x4 |
First 3 succeed, 4th blocked by rate limit (3/min) |
publish_post |
Blocks until you approve via the management API |
list_posts |
Bypasses FIFO queue, returns immediately |
audit/logs |
Shows full audit trail of all operations |
# Health check
curl localhost:18070/health
# View audit logs
curl 'localhost:18070/api/v1/audit/logs?limit=5' | jqWhen you're done exploring, press Ctrl+C to stop the demo.
aegis setup
# or: npx aegis-mcp-proxy setupFollow the prompts:
- Backend URL — Enter your MCP server address (e.g.,
http://localhost:9200/mcp). Aegis connects and discovers available tools. - Per-tool policies — Review smart defaults based on tool names. Read-only tools get unlimited access; write/publish tools get rate limits + approval; dangerous tools are denied.
- Agent type — Select OpenClaw (auto-detected if installed). The wizard injects the Aegis proxy URL into
~/.openclaw/workspace/config/mcporter.json. - Approval notifications (optional) — Configure a Feishu/Lark or generic webhook URL for approval request delivery. The wizard auto-detects your local IP for callback URLs.
./aegis config/aegis.yaml
# or: npx aegis-mcp-proxy config/aegis.yamlopenclaw gateway restart
# or if using systemd:
systemctl --user restart openclaw-gateway# Check Aegis health
curl localhost:18070/health
# View audit log — you should see tool calls after interacting with OpenClaw
curl 'localhost:18070/api/v1/audit/logs?limit=5' | jqThe setup wizard performed these changes:
-
Created
config/aegis.yaml— Aegis policy config with your backend, agent, and tool policies. -
Injected an entry into
~/.openclaw/workspace/config/mcporter.json:{ "mcpServers": { "your-backend": { "baseUrl": "http://localhost:18070/agents/openclaw-your-backend/mcp" } } }A
.bakbackup was created before modification. -
Result: OpenClaw calls mcporter, which calls Aegis instead of your MCP server directly. Aegis enforces ACL, rate limits, approval, and audit logging, then forwards to the backend.
Feishu/Lark → OpenClaw → mcporter → Aegis (:18070) → Your MCP Server
OpenClaw uses mcporter to call MCP tools. The LLM must produce the correct mcporter call syntax, which can be tricky — common mistakes include missing the call subcommand, incorrect quoting of JSON arguments, or confusing server names.
Create a wrapper script that simplifies the call syntax, then describe it in a SKILL.md so the LLM knows how to use it.
1. Create a wrapper script (~/.openclaw/workspace/tools/my-backend.sh):
#!/bin/bash
# Usage: my-backend.sh <tool_name> <json_args>
# Example: my-backend.sh get_weather '{"city":"Beijing"}'
mcporter call my-backend "$1" "$2"chmod +x ~/.openclaw/workspace/tools/my-backend.sh2. Describe it in SKILL.md (~/.openclaw/workspace/SKILL.md):
## MCP Tools (my-backend)
Call tools using the wrapper script:
bash ~/.openclaw/workspace/tools/my-backend.sh <tool_name> '<json_args>'
Available tools:
- get_weather: Get weather for a city. Args: {"city": "string"}
- publish_post: Publish a post (requires approval). Args: {"title": "string", "content": "string"}3. Also add to TOOLS.md (~/.openclaw/workspace/TOOLS.md) if your agent reads tool descriptions from there.
- Policy Configuration Guide — Fine-tune ACL, rate limits, approval rules, and queue settings
- Management API — Query audit logs, manage pending approvals, check rate limit usage
- Hot reload — Edit
aegis.yaml, thenPOST /api/v1/config/reload— no restart needed - API authentication — Set
server.api_tokenin your config to protect management endpoints in production