Desktop Mcp

io.github.jaimenbell由 GitHub 账号 jaimenbell 发布v0.1.1更新于 Oct 24, 2026

Windows desktop-control MCP server: screenshot, window mgmt, mouse/keyboard input, recording.

已验证STDIO仅桌面浏览器自动化媒体与设计

概览

AI 生成的概览

仅限 Windows 的本地 MCP 服务器,让助手截屏、查看和管理窗口、注入鼠标键盘输入,并录制屏幕。

可以做什么
截取显示器、区域或窗口的截图,并列出窗口、获取活动窗口或查询窗口信息(始终开启)。在启用 window 组后,可聚焦、移动、调整大小、最小化和还原窗口。在启用 input 组后,可移动、点击、拖拽和滚动鼠标,按键、发送快捷键和输入文本。在启用 record 组后,可启动、查询状态和停止带时长上限的 ffmpeg 屏幕录制。
适用场景
适合助手需要查看或操作同一台机器上的 Windows 桌面的场景,例如查看屏幕内容、整理窗口、自动化重复的图形界面操作,或录制一段屏幕视频。不适合远程控制或非 Windows 主机。
运行要求
作为本地 stdio 进程在 Windows 上运行,从 PyPI 安装(pip install desktop-mcp),由 MCP 宿主启动。需要 Python 及 fastmcp、mss、pyautogui、PyGetWindow、pywin32,录制还需 PATH 中有 ffmpeg 和 ffprobe。window、input、record 组默认关闭,需分别用 DESKTOP_MCP_ENABLE_WINDOW、DESKTOP_MCP_ENABLE_INPUT、DESKTOP_MCP_ENABLE_RECORD 开启;可选设置包括 DESKTOP_MCP_RATE_LIMIT_PER_MIN 和 DESKTOP_MCP_SCRATCH_DIR。
安装前请注意
截图功能始终开启,可捕获任何可见窗口,包括密码管理器、双重验证应用、助记词和银行页面;PNG 会留在临时目录中。启用 DESKTOP_MCP_ENABLE_INPUT 被描述为等同远程代码执行,调用方可向当前焦点窗口输入命令并操作鼠标。向高权限窗口注入输入可能静默失败却返回成功。应仅在可信主机上运行,避免以管理员权限运行,并只为特定任务开启相应组。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Desktop Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

desktop-mcp

[PyPI] [MCP Registry] [License: MIT] [tests] [CI]

Windows desktop-control MCP server: screenshot, window management, mouse/keyboard input, and ffmpeg screen-recording, config-gated by tool group (input off by default) -- built to the same standard as mcp-factory and rag-mcp: own pyproject, fastmcp server, honest README, real test suite.

Quickstart

bash
pip install desktop-mcp
jsonc
// ~/.claude.json (or any MCP-host stdio client config){  "mcpServers": {    "desktop-mcp": {      "command": "desktop-mcp"      // or: "command": "python", "args": ["-m", "desktop_mcp"]    }  }}

window/input/record tool groups are env-gated -- input stays off unless you explicitly opt in. See Env vars below for the full table.

Tool groups

GroupToolsDefault state
observescreenshot, list_windows, get_active_window, window_infoalways on
windowfocus_window, move_resize_window, minimize_window, restore_windowenv-gated, off unless DESKTOP_MCP_ENABLE_WINDOW=1
inputmouse_move, mouse_click, mouse_drag, mouse_scroll, key_press, hotkey, type_textenv-gated, OFF by default -- requires DESKTOP_MCP_ENABLE_INPUT=1
recordrecord_start, record_status, record_stopenv-gated, off unless DESKTOP_MCP_ENABLE_RECORD=1

A disabled group returns a structured policy_refusal error (never a silent no-op, never a crash). Input actions are additionally rate-capped (default 60 actions/min, tunable via DESKTOP_MCP_RATE_LIMIT_PER_MIN) -- exceeding the cap returns a structured rate_limited error.

This is defense-in-depth: harness-level permission prompts are the first gate, but the server itself refuses input/window/record actions unless its own env explicitly enables them, so a misconfigured or overly-permissive harness can't turn on capabilities the operator didn't opt into for this process.

Security

Read this before you register desktop-mcp. This is a desktop-control server; what it can do to your machine is spelled out here plainly so you can make an informed decision. Honesty about the blast radius is the point.

  • The observe group (screenshot, window enumeration) is ALWAYS ON and cannot be disabled. Any caller that can reach this server can capture the contents of any visible window on the machine -- including a password manager, an authenticator/2FA app, a seed phrase, a banking tab, or a private message. screenshot returns a file path to a PNG written to the scratch dir (default %TEMP%\desktop-mcp-scratch), not inline pixels, so captured screen contents also persist on disk until that directory is cleared. Treat the scratch dir as sensitive and run this server only on a machine and under a harness you trust.
  • DESKTOP_MCP_ENABLE_INPUT=1 grants keystroke and mouse injection into the focused window -- this is RCE-equivalent. With the input group enabled, a caller can type commands, press hotkeys, and drive the mouse in whatever window currently has focus (a terminal, a browser, an admin tool). It is OFF by default for exactly this reason; turn it on only when you understand that you are handing the caller the keyboard. When disabled every input tool returns a structured policy_refusal (never a silent action).
  • Least privilege: leave input, window, and record groups off unless a specific task needs them, keep this server on a trusted host, and do not run it elevated (admin) unless you have accepted that an elevated input group can drive elevated windows.

