跳到正文
DEV Community· Lmeng·· 3 小時前AI 評分51

nano-mcp-termux:可在 Android Termux 運行的零依賴 MCP 伺服器

Showdev: A zero-dependency MCP server that runs on Android Termux

AI 導讀

Lmeng 開發了 nano-mcp-termux,一個只用 Python 標準庫、可在 Android Termux 運行的單檔 MCP 伺服器,提供 13 個涵蓋檔案系統、shell、網絡和裝置感測器的工具。

正文

Here's the English version with the AI disclosure updated as requested:


Last week I tried to run an MCP (Model Context Protocol) server on my phone — a Xiaomi 23013RK75C (Android 15, aarch64, 6 GB RAM) — and hit a wall: every existing server either required Docker (no systemd on Termux), pulled in heavy dependencies, or crashed on ARM64 due to syscall emulation issues.

So I wrote a single-file MCP server with zero external dependencies. The same codebase runs on Termux, PRoot, Raspberry Pi, and desktop Linux:

· One Python file (~300 lines), stdlib only
· Implements the full MCP protocol (initialize, tools/list, tools/call, etc.)
· Starts in under 1 second, stays under 2 MB installed
· Ships with 13 tools covering filesystem, shell, network, and device sensors

These cover the operations I actually use on a phone. Here's how to get it running in about 3 minutes:

pkg install python git
pip install git+https://github.com/Lmeng486/nano-mcp-termux.git
python -m nano_mcp_termux --transport stdio

Point any MCP-compatible client (Claude Desktop, Cursor, Cline, Operit) at it as a stdio transport. All 13 tools appear immediately.

What makes it different:

Standard servers nano-mcp-termux
Runtime CPython ≥3.10 + pip deps CPython 3.12.3, stdlib only
Size 50-200 MB < 2 MB
Boot time 2-5 seconds < 1 second
Android Broken Verified on Android 15 / Termux
Protocol tests Pass Pass

I also maintain a companion repository — awesome-termux-mcp — a curated directory of every MCP server I could get working under Termux, plus two real-world reports: one measuring context usage when the LLM is 15 MB away instead of 15 ms, and one on how MCPs actually break at the edge (spoiler: it's almost never the protocol).

Known issues: file watching uses polling because Termux doesn't ship inotify-dfs compatible kernel headers — it works, but isn't push-based. SQLite-backed sessions aren't in yet; persistence is via flat JSON files for now. No Windows support planned (focus is Linux + Android).

Developers who hack on mobile or embedded Linux: what breaks in your environment? I want this to be a useful baseline, not just a toy. Open to PRs and battle-tested patches.

GitHub: github.com/Lmeng486/nano-mcp-termux
Package: pip install nano-mcp-termux or run the file directly.

來源:DEV Community · dev.to