Skip to main content
Glama

DesktopBridge 🌉

CI Home Node License: MIT

本地 Model Context Protocol 服务器,适用于 macOS。Claude(或任何 MCP 主机)通过 stdio 与之通信,可以:

  • 允许的目录 内读取、写入、列出和搜索文件

  • 读取 CPU / 内存 / 磁盘统计、运行时间和脱敏的环境变量

  • 列出正在运行的应用程序

  • 运行 shell 命令,支持 分离的 stdout/stderr、超时和可选的进度流

  • 读取和写入剪贴板

  • 捕获屏幕截图并列出显示器

此进程与启动它的用户具有相同的操作系统权限。将其视为在 Mac 上给模型一个终端,然后使用 DESKTOP_BRIDGE_ROOTS 缩小爆炸半径。

要求

  • macOS(剪贴板、屏幕截图和应用程序列表使用 Apple 工具)

  • Node.js 20.19+(推荐 22 LTS)

Related MCP server: macOS Automator MCP Server

安装

cd desktop-bridge
npm install
npm run build
npm test

编译后的入口点是 dist/index.js

连接到 Claude Desktop

  1. 构建服务器(npm run build)。

  2. 打开 Claude Desktop → 设置 → 开发者 → 编辑配置

  3. 合并 claude_desktop_config.example.json 中的块,替换路径和用户名:

{
  "mcpServers": {
    "desktop-bridge": {
      "command": "node",
      "args": ["/Users/YOU/dev/desktop-bridge/dist/index.js"],
      "env": {
        "DESKTOP_BRIDGE_ROOTS": "/Users/YOU/Desktop,/Users/YOU/Documents,/Users/YOU/Downloads"
      }
    }
  }
}
  1. 完全退出并重新打开 Claude Desktop。

  2. 确认 desktop-bridge 出现在 MCP 工具中(桥接图标 🌉)。

macOS 上的配置文件:

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

连接到 Claude Code

claude mcp add desktop-bridge -- node /Users/YOU/dev/desktop-bridge/dist/index.js

或者将相同的 command / args / env 块添加到 ~/.claude.json

连接到 Cursor

添加到 ~/.cursor/mcp.json(或项目的 .cursor/mcp.json):

{
  "mcpServers": {
    "desktop-bridge": {
      "command": "node",
      "args": ["/Users/YOU/dev/desktop-bridge/dist/index.js"]
    }
  }
}

无主机冒烟测试

npm run inspector

这将针对构建的 stdio 服务器启动 MCP Inspector。调用 list_roots,然后调用 get_system_info

日志仅输出到 stderr。不要在此进程中使用 console.log — stdout 是 JSON-RPC 通道。

环境变量

变量

默认值

含义

DESKTOP_BRIDGE_ROOTS

~/Desktop, ~/Documents, ~/Downloads(如果存在)

文件工具可以访问的逗号分隔目录。操作系统临时目录始终添加,以便屏幕截图有存放位置。

DESKTOP_BRIDGE_MAX_FILE_BYTES

10485760

单个文件读/写的最大大小(1 KiB–100 MiB)。

DESKTOP_BRIDGE_COMMAND_TIMEOUT_MS

30000

默认 run_command 超时(100–300000)。

DESKTOP_BRIDGE_MAX_OUTPUT_BYTES

1048576

组合的 stdout+stderr 捕获上限。超出输出会终止进程并设置 truncated

DESKTOP_BRIDGE_ALLOW_SHELL

true

设置为 false 以禁用 run_command

DESKTOP_BRIDGE_RESTRICT_SHELL_CWD

true

为 true 时,run_command 的 cwd 必须位于允许的根目录内。

DESKTOP_BRIDGE_STATUS_URL

未设置

状态站点的心跳 POST URL(…/api/heartbeat)。

DESKTOP_BRIDGE_STATUS_TOKEN

未设置

与站点的 HEARTBEAT_TOKEN 匹配的 Bearer 令牌。

DESKTOP_BRIDGE_STATUS_INTERVAL_MS

15000

心跳间隔(5s–5m)。

复制 .env.example 获取带注释的模板。服务器读取 进程环境变量(Claude Desktop env 块),而不是 .env 文件。

工具

工具

功能

list_roots

允许的目录和文件大小上限

read_file

文本(可选行窗口)或 base64

write_file

创建/覆盖/追加;可选 mkdir -p

list_directory

