Skip to main content
Glama

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.sh

Related MCP server: autoglm-mcp-server

设置指南(共 5 步)

步骤 1:在 Android 上安装 Termux 与 Termux:API

  1. 下载 TermuxTermux:API 应用。

    • 重要提示:请不要从 Google Play Store 安装它们(这些版本已经过时且有故障)。请从 F-DroidGitHub Releases 下载。

  2. 在手机上安装这两个应用。


步骤 2:授予 Android 权限

  1. 进入 Android 设置 -> 应用 -> Termux:API

  2. 授予以下权限,以便 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。

  1. 在 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
  1. 从 PC 上验证免密码访问:

    ssh -p 8022 u0_a123@192.168.1.50

    如果不需要输入密码即可登录,就说明准备好了!


步骤 5:在 PC 上配置 Claude Desktop

更新 PC 上的 Claude Desktop 配置文件,让服务器在 Ubuntu 虚拟环境内启动。

  1. 打开 Claude Desktop 配置文件:

    • Windows%APPDATA%\Claude\claude_desktop_config.json

    • macOS~/Library/Application Support/Claude/claude_desktop_config.json

  2. mcpServers 下添加服务器配置(将用户名和 IP 地址替换为你自己的信息):

步骤 5:在 PC 上配置 Claude Desktop

更新 PC 上的 Claude Desktop 配置文件,让服务器在 Ubuntu 虚拟环境内启动。

  1. 打开你的 Claude Desktop 配置文件:

    • Windows%APPDATABR%\Claude\claude_desktop_config.json

    • macOS~/Library/ApplicationSupport/Claude/claude_desktop_config.json

  2. 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"
          ]
        }
      }
    }
  3. 重启 Claude Desktop。现在,AI 就能操控你的手机了!


备选:通过 HTTP / SSE 连接(远程服务器)

如果你希望以独立 Web 服务器的形式运行,而不是通过 SSH stdio 启动:

  1. 在 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
  2. 在 PC 上,配置 Claude Desktop,使其直接指向你手机的 IP:

    {
      "mcpServers": {
        "termux-remote": {
          "url": "http://your_phone_ip:8000/sse"
        }
      }
    }
A
license - permissive license
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.

  • Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.

  • A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…

View all MCP Connectors

Latest Blog Posts

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/AbuZar-Ansarii/Termux-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server