Building an MCP Bridge for OpenClaw
How we connected OpenClaw agents to the Model Context Protocol ecosystem — and cut document lookup tokens by 99.6%.
The Problem
OpenClaw agents are powerful, but they have a blind spot: they can't talk to MCP servers. The Model Context Protocol is an open standard that lets AI tools access structured data — documents, code, databases, APIs — through a unified interface.
Without MCP support, agents resort to brute-force file reads. Need one section from an 82KB spec? You're dumping the whole thing into the context window. That's ~20,000 tokens burned to find a paragraph.
OpenClaw's native MCP client support is on the roadmap but hasn't shipped yet. We didn't want to wait.
The Solution
We built openclaw-mcp-bridge — a Python CLI that bridges the gap. It spawns MCP servers as child processes and routes tool calls via JSON-RPC 2.0 over stdio. No daemons, no ports, no config servers.
Agents call it through the exec tool, just like any other CLI command.
The bridge is generic — it works with any MCP server that supports stdio transport. Configure your servers in servers.json, and every agent on the machine can use them.
The Numbers
We tested with jDocMunch, an MCP server that indexes documentation by heading hierarchy. We pointed it at our 82KB project spec (1,936 lines, 552 sections across 26 files).
The indexing took 394ms. The sections persist locally, so subsequent lookups are instant. For a fleet of 6 agents that need to reference the same spec, this translates to real cost savings on every cold start.
Quick Start
# Install the bridge + a doc server pip install mcp jdocmunch-mcp git clone https://github.com/cooeyau/openclaw-mcp-bridge.git ln -s $(pwd)/openclaw-mcp-bridge/src/mcp_bridge.py /usr/local/bin/mcp-bridge
mcp-bridge call jdocmunch index_local \ --args '{"path": "/your/project"}' # → 552 sections indexed in 394ms
# Search by natural language mcp-bridge call jdocmunch search_sections \ --args '{"repo":"local/project","query":"auth flow"}' # Get just that section mcp-bridge call jdocmunch get_section \ --args '{"repo":"local/project","section_id":"..."}'
Compatible Servers
Any MCP server that speaks stdio plugs straight in. Here are a few we've tested:
📄 jDocMunch
Navigate docs by heading hierarchy. Retrieve exact sections instead of whole files.
pip install jdocmunch-mcp
🔧 jCodeMunch
Search code by symbol — functions, classes, methods via tree-sitter AST parsing.
pip install jcodemunch-mcp
📊 Any MCP Server
Databases, APIs, knowledge bases — if it speaks MCP over stdio, it works.
servers.json
🔌 Build Your Own
The bridge handles the protocol. You handle the logic.
modelcontextprotocol.io
What's Next
We're watching OpenClaw #4834 for native MCP client support. When it lands, agents won't need the bridge at all — but until then, this gives the community a working solution today.
The bridge is open source under MIT. Fork it, extend it, break it.