Mobile MCP Command Bridge

Mobile MCP Command Bridge

A controlled local program execution bridge for mobile MCP clients, exposing structured tools for running programs, file operations, and network diagnostics without shell access.

Category
访问服务器

README

MCP Command Bridge

Full container control bridge for mobile MCP clients (RikkaHub, etc.).

This project exposes MCP tools that let an AI agent run shell commands, execute programs, manage files, make HTTP requests, and install packages inside a Docker container sandbox. The container IS the sandbox — the agent has full control inside it, with all operations audit-logged and workspace data persisted to the host.

Works on Windows and Linux (VPS). Deploy to a VPS with the one-click script for secure remote access from your phone.

Features

Core Tools

  • run_shell(command) — PREFERRED tool. Execute shell command strings directly via bash -c. Supports pipes (|), redirects (>), chaining (&&, ||), env vars ($HOME), globs (*), and all bash syntax. No need to write scripts to files first.
  • run_program(program, args) — Structured argv execution (shell=False). Use when you need precise control without shell interpretation.
  • run_workspace_script(runtime, path) — Run a script file from the workspace.
  • get_policy() / get_capability_details(name) — Capability discovery for the LLM.

Task Tools

  • HTTP: http_probe(url), fetch_url(url)
  • Network: ping_host, dns_lookup, tcp_probe, trace_route
  • System: system_snapshot()
  • Files: list_files, read_file, write_file, append_file, make_directory

Security & Infrastructure

  • Streamable HTTP MCP server at /mcp (mobile-compatible: no DNS rebinding / Origin checks).
  • Bearer token auth + optional IP allowlist + rate limiting.
  • Environment variable override for token and secrets (MCB_TOKEN, MCB_SECRET_*).
  • Full UTF-8 encoding support — Chinese and other non-ASCII text works out of the box.
  • JSONL audit logging of all operations to data/logs/audit.jsonl (host-mapped).
  • Secret placeholder replacement and masking in outputs and logs.
  • Timeout and output truncation.

Data Persistence

Container path Host path Purpose
/app/agent_workspace data/workspace/ Agent's writable workspace
/app/projects data/projects/ Cloned repos and project files
/app/logs/audit.jsonl data/logs/audit.jsonl Audit log of all operations

Files saved outside these paths are ephemeral and will be lost on container restart.

Install

pip install -e .

Configure

Start from config.example.yaml (LAN) or config.vps.yaml (VPS).

Important fields:

  • server.token: required Bearer token (or set MCB_TOKEN env var).
  • server.allowed_origins: accepted browser/client origins.
  • server.ip_allowlist: optional IP restriction (empty = allow all).
  • server.rate_limit_per_minute: app-level rate limit (0 = unlimited).
  • server.compact_toolset: expose compact grouped tools instead of many granular tools.
  • execution.allowed_roots: directories commands may run inside.
  • execution.writable_roots: directories MCP clients may create and edit files inside.
  • programs.<name>.enabled: whether a program is callable.
  • secrets: values available through ${NAME} placeholders (or MCB_SECRET_<NAME> env vars).

Run

python -m mcp_command_bridge.server --config config.example.yaml

The default sample config listens on:

http://127.0.0.1:8765/mcp

For LAN use, keep server.host: "0.0.0.0" in the config and connect from the phone to:

http://<computer-lan-ip>:8765/mcp

VPS Deployment

Deploy to a VPS with Docker — port 8765 is exposed for your own reverse proxy setup:

git clone https://github.com/XD06/MCP_Command_Bridge.git
cd MCP_Command_Bridge
sudo bash deploy/deploy.sh --domain mcp.yourdomain.com

The script installs Docker, generates a strong token, builds the container, and exposes port 8765. A reference Nginx config (TLS + rate limiting + security headers) is at deploy/nginx/mcp-command-bridge.conf — set up your own Nginx/Caddy for TLS and domain routing. Data (workspace, audit logs) is mapped to the host for easy access.

See docs/vps-deployment.md for full details.

Send:

Authorization: Bearer <server.token>

Test

python -m unittest discover -s tests

Current result:

95 tests passed

Security Model

Container Full-Control Mode (VPS)

In VPS/Docker deployment, the container IS the sandbox:

  • run_shell and run_program are exposed with no restrictions on URLs, methods, paths, or arguments.
  • The agent can apt-get install, pip install, git clone, write scripts, and execute them.
  • Isolation comes from Docker resource limits, not application-level restrictions.
  • All operations are audit-logged to data/logs/audit.jsonl (host-mapped).

Restricted Mode (LAN)

run_program and run_shell are hidden by default (server.expose_advanced_tools: false). File tools are restricted to execution.writable_roots. This mode is for local development.

Encoding

All subprocess I/O uses hardcoded UTF-8 encoding (encoding="utf-8", errors="replace"). The Docker container sets LANG=C.UTF-8, LC_ALL=C.UTF-8, PYTHONUTF8=1, PYTHONIOENCODING=utf-8. Chinese and other non-ASCII text works without errors.

Tool Selection Guide

  • run_shell(command) — PREFERRED for most tasks. Pipes, redirects, chaining, inline code.
  • http_probe(url) / fetch_url(url) — Quick HTTP status / text fetch.
  • ping_host, dns_lookup, tcp_probe, trace_route — Network diagnostics.
  • system_snapshot() — OS, IP, Python version info.
  • write_file / read_file — Create and read workspace files.
  • run_workspace_script(runtime, path) — Run a workspace script file.
  • run_program(program, args) — Precise argv control without shell interpretation.

get_policy() returns a capability summary. get_capability_details(name) returns detailed rules.

server.require_capability_preflight: true forces models to call get_capability_details(name) before task tools in that capability can run.

With server.compact_toolset: true, the default tool surface is:

get_policy
get_capability_details
system_snapshot
http_request
network_check
workspace
run_workspace_script

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选