Skip to main content
Glama

desktop-mcp

面向大语言模型的桌面视觉与控制,支持 Linux,包括 Wayland —— 模型截取整个屏幕的截图,然后在所看到的内容上点击、输入和滚动。基于 stdio 的纯 MCP,因此它可以在 Claude Code、Claude Desktop、Cursor 或任何其他 MCP 客户端中使用。

先读这里:你可能不需要这个

Anthropic 原生提供 computer use 功能,在它能工作的地方你应该改用这个功能——它集成得更好,而且确实在维护:

  • macOS 和 Windows:Claude Desktop 在 Cowork 和 Claude Code 中内置了 computer use。它可以操控你的真实桌面。 (文档)

  • 构建你自己的智能体:Claude API 有一个第一方的 computer 工具 (GA 版本为 computer_toolset_20260801 工具集)。 (文档)

这个项目填补的空白是 Linux。 截至 2026 年 8 月,computer use 在 Linux 桌面应用中尚不可用,而且 Wayland 上的桌面自动化确实很别扭,这是 X11 从未有过的:

  • COSMIC 的合成器没有实现 wlr-screencopy,所以 grim 直接失败,每个截图工具都需要针对每个合成器的路径。

  • 没有协议可以查询光标位置,也没有协议可以枚举其他客户端的窗口。

  • 输入必须通过 /dev/uinput 从合成器下方注入,因为通常打包的 ydotool 暴露的是 相对 指针,其长距离跳转会被指针加速搞乱。

如果你在 macOS 或 Windows 上,这个仓库基本上是多余的。如果你在 Linux 上——尤其是 Wayland——它是可用的选择。

桌面自动化 MCP 服务器并不是一个新类别;已经有成千上万个 MCP 服务器。这里的特殊之处在于 Wayland 原生的绝对 uinput 输入路径,在 COSMIC 上实测像素级精确。

Related MCP server: mcp-linux-desktop

状态

编写时考虑了跨平台,但实际只有一种配置被验证过。其余只是代码路径,不是实证——请相应看待。

平台

截图

输入

已测试

Linux / Wayland

cosmic-screenshot, grim, spectacle, GNOME D-Bus

/dev/uinput

是 — 仅 COSMIC

Linux / X11

maim, ImageMagick import, mss

/dev/uinput, xdotool

否

macOS

screencapture

pyautogui

否

Windows

mss, PowerShell

pyautogui

否

测试了什么,以及如何测试

在以下环境进行了端到端验证:

  • Pop!_OS 24.04 LTS,内核 7.0.11,COSMIC(cosmic-comp 1.0.0),Wayland,单台 2560x1440 显示器,Python 3.13。

结果:

检查项

方法

结果

截图

cosmic-screenshot 后端

捕获 2560x1440,缩小到 1400x788

指针精度

5 个目标点,通过 XWayland 读回

5/5 精确,0px 误差

按钮和滚动

xev 事件日志

按钮 1、3、4 的 ButtonPress/Release

拖拽

xev 运动计数

按下和释放之间有 26 个 MotionNotify 事件

输入

wtype 和原始 uinput 键码

文本落入了聚焦的编辑器

组合键

编辑器中的 ctrl+a

已生效

通过 MCP 点击

针对原生 Wayland 应用的完整 stdio 往返

打开了新标签页

未测试但值得了解:多显示器布局、HiDPI 缩放、原始键码路径上的非美式键盘布局(wtype 能正确处理这些;uinput 键码假定为美式),以及所有非 COSMIC 合成器。

欢迎来自其他平台的报告——desktop_info 会输出诊断后端问题所需的一切信息。

安装

git clone <this repo> && cd desktop-mcp
uv venv && uv pip install -e .

macOS、Windows 和 Linux/X11 还需要输入依赖:

uv pip install -e ".[gui]"

Linux:一次性权限设置

在 Wayland 上注入输入意味着要写入 /dev/uinput,而它默认归 root 所有:

bash scripts/setup-linux.sh   # needs sudo once
# then log out and back in

macOS:一次性权限设置