The env-gating, default-off input group, structured refusals, and rate cap described above are the enforced controls; this section states, without softening, what remains reachable by design.

Honest-capabilities table

Every claim below maps to the file that implements it and the test(s) that verify it -- no capability is asserted without a corresponding implementation + test.

ClaimImplementationVerified by
Capture a screenshot (monitor / region / window) as PNGdesktop_mcp/groups/observe.py::screenshottests/test_observe.py::TestScreenshot, live: tests/test_live_smoke.py::test_live_screenshot_real_png
Enumerate windows / get active window / look up by titledesktop_mcp/groups/observe.pytests/test_observe.py::TestListWindows, TestGetActiveWindow, TestWindowInfo
Focus / move+resize / minimize / restore a windowdesktop_mcp/groups/window.pytests/test_window.py
Mouse move/click/drag/scroll, key press/hotkey, type textdesktop_mcp/groups/input_tools.pytests/test_input.py (mocked pyautogui only -- see Limitations)
Screen recording via ffmpeg gdigrab, hard duration cap, graceful stopdesktop_mcp/groups/record.pytests/test_record.py, live: tests/test_live_smoke.py::test_live_record_real_mp4
Input group OFF by default, structured refusal when disableddesktop_mcp/config.py::group_enabled, gatedtests/test_config.py::TestGroupEnabled, tests/test_input.py::TestGateDisabledByDefault
Rate cap on input actions (default 60/min)desktop_mcp/config.py::TokenBucket, RateLimiterRegistrytests/test_config.py::TestTokenBucket, tests/test_input.py::TestRateLimit
DPI-awareness bootstrap (per-monitor-v2) so mss/pyautogui coords agree on scaled displaysdesktop_mcp/config.py::ensure_dpi_awarenesstests/test_config.py::TestDpiAwareness (idempotency only; visual coord-agreement is not automated -- see Limitations)
Coordinate validation against virtual-desktop bounds before any mouse actiondesktop_mcp/groups/input_tools.py::_validate_pointtests/test_input.py (out-of-bounds cases)
Orphan-guard: a stale recorder from a crashed process gets killed before a new one startsdesktop_mcp/groups/record.py::_orphan_guardtests/test_record.py::TestRecordStart::test_orphan_guard_kills_stale_recorder

