Skip to main content
Glama

remote-pc-mcp

一套代码同时适配 macOS 与 Windows 的跨平台 Streamable HTTP MCP Server,配合 Tailscale 私有加密组网,让部署在 VPS 上的 AI Agent(如 CloudCLI / Codex / Claude Code / Antigravity CLI)可以安全、稳定地远程操控你的多台个人电脑。

核心特性

  • 零 C++ 原生编译依赖:纯 Node.js(>= 20)+ 官方 @modelcontextprotocol/sdk,Mac / Windows 下载后 npm install 即用,不会踩 node-gyp 编译坑。

  • 多台电脑同时接入:Mac 默认监听 8787(my-mac),Windows 默认监听 8788(my-win),VPS 上的 Agent 可以同时区分并操控两台电脑。

  • 默认绑定 Tailscale 私网 + Bearer Token 鉴权:自动检测本机 Tailscale IPv4(100.64.0.0/10)绑定,不暴露公网,每次请求校验 Authorization: Bearer <token>。

  • 增强版桌面控制(纯系统内置,零额外软件):

    • 基础工具:get_system_info、run_command(Mac 固定 /bin/zsh,Windows 固定系统 powershell.exe 强制 UTF-8 防中文乱码)、read_file、write_file、list_dir

    • 桌面 GUI 工具:take_screenshot(直接回传压缩后的屏幕图像给模型看)、list_windows、focus_window、read_ui_elements(读取窗口控件树)、mouse_click、keyboard_type(剪贴板粘贴模式完美支持中文)、keyboard_hotkey


Related MCP server: agentic-remote-pc

整体架构

手机 / 浏览器
   │ HTTPS
   ▼
VPS (CloudCLI: Codex / Claude Code)
   ├── MCP "my-mac" ──(Tailscale 加密内网)──► macOS 电脑 (:8787)
   └── MCP "my-win" ──(Tailscale 加密内网)──► Windows 电脑 (:8788)

快速上手

前置准备

  1. Tailscale:在你的 VPS、Mac、Windows 上安装并登录同一个 Tailscale 账号。

  2. Node.js >= 20:在要被控制的 Mac 和 Windows 电脑上安装 Node.js 20 或更高版本。


一、在 macOS 上部署(默认端口 8787)

git clone https://github.com/Caben123/remote-pc-mcp.git
cd remote-pc-mcp

# 一键安装依赖、生成随机 Token,并注册 macOS 开机自启(LaunchAgent)
bash scripts/setup-mac.sh --install-service

如果只想前台手动运行,不加 --install-service,执行完后运行 npm start 即可。

macOS 桌面控制权限设置(使用截屏 / 窗口 / 键鼠工具必做): 打开 系统设置 → 隐私与安全性,在以下两项中勾选你的终端 App(或 node 可执行文件):

  • 辅助功能(Accessibility)

  • 屏幕录制(Screen Recording)


二、在 Windows 上部署(默认端口 8788)

打开 PowerShell:

git clone https://github.com/Caben123/remote-pc-mcp.git
cd remote-pc-mcp

# 一键安装依赖、生成随机 Token,并配置登录自动后台启动
powershell -ExecutionPolicy Bypass -File scripts\setup-win.ps1 -InstallStartup

如果只想前台手动运行,去掉 -InstallStartup,执行完后运行 npm start 即可。 Windows 防火墙如弹出提示,请允许 Node.js 在“专用网络”通信(或允许 Tailscale 接口入站端口 8788)。


三、在 VPS 上一键挂载到 Codex & Claude Code

上面在 Mac / Windows 运行完一键脚本后,终端会直接打印出一条对应这台电脑的注册命令。 在 VPS 上(切换到运行 CloudCLI 的用户,例如 coder)执行即可:

# 下载注册脚本(或直接 git clone 本仓库)
git clone https://github.com/Caben123/remote-pc-mcp.git
cd remote-pc-mcp

# 注册 Mac
bash scripts/register-vps.sh my-mac http://<Mac的Tailscale_IP>:8787/mcp <Mac生成的MCP_TOKEN>

# 注册 Windows
bash scripts/register-vps.sh my-win http://<Win的Tailscale_IP>:8788/mcp <Win生成的MCP_TOKEN>

完成后刷新 CloudCLI 网页(或新开一个会话),就可以直接对 AI 说:

  • “先看看 my-mac 的系统信息,列出我桌面的文件”

  • “截一张 my-win 的屏幕,告诉我当前打开了哪些窗口”


配置项说明(.env)

变量名

默认值

说明

HOST

auto

自动绑定本机 Tailscale IPv4;检测不到时回退 127.0.0.1

PORT

Mac 8787 / Win 8788

监听端口

MACHINE_NAME

my-mac / my-win

机器名称标识

MCP_TOKEN

(必填)

Bearer 鉴权密钥(禁止提交到 Git)

ALLOWED_ROOTS

(留空)

可选目录白名单,逗号分隔;留空按当前用户权限

COMMAND_TIMEOUT_MS

60000

单条命令超时时间(毫秒)

ENABLE_DESKTOP_TOOLS

true

设为 false 可关闭桌面 GUI 工具,仅保留 Shell 与文件

SCREENSHOT_MAX_WIDTH

1440

截屏缩放最大宽度(像素)


安全提醒

  1. 切勿将 .env 或 MCP_TOKEN 提交到任何代码仓库或截图分享。

  2. 建议始终保持 HOST=auto(仅绑定 Tailscale 私网 IP),不要把服务暴露在公网 IP 上。

  3. 本服务以你当前系统用户权限运行,如仅希望 AI 访问特定项目目录,请在 .env 中配置 ALLOWED_ROOTS。

  4. 被控制的电脑需要保持开机、联网、不休眠(Mac 可设置合盖/电源防休眠,Windows 可在电源选项关闭自动睡眠)。

本地自检

npm run test:smoke

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI services like Claude and Cursor to remotely control a Mac by executing shell commands, managing files, and running AppleScript for UI automation. Access is secured through OAuth 2.0 authentication and encrypted tunnels to protect remote interactions.
      2
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI clients to securely control trusted devices and perform filesystem, terminal, process, and document operations through a self-hosted remote service.
      1,287,096 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables an AI agent to inspect and operate a remote Windows machine over a private tailnet, listing and reading files, transferring and mutating them within a configured sandbox root, capturing screenshots, and — only when explicitly double-opted-in — executing commands and sending keystrokes. It runs self-hosted with no third-party client or vendor cloud in the session path, and reports its live policy rather than asserting its own safety.
      MIT