MCP Client Skill
Purpose
OpenClaw versions before native MCP client support (e.g. 2026.3.13) do not expose configured MCP servers as agent tools. This skill bridges that gap by spawning MCP server processes directly and speaking JSON-RPC over stdio.
When to use
- User asks to use an MCP server (desktop-commander, playwright, memory, etc.)
openclaw mcp listreturns "unknown command" or config path not found- Native MCP tool calling is unavailable in the current runtime
When NOT to use
- Native MCP support is already working (
openclaw mcp listshows servers) - The task can be done with existing agent tools (exec, read, edit, browser)
Workflow
1. Discover configured servers
Read ~/.openclaw/openclaw.json (JSON) or ~/.openclaw/config.yaml (YAML)
and extract mcp.servers:
{
"mcp": {
"servers": {
"desktop-commander": {
"command": "node",
"args": ["/Users/deepak/code/mcps/desktop-commander/dist/index.js"]
},
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"],
"env": { "MEMORY_FILE_PATH": "/Users/deepak/.memory/memory.json" }
}
}
}
}
2. Spawn the server process
Use scripts/mcp-call.js (see below) or inline Node.js to:
- Spawn the process with
command+args - Set any
envvariables - Send
initializerequest (JSON-RPC) - Send
tools/listto discover available tools - Send
tools/callto invoke the desired tool - Parse the result and return to user
- Kill the process
3. Handle responses
MCP servers return results as JSON-RPC responses. Tool results are in:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"content": [{"type": "text", "text": "..."}],
"isError": false
}
}
Extract result.content[0].text for text output, or handle isError: true.
Helper Script
Use scripts/mcp-call.js for reliable MCP communication:
node scripts/mcp-call.js <server-name> <tool-name> '<json-args>'
Examples:
# Read a file via desktop-commander
node scripts/mcp-call.js desktop-commander read_file '{"path":"/Users/deepak/code/mcps/desktop-commander/package.json","length":10}'
# Read memory graph
node scripts/mcp-call.js memory read_graph '{}'
# Search memory nodes
node scripts/mcp-call.js memory search_nodes '{"query":"physics"}'
The script:
- Reads server config from
~/.openclaw/openclaw.json - Spawns the process, sends initialize + tools/call
- Outputs clean result text (or JSON if
--json) - Exits with code 1 on error
Memory MCP Server Tools
The @modelcontextprotocol/server-memory exposes a knowledge graph:
| Tool | Purpose |
|---|---|
create_entities |
Add entities with type + observations |
create_relations |
Link entities with relation types |
add_observations |
Append observations to existing entities |
read_graph |
Dump the full graph |
search_nodes |
Search entities by name/observation |
open_nodes |
Get specific entities by name |
delete_entities |
Remove entities |
delete_observations |
Remove specific observations |
delete_relations |
Remove relations |
Security Notes
- Only spawn servers from trusted config (user-owned
~/.openclaw/) - Respect
allowedDirectoriesin desktop-commander — it will reject paths - Do not log or echo MCP server env vars (may contain tokens)
- Kill processes after use to avoid zombie MCP servers
Current Limitations
- Stdio transport only (no SSE/streamable-http support in workaround)
- One-shot calls (no persistent MCP connection across agent turns)
- Process spawn overhead per call (~1-2s for feature flag fetch)
- Tool schemas are discovered dynamically, not cached
Future
When OpenClaw natively supports MCP clients (openclaw mcp list works),
this skill becomes obsolete. Transition path: remove skill, rely on native
bundle-mcp tool profile.
