Termux MCP Server
Termux MCP Server (Ubuntu PRoot Distro) 📱🤖
这是一个模型上下文协议(MCP)服务器,专为在 Termux 内的 **Ubuntu(PRoot 发行版)**中运行而设计。
在 Termux 中使用 Ubuntu,可以使用标准的预编译二进制包(wheels),这意味着无需漫长的构建等待时间,也不会遇到编译错误(例如 rpds-py 的 Rust 编译器错误),同时仍保留对 Termux API 命令的完整访问权限,以控制你的 Android 设备。
一行命令快速安装
在手机上打开 Termux 应用,然后运行下面这一条命令,即可自动完成仓库克隆、Ubuntu 安装、虚拟环境搭建和自动配置:
curl -sSL https://raw.githubusercontent.com/AbuZar-Ansarii/Termux-MCP-Server/main/setup.sh -o setup.sh && chmod +x setup.sh && ./setup.shRelated MCP server: autoglm-mcp-server
设置指南(共 5 步)
步骤 1:在 Android 上安装 Termux 与 Termux:API
下载 Termux 与 Termux:API 应用。
重要提示:请不要从 Google Play Store 安装它们(这些版本已经过时且有故障)。请从 F-Droid 或 GitHub Releases 下载。
在手机上安装这两个应用。
步骤 2:授予 Android 权限
进入 Android 设置 -> 应用 -> Termux:API。
授予以下权限,以便 AI 能够控制你的设备:
Camera(用于拍摄照片)
Location(用于获取 GPS 坐标)
SMS(用于短信)
Notifications(用于弹出通知)
步骤 3:在 Termux 内运行自动安装脚本
在 Termux 中运行这一行安装命令:
curl -sSL https://raw.githubusercontent.com/AbuZar-Ansarii/Termux-MCP-Server/main/setup.sh -o setup.sh && chmod +x setup.sh && ./setup.sh此命令将自动更新 Termux、安装 proot-distro Ubuntu,并在其中配置 Python 虚拟环境(venv)和立即安装所有依赖项。
步骤 4:配置免密码 SSH 访问
AI 客户端在 PC 上以非交互方式运行,需要自动登录 Termux。
在 Termux 中,设置密码并启动 SSH 服务器:
passwd sshd whoami # Check your username (e.g. u0_a123) ifconfig # Check your phone's IP address (e.g. 192.168.1.50)
2。 在 PC 上,将 SSH 公钥复制到手机:
Windows PowerShell:
cat ~/.ssh/id_rsa.pub | ssh -p 8022 u0_a123@192.168.1.50 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys"macOS/Linux 终端:
ssh-copy-id -p 8022 u0_a123@192.168.1.50
从 PC 上验证免密码访问:
ssh -p 8022 u0_a123@192.168.1.50如果不需要输入密码即可登录,就说明准备好了!
步骤 5:在 PC 上配置 Claude Desktop
更新 PC 上的 Claude Desktop 配置文件,让服务器在 Ubuntu 虚拟环境内启动。
打开 Claude Desktop 配置文件:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
在
mcpServers下添加服务器配置(将用户名和 IP 地址替换为你自己的信息):
步骤 5:在 PC 上配置 Claude Desktop
更新 PC 上的 Claude Desktop 配置文件,让服务器在 Ubuntu 虚拟环境内启动。
打开你的 Claude Desktop 配置文件:
Windows:
%APPDATABR%\Claude\claude_desktop_config.jsonmacOS:
~/Library/ApplicationSupport/Claude/claude_desktop_config.json
在
mcpServers下添加服务器配置(将用户名和 iP 地址替换成你自己的):{ "mcpServers": { "termux": { "command": "ssh", "args": [ "-p", "8022", "-o", "StrictHostKeyChecking=accept-new", "u0_a123@192.168.1.50", "proot-distro login ubuntu -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/data/data/com.termux/files/usr/bin /root/venv/bin/python3 /root/termux_mcp.py" ] } } }重启 Claude Desktop。现在,AI 就能操控你的手机了!
备选:通过 HTTP / SSE 连接(远程服务器)
如果你希望以独立 Web 服务器的形式运行,而不是通过 SSH stdio 启动:
在 Termux 中,在 Ubuntu 内使用 SSE 模式运行服务器:
proot-distro login ubuntu -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/data/data/com.termux/files/usr/bin /root/venv/bin/python3 /root/termux_mcp.py sse --port 8000在 PC 上,配置 Claude Desktop,使其直接指向你手机的 IP:
{ "mcpServers": { "termux-remote": { "url": "http://your_phone_ip:8000/sse" } } }
Related MCP Connectors
Turns a phone into a camera+Bluetooth remote so AI assistants can see and control any PC.
- DNS-DATA RemoteDeprecatedcom.dns-data
Connect AI assistants to authorized Windows and macOS devices for files, commands, and management.
Let AI agents control Android and iOS devices on Mobilerun Cloud: screen, input, apps, workflows.
Connect AI assistants to explicitly paired computers, servers, and VMs for permitted remote actions.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to directly control Android devices via Termux, providing 120+ tools for screen manipulation, file management, app control, and system operations with layered loading and security gating.4MIT
- AlicenseAqualityDmaintenanceEnables AI models to control Android devices via ADB through natural language commands, supporting screen analysis and automated actions.353 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables LLM agents to control Android devices securely via Shizuku and Termux:API, providing a universal shell tool for command execution and persistent sessions.9Apache 2.0
- AlicenseAqualityDmaintenanceGives PC AI agents real-world senses by connecting to an Android phone's camera, sensors, and files over local Wi-Fi without cloud relay or ADB.736 PyPI2MIT