在“系统设置 → 隐私与安全性”中,为启动服务器的应用(Terminal、iTerm、Claude Desktop)授予屏幕录制和辅助功能权限。

接入

Claude Code:

claude mcp add desktop -- /absolute/path/to/desktop-mcp/.venv/bin/python -m desktop_mcp.server

Claude Desktop(claude_desktop_config.json)和 Cursor(.cursor/mcp.json)使用相同的结构:

{
  "mcpServers": {
    "desktop": {
      "command": "/absolute/path/to/desktop-mcp/.venv/bin/python",
      "args": ["-m", "desktop_mcp.server"]
    }
  }
}

工具

工具

用途

screenshot

捕获桌面

click

左/右/中键单击,单击或双击

move

移动指针而不点击(悬停)

drag

按下、移动、释放——选择、滑块、移动窗口

scroll

在某个点下滚动滚轮

type_text

向聚焦的元素输入文本

key

组合键,如 ctrl+s、alt+tab、cmd+space

cursor_position

指针所在位置

list_windows

打开窗口(在操作系统允许的情况下)

wait

暂停,然后重新查看

desktop_info

环境、当前后端、安全设置

坐标

截图在发送前会被缩小(默认长边 1400px),因此模型使用的是图像像素;服务器在每次调用时将它们映射回屏幕像素。请直接传入你从截图上读到的坐标。

这是大多数自制的 computer use 工具最容易搞错的细节。忽略它,每次点击都会落在目标位置的一个固定比例处。

为什么在 Linux 上使用 /dev/uinput 而不是 ydotool

通常打包的 ydotool 构建暴露的是 相对 指针,因此跳到 (1280, 720) 会被当作一次大的相对运动传递——合成器会对其应用指针加速。光标会落在目标附近而不是目标上,误差随距离增大。绝对 uinput 设备绕开了加速:在 2560x1440 屏幕上实测 5/5 精确。当 /dev/uinput 不可写时,ydotool 仍作为后备方案。

点击时序

合成器异步分发指针移动,而工具包会忽略在它们处理完将光标移到控件上的移动事件之前到达的按钮按下事件。在 COSMIC 上实测:移动和按下之间间隔 30ms 能可靠地高亮按钮,但绝不会激活它——悬停状态证明坐标是正确的,这使得这个失败很容易被误读为定位 bug。250ms 可以激活它。按下还必须保持(约 90ms)才能被识别为真正的点击,而不是一个杂散事件。

这两个延迟都可调;只有在你的桌面环境能承受时才降低它们。

安全

这赋予了模型与坐在机器前的人相同的操作权限。它可以读取屏幕上的任何内容——打开的密码管理器、私密消息、令牌——并点击任何东西,包括破坏性按钮。请将会话视为你把键盘交给了别人。

环境变量:

变量

默认值

作用

DESKTOP_MCP_READ_ONLY

关闭

允许截图,拒绝所有输入

DESKTOP_MCP_RATE_LIMIT

240

每分钟最大输入操作数

DESKTOP_MCP_BLOCK_KEYS

—

额外要拒绝的逗号分隔组合键

DESKTOP_MCP_AUDIT_LOG

—

将每个操作追加到此文件

DESKTOP_MCP_MAX_EDGE

1400

截图长边像素数

DESKTOP_MCP_MOVE_SETTLE

0.25

移动指针和按下之间等待的秒数

DESKTOP_MCP_PRESS_HOLD

0.09

鼠标按钮按住的秒数

ctrl+alt+F1–F12 始终被阻止;VT 切换可能会让图形会话从你手中溜走。

一个只读审查者配置:

DESKTOP_MCP_READ_ONLY=1 python -m desktop_mcp.server

验证

.venv/bin/python scripts/mcp_smoke.py   # real stdio MCP round trip

Available Tools

11 tools
clickB

Click at (x, y), in screenshot-image coordinates.

button: "left", "right" or "middle". count: 2 for a double-click.

NameRequiredDescriptionDefault
xYes
yYes
countNo
buttonNoleft
screenshotNo
cursor_positionA

Report where the pointer is, in both image and screen coordinates.

