nano-mcp-termux
Provides tools for interacting with the Android/Termux environment, including retrieving device status (battery, storage, architecture, memory), resolving and adapting Android filesystem paths (e.g., /sdcard, /storage/emulated/0, noexec mounts), and reporting Phantom Process Killer risk on Android 12+.
nano-mcp-termux
Zero-dependency, single-file MCP server for AI agents, natively running on Termux (Android), Raspberry Pi, and Linux.
🚀 Quick Start
Local (Termux / Linux)
cd /path/to/nano-mcp-termux
python3 nano_mcp_termux.pyDocker
docker build -t nano-mcp-termux .
docker run -i --rm nano-mcp-termuxHealth check (one-shot, no MCP handshake)
python3 nano_mcp_termux.py --healthRelated MCP server: Python MCP Toolkit Server
🛠️ Features
✅ Zero-dependency: No external packages required
✅ Single-file: All logic in one Python script
✅ Cross-platform: Works in Termux (Android), on Raspberry Pi, Linux, and inside Docker
✅ Container-ready: Dockerfile at repo root for Glama introspection
✅ Standard stdio framing: Newline-delimited JSON-RPC (official MCP transport)
✅ Version negotiation: Echoes client
protocolVersion(2024-11-05 / 2025-06-18 / 2025-11-25), falls back to highest supported✅ Graceful degradation:
device_statusnever fails; unavailable inputs are marked, not crashed✅ [lifecycle] No orphaned processes: every command runs in its own process group; timeouts kill the whole tree (
SIGTERM→SIGKILL), never just the shell✅ [lifecycle] Self-terminating: parent-process watchdog + stdin-EOF detection + optional idle timeout, so a dead client never leaves a zombie server behind
✅ [lifecycle] Phantom Process Killer aware: reports Android 12+ child-count risk with concrete mitigations
✅ [paths] Android/Termux path adapter: resolves
/sdcard↔/storage/emulated/0↔$HOME/storage/shared, detectsnoexecmounts, case-insensitive filesystems, and shell-quoting hazards
🧩 Tools Overview
Tool | Description |
| Aggregate device info: battery / storage / arch / memory (degraded fields marked unavailable) |
| Runtime health: pid/ppid/env, uptime, request counters, live children, reaping policy, RSS, Phantom Process Killer risk |
| Resolve an Android/Termux path: canonical form, mount point, |
| Environment profile: runtime class, |
🔗 Protocol Surface
Method | Behavior |
| Echoes supported client version (2024-11-05 / 2025-06-18 / 2025-11-25), else responds with highest supported per MCP spec; declares |
| Silent (no response) |
| Returns |
| Returns tool catalog |
| Returns |
Unknown method / tool |
|
Malformed JSON |
|
🔄 Why 1.1.0: the orphan-process bug
Version 1.0.0 ran commands with subprocess.run(..., timeout=...). On timeout,
Python terminates only the direct child — the sh -c wrapper. Anything the
shell had already spawned is reparented to init and survives forever. On
Android that is the exact leak class that trips the Phantom Process Killer
and can get the whole app group killed.
1.1.0 fixes this at the root: commands are spawned with start_new_session=True
and torn down with os.killpg(pgid, SIGTERM) → SIGKILL, so the entire process
tree dies together.
The repository ships a reproducible A/B regression test for it:
python3 test_lifecycle_orphan.py
# current nano_mcp_termux.py leaked_grandchildren=0
# legacy nano_mcp_termux_v10_backup.py leaked_grandchildren=1 <- the bug
# PASS: current server leaves 0 orphaned grandchildren after timeout✅ Tests
python3 test_client.py # 32 protocol / tool / lifecycle assertions
python3 test_lifecycle_orphan.py # orphan-leak A/B regression (1.0.0 vs 1.1.0)⚙️ Environment variables
Variable | Default | Purpose |
|
| Seconds of inactivity before the server exits on its own |
| unset | Set to |
🔗 Links
Original repository: Lmeng486/nano-mcp-termux
Verification report: awesome-termux-mcp
Measured overhead report (this server as subject under test, all numbers from a real device): MCP on Mobile: Measured Overhead Report
This server is designed to pass Glama introspection checks and serve as a lightweight MCP implementation for mobile and edge devices.
This server cannot be deployed
Maintenance
Related MCP Connectors
A simple MCP server built with FastMCP and python
MCP server for AI dialogue using various LLM models via AceDataCloud
MCP server for Hostinger API
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA simple MCP Server with shell execution capabilities that can be run locally with Ngrok tunneling or hosted in an Ubuntu 24 Docker container.4MIT
- AlicenseAqualityDmaintenanceA Python-based MCP server for file operations, web search with fallback, and task management, designed for Termux and extensible via plugins.32GPL 3.0
- AlicenseNot gradedqualityDmaintenanceUltra-lightweight MCP server for Bun with full protocol compliance. Enables building MCP servers with tools, resources, and prompts using minimal dependencies and heap footprint.35,226 npmMIT
- FlicenseNot gradedqualityCmaintenanceA Python MCP server that allows ChatGPT to execute commands on your local PC via a secure Cloudflare tunnel.-