名称、类型、大小、修改时间、模式

search_files

按名称进行 glob 和/或按文件内容进行正则表达式搜索

get_system_stats

CPU 百分比、负载、内存、df

get_system_info

主机、运行时间、用户、脱敏环境变量

list_applications

通过 System Events 列出 GUI(或所有)进程

run_command

带分离 stdout/stderr 的 shell;stream → 进度通知

read_clipboard / write_clipboard

pbpaste / pbcopy

get_display_info

显示器名称、主显示器标志、缩放、帧

take_screenshot

通过 screencapture 生成 PNG;当 ≤ 5 MiB 时返回图像块

资源:desktop://rootsdesktop://system/info
提示:inspect_desktopfind_file

安全模型

  • 文件: 每个路径都经过 realpath 处理。解析后的路径必须保持在配置的根目录内。拒绝 ..、多余斜杠和逃逸的符号链接。

  • 主目录不是默认根目录。 这使 ~/.ssh 等目录在您有意添加之前无法访问。

  • Shell: 仍然是完整的用户 shell。即使 cwd 受限,命令也可以 cd 到任何位置。如果只需要文件/剪贴板/屏幕工具,请使用 DESKTOP_BRIDGE_ALLOW_SHELL=false 禁用它。

  • 环境变量: 匹配 password/token/secret/key/credential/cookie/session 的键将被替换为 [redacted]

  • Stdio: 没有网络监听器。主机启动此进程。

macOS 权限

功能

权限

屏幕截图

启动 Node 的应用程序(Claude Desktop、Cursor 或 Terminal)需要 屏幕录制 权限

list_applications

如果 macOS 提示,需要 自动化 → System Events 权限

重度辅助功能应用

可能仍会隐藏标题;该工具无论如何都会列出进程名称

如果 screencapture 失败,请打开 系统设置 → 隐私与安全性 → 屏幕录制 并启用主机应用,然后重新启动它。

开发

npm run build    # tsc → dist/
npm start        # node dist/index.js (stdio)
npm test         # compile + node:test

布局:src/lib/*(路径守卫、进程运行器、glob/搜索)、src/tools/*(MCP 工具)、src/index.ts(stdio 入口)。

主页

https://home.jameymcelveen.com 是浏览器起始页(web/,无额外 npm 包)。登录使用 @mcelveen.us 加上 STATUS_PASSWORD

今天有什么,以及未来内容的转储托盘:

部分

说明

搜索

自动聚焦。Google / Kagi / DDG。Bang 命令:!g !k !d !gh !yt !w !maps

链接

与本地起始页应用相同的磁贴,加上属性。在设置中作为 JSON 编辑

天气

Open-Meteo,°F,Florence SC,除非您覆盖坐标

Mac

DesktopBridge 心跳:在线 / 过期 / 离线,IP,负载

草稿

自动保存的笔记

单词

每日经文

将 Chrome/Safari/Firefox 主页设置为 https://home.jameymcelveen.com(浏览器不会让页面为您设置)。会话 cookie 持续 30 天。/ 聚焦搜索;⌘K 也可以。

推送到 main 运行 CI,然后部署 Vercel(站点)和 Railway(心跳 + 保存的配置)。

在 Mac 上,添加到 MCP 服务器环境变量:

DESKTOP_BRIDGE_STATUS_URL=https://home.jameymcelveen.com/api/heartbeat
DESKTOP_BRIDGE_STATUS_TOKEN=<HEARTBEAT_TOKEN>

许可证

MIT

A
license - permissive license
A
quality
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

  • A
    license
    A
    quality
    A
    maintenance
    Provides a Model Context Protocol server for executing AppleScript and JavaScript for Automation scripts on macOS, featuring a knowledge base of pre-defined scripts and supporting automation of macOS applications and system functions.
    2
    507
    874
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    A Model Context Protocol server that enables execution of AppleScript and JavaScript for Automation scripts on macOS, allowing programmatic control of applications and system functions through a rich knowledge base of pre-defined scripts.
    2
    507
    8
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Secure AppleScript execution for AI applications via Model Context Protocol with configurable security profiles and automatic TCC permission handling.
    3
    1

View all related MCP servers

Related MCP Connectors

  • Let ChatGPT, Claude & Cursor use your Mac: email, calendar, iMessage, Teams, files. Local, free.

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

  • 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/jameymcelveen/desktop-bridge'

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