Limitations (read before relying on this)

  • UIPI (User Interface Privilege Isolation) -- protects window handles, not input. A medium-integrity process (this server, unless you elevate it) cannot manipulate a window owned by a higher-integrity (elevated/admin) process: focus_window, move_resize_window, minimize_window, and restore_window go through pygetwindow's window-handle APIs (desktop_mcp/groups/window.py), which Windows blocks under UIPI and which this server surfaces as a structured window_action_failed error naming UIPI, never a silent no-op. Keyboard/mouse input tools ARE covered by UIPI too -- and worse, they fail silently. type_text, hotkey, key_press, and the mouse actions (desktop_mcp/groups/input_tools.py) go through pyautogui, whose Windows backend actually calls the legacy keybd_event/mouse_event Win32 functions (not SendInput -- pyautogui tried SendInput and reverted to the older calls; see _pyautogui_win.py in the installed package). Per Microsoft's own docs, UIPI applies to synthesized input generally: "[applications] are permitted to inject input only into applications that are at an equal or lesser integrity level" (MSDN SendInput reference), and critically, "neither GetLastError nor the return value will indicate the failure was caused by UIPI blocking." keybd_event/mouse_event are void-return legacy calls with no failure signal at all, so pyautogui (and this server) cannot detect a block even in principle: if an elevated window has focus, these tools report {"ok": true} while Windows silently discards the injected keystrokes/clicks -- no exception, no error field, nothing reaches the target. This is worse than the window-handle path above, which at least raises a structured window_action_failed error naming UIPI. There is no code-level bypass and no workaround short of running the server elevated (or not enabling the input group at all), which this project does not do or recommend. Operators should treat any elevated app that could plausibly have focus as silently unreachable by this server's input tools, not as a gap that lets them through. Possible future enhancement (not implemented): detect the foreground window's integrity level before injecting and return a structured refusal instead of a false {"ok": true} -- tracked as a v2 idea, not a current capability.
  • DPI scaling. The server sets per-monitor-v2 DPI awareness at startup so mss pixel coordinates and pyautogui point coordinates should agree on scaled displays. This bootstrap is unit-tested for idempotency/no-crash only -- actual coordinate agreement on a live multi-DPI multi-monitor setup has not been automated-tested and should be spot-checked if you're targeting a non-100%-scaled monitor.
  • UAC secure desktop. When Windows switches to the secure desktop (UAC elevation prompts, Ctrl+Alt+Del, lock screen), no process running on the regular desktop -- including this server -- can see or interact with it. Screenshots will show whatever was on the regular desktop before the switch; input calls will not reach the secure desktop at all.
  • Single machine, local only. No network transport, no remote control. stdio only, spawned by the MCP host on the same machine.
  • Input group is off by default in this repo's own registration. See ~/.claude.json's desktop-mcp entry -- DESKTOP_MCP_ENABLE_INPUT is not set there. Enabling it is a deliberate per-registration operator choice, not a code change.
  • pyautogui failsafe. FAILSAFE=True is intentional: slamming the cursor into a screen corner mid-action raises inside pyautogui and aborts the call. This can interrupt an in-flight mouse_drag. Treated as acceptable v1 behavior (see plan's Open questions) -- it's a deliberate human kill-switch, not a bug.
  • No OCR / vision analysis. Screenshots are raw PNGs; interpreting their content is the consumer's job, not this server's.
  • No clipboard tools. Credential-adjacent surface, deferred to a v2 with its own safety design.
  • Not registered with the mcp-factory hub. This ships as a standalone repo (own pyproject, own venv-free system-Python312 install), matching the rag-mcp model. Hub/registry integration is a v2 candidate.

Env vars

VarEffectDefault
DESKTOP_MCP_ENABLE_WINDOWenable the window tool groupunset (off)
DESKTOP_MCP_ENABLE_INPUTenable the input tool groupunset (off)
DESKTOP_MCP_ENABLE_RECORDenable the record tool groupunset (off)
DESKTOP_MCP_RATE_LIMIT_PER_MINinput-group rate cap60
DESKTOP_MCP_SCRATCH_DIRwhere screenshots/recordings/pidfiles are written%TEMP%\desktop-mcp-scratch
DESKTOP_MCP_LIVE1 to run real-hardware smoke tests (see Testing)unset (skip)

Usage examples

jsonc
// A tool call from the MCP host, illustrative -- not a shell command.{"tool": "screenshot", "arguments": {"monitor": 0}}// -> {"ok": true, "path": "C:\\Users\\...\\Temp\\desktop-mcp-scratch\\screenshot-....png", "w": 3840, "h": 1080, "monitor": 0}
{"tool": "record_start", "arguments": {"fps": 30, "max_duration_s": 30}}// -> {"ok": true, "path": "...\\recording-....mp4", "pid": 12345, "fps": 30, "max_duration_s": 30}{"tool": "record_stop", "arguments": {}}// -> {"ok": true, "path": "...\\recording-....mp4", "bytes": 800560, "duration_s": 3.13}
// input group disabled (default):{"tool": "mouse_click", "arguments": {"x": 500, "y": 500}}// -> {"ok": false, "error": {"type": "policy_refusal", "group": "input", "required_env": "DESKTOP_MCP_ENABLE_INPUT", ...}}

Testing

CI (.github/workflows/ci.yml) runs this suite on every push/PR (on windows-latest, since pywin32/PyGetWindow are Windows-only deps that don't install on Linux runners) and fails the build if the Tests badge above drifts from what the suite actually reports -- see scripts/check_readme_counts.py.

# unit suite (mocked backends, no real screen/input/recording touched)python -m pytest -q
# handshake check -- prints every registered tool namepython scripts/list_tools.py
# real-hardware smokes (real screenshot PNG, real ~3s screen recording;# never input-injection -- see safety rails above)DESKTOP_MCP_LIVE=1 python -m pytest -q -k live_screenshotDESKTOP_MCP_LIVE=1 python -m pytest -q -k live_record

Install

pip install -r requirements.txt   # or: pip install .# deps: fastmcp==3.4.2, mss==10.2.0, pyautogui==0.9.54, PyGetWindow==0.0.9, pywin32==312# also requires ffmpeg + ffprobe on PATH for the record group

Registered in ~/.claude.json as desktop-mcp (stdio, system Python312, observe+window+record groups enabled, input group absent from env).

Commercial support

Maintained by Jaimen Bell. For production MCP integrations, custom servers, or agent-reliability work, see jaimenbell.dev.

Building your own MCP server? The MCP Starter Kit has templates, a build playbook, and packaging war-stories from shipping this one.

mcp-name: io.github.jaimenbell/desktop-mcp

来源:README.md,提交 9c9c79e

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分