openclaw-mcp-termux
openclaw-mcp-termux
An MCP (Model Context Protocol) server running natively on Android via Termux. Bridges Claude.ai or Claude Desktop to a locally-running OpenClaw gateway using 10 consolidated tools optimized for the God Orchestrator pattern.
Architecture
Sakaar (vision/intent)
→ Claude (compiler — frontier inference)
→ MCP Bridge (this server — 10 tools)
→ OpenClaw Gateway (127.0.0.1:18789)
→ Agents: Tani (main), Alan (coding), Rachel (rachel)The MCP bridge is the transport layer between Claude's compiler and the OpenClaw execution agents. It provides three capabilities: dispatch (send tasks to agents), observe (monitor agent state), and control (intervene on running sessions).
Transport:
stdioover SSH — Claude Desktop connects viassh flip "node dist/index.js"Streamable HTTP— Claude.ai via Cloudflare Tunnel
Key design decisions:
SSH-first CLI — all
openclawCLI calls route throughssh proot(~200ms) instead of the wrapper script (2-10s cold start)Filesystem-first reads — config/session/log reads hit files directly (~16ms) instead of shelling out to the CLI
Env-based auth — gateway token from
.envviadotenv, resolved relative to script location (handles SSH cwd != project dir)No Docker — runs natively in Termux Node.js, OpenClaw runs in proot-Ubuntu
10 Tools
Agent Orchestration
Tool | Description |
| Send tasks to agents. Three modes: |
| Multi-view observation. Views: |
| Session management: abort, steer, compact, reset. Returns 404 for all actions — gateway doesn't expose session control via |
File Operations
Tool | Description |
| Read full or partial file contents. Supports |
| Create or overwrite files. Auto-creates parent directories. |
| Replace a unique string in a file with another. No shell escaping. |
| Recursive directory search for literal string patterns. Case-insensitive. |
System & CLI
Tool | Description |
| OpenClaw CLI operations. |
| Execute arbitrary shell commands on the Termux device. Safety blocklist for destructive patterns. |
| Device snapshot: RAM, CPU load, disk, gateway reachability, active processes. |
Quick Start (Local stdio via SSH)
Clone & Build on the device
git clone https://github.com/schmosbyy/openclaw-mcp-termux.git cd openclaw-mcp-termux npm install && npm run buildCreate
.envin the project rootcat > .env << 'EOF' OPENCLAW_URL=http://127.0.0.1:18789 OPENCLAW_GATEWAY_TOKEN=your-gateway-bearer-token OPENCLAW_HOOK_SECRET=your-hook-secret EOFConfigure Claude Desktop (
claude_desktop_config.json){ "mcpServers": { "flip": { "command": "/usr/bin/ssh", "args": [ "flip", "/data/data/com.termux/files/usr/bin/node /data/data/com.termux/files/home/openclaw-mcp-termux/dist/index.js" ] } } }
No inline env vars needed — .env is loaded from the project directory automatically.
Remote HTTP Mode (Claude.ai)
Start the bridge
bash scripts/gen-token.sh # generates BRIDGE_TOKEN bash scripts/start-tmux.sh # persistent backgroundExpose via Cloudflare
cloudflared tunnel --url http://127.0.0.1:3000Add the tunnel URL +
BRIDGE_TOKENin Claude.ai → Settings → Integrations.
Environment Variables
Variable | Required | Description |
| Yes | Gateway bearer token from |
| Yes | Webhook secret for |
| No | Gateway URL (default |
| HTTP mode | Auth token for remote Claude.ai connections |
| No | HTTP timeout (default 660000ms) |
| No |
|
Project Structure
src/
├── index.ts # Entry point, transport selection, .env loading
├── server.ts # MCP tool registry (10 tools) + dispatch router
├── transport.ts # stdio vs StreamableHTTP transport
├── auth.ts # Bearer token auth for HTTP mode
├── gateway/
│ ├── client.ts # GatewayClient — HTTP API + SSH CLI
│ └── types.ts # TypeScript response interfaces
└── tools/
├── agent_dispatch.ts # Send to agents (async/sync/spawn)
├── agent_query.ts # Observe agents (health/sessions/actions/logs/history)
├── agent_control.ts # Control sessions (abort/steer/compact/reset)
├── openclaw_cli.ts # CLI ops (config_get via FS, config_set via SSH)
├── file_read.ts # Read files
├── file_write.ts # Write files
├── file_edit.ts # Edit files (string replace)
├── file_search.ts # Search files
├── shell_exec.ts # Shell commands
└── system_health.ts # Device health snapshotTroubleshooting
Issue | Resolution |
| Run |
Server dies after screen lock | Run via |
Auth failures | Check |
Gateway unreachable | Start it on the device: |
| SSH tunnel dies with gateway. Restart gateway to restore. |
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/schmosbyy/openclaw-mcp-termux'
If you have feedback or need assistance with the MCP directory API, please join our Discord server