NameRequiredDescriptionDefault

No parameters

Output Schema

NameRequiredDescription
resultYes
desktop_infoA

Report the environment, the chosen backends, and the active safety limits.

Worth calling once at the start of a session, or whenever something fails.

NameRequiredDescriptionDefault

No parameters

dragB

Press at one point, move, and release at another.

Use for selecting text, moving windows, and dragging sliders.

NameRequiredDescriptionDefault
to_xYes
to_yYes
buttonNoleft
from_xYes
from_yYes
screenshotNo
keyB

Press a key or chord, e.g. "enter", "ctrl+s", "alt+tab", "cmd+space".

Modifiers: ctrl, alt, shift, super (aka win), cmd. "cmd" is Command on macOS and Super elsewhere, so one chord works across platforms.

NameRequiredDescriptionDefault
comboYes
pressesNo
screenshotNo
list_windowsA

List open windows with their titles and geometry, where the OS allows it.

NameRequiredDescriptionDefault

No parameters

moveB

Move the pointer to (x, y) without clicking -- useful for hover states.

NameRequiredDescriptionDefault
xYes
yYes
screenshotNo
screenshotA

Capture the desktop and return it as an image.

Take one before acting, and after any action whose result you need to see. All other tools expect coordinates measured on this image.

NameRequiredDescriptionDefault

No parameters

scrollA

Scroll under the pointer at (x, y).

dy is in wheel detents: negative scrolls down the page, positive scrolls up.

NameRequiredDescriptionDefault
xYes
yYes
dxNo
dyNo
screenshotNo
type_textA

Type text into whatever currently has keyboard focus.

Click the target field first. Newlines in the text are typed as Enter.

NameRequiredDescriptionDefault
textYes
screenshotNo
waitC

Pause, then look again. Use while a page loads or an animation finishes.

NameRequiredDescriptionDefault
secondsNo
screenshotNo

Tool Schema Changelog

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

  1. 11 tool updatesv0.1.0
    • First observedclick
    • First observedcursor_position
    • First observeddesktop_info
    • First observeddrag
    • First observedkey
    • First observedlist_windows
    • First observedmove
    • First observedscreenshot
    • First observedscroll
    • First observedtype_text
    • First observedwait

TDQS

A3.7/5.0

Scored across 11 tools

Disambiguation5/5

Each tool maps to a distinct input modality or query—screenshot, pointer actions, keyboard actions, and state queries—so there is little chance of selecting the wrong tool. The only adjacent pair is type_text vs key, but their descriptions clearly separate literal text entry from chords/hotkeys.

Naming Consistency4/5

Most names are short, lowercase imperative verbs (click, move, drag, scroll, wait), with a few compound state/query names (cursor_position, desktop_info) and two verb_noun pairs (type_text, list_windows). The style is readable and predictable, though not every tool follows a uniform verb_noun pattern.

Tool Count5/5

11 tools cover the core desktop-automation surface without redundancy or bloat. Each tool addresses a distinct need, so the count feels intentional and well-scoped.

Completeness5/5

The set provides observation (screenshot, cursor_position, list_windows, desktop_info), mouse control (click, move, drag, scroll), keyboard control (type_text, key), and a synchronization primitive (wait), covering the full cycle of GUI automation. I don't see an obvious missing operation that would leave an agent stuck in normal desktop flows.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    Controls a real Linux desktop from any MCP host. Reads accessibility trees, takes screenshots, and drives clicks, scrolls, and keystrokes across GNOME, KDE/KWin, Hyprland, i3, and COSMIC.
    3,776 npm
    834
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables full Linux desktop control including windows, mouse, keyboard, clipboard, audio, screenshots, OCR, accessibility, and system management through MCP-compatible AI agents.
    1
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    An MCP server that gives a model eyes and hands on a Linux Wayland desktop, enabling screenshot capture, mouse/keyboard control, OCR, and icon detection via OmniParser.
    1
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    MCP server for controlling Linux desktops over Wayland, enabling AI agents to perform mouse, keyboard, window, and screenshot operations on Fedora KDE Plasma.
    AGPL 3.0