Desktop MCP
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Desktop MCP
面向 Windows 的本机 MCP 服务,为 GUI Agent 提供屏幕观察和键鼠操作。任何支持 stdio 的 MCP 宿主都可以启动服务、发现工具并调用它们。Python 工具通过 MSS 按请求截取显示器画面,再通过 Win32 执行输入。整个链路可以用普通 MCP 客户端运行,无需模型或 API Key。
供 Desktop Monitor 使用
按 Desktop Monitor 的说明安装对应的 MCP 版本并启动录制。Monitor 会自动启动 Desktop MCP 子进程。
Related MCP server: com-use-mcp
供其他 MCP 客户端使用
需要 Windows 10 1703 或更新版本、Python 3.11+,以及当前用户的交互式桌面。在 desktop-mcp 目录安装依赖并检查源码入口。
python -m pip install -r requirements.txt
python run_mcp.py --version在 MCP 客户端中添加一个 stdio 服务,由它启动 run_mcp.py。将 command 换成安装了依赖的 Python 的绝对路径,将 args 中的路径换成本机源码入口。如果在终端直接运行 python run_mcp.py,进程会在标准输入上等待 MCP 请求。
{
"mcpServers": {
"desktop-mcp": {
"command": "C:\\projects\\desktop-mcp\\.venv\\Scripts\\python.exe",
"args": ["C:\\projects\\desktop-mcp\\run_mcp.py"]
}
}
}宿主通过 initialize 获得服务名、版本和工具能力,通过 tools/list 获取工具名、描述及参数 schema,然后通过 tools/call 执行。服务使用标准输入输出传输 MCP 消息,诊断信息走标准错误。 MCP 握手 · MCP 工具
即时截图与键鼠操作
工具 | 参数 | 返回或行为 |
| 无 | 显示器 ID、桌面原点、宽高和主屏标记。 |
|
| 默认截主屏。返回一张 PNG 和含 |
|
| 在截图上的点执行左键或右键,支持单击和双击。 |
|
| 移动到截图上的点,再向上或向下滚动。方向为 |
|
| 支持字母、数字、常用导航键和 |
|
| 向当前焦点输入最多 2,048 个 Unicode 字符。换行、制表等控制键使用 |
点击和滚动使用原始截图的整数像素坐标,左上角是 (0, 0)。如果宿主缩放了显示图,调用前先把坐标换算回原图。服务保留最近 32 张截图的坐标信息,每帧有效期 60 秒。失效、越界或显示布局变化会返回具体错误码,客户端可以按需重新观察。
动作成功时返回 {"status":"executed"},表示输入已提交给设备。应用是否完成预期操作,需要下一次截图或应用状态来确认。若连接在发送动作后中断,或服务报告 outcome_unknown,先观察再决定是否重试。按键和输入指向当前焦点,建议在同一桌面串行执行一个任务。
用 Python 客户端验证
把下面的例子保存为项目根目录下的 smoke.py,然后运行 python smoke.py。它通过真实 MCP 子进程发现工具、截取当前主屏,并打印结果元数据。
import asyncio
import sys
from pathlib import Path
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def main():
script = Path(__file__).resolve().with_name("run_mcp.py")
params = StdioServerParameters(command=sys.executable, args=[str(script)])
async with (
stdio_client(params) as (read, write),
ClientSession(read, write) as client,
):
info = await client.initialize()
print(info.serverInfo.name, info.serverInfo.version)
print([tool.name for tool in (await client.list_tools()).tools])
result = await client.call_tool("screenshot")
if result.isError:
raise RuntimeError(result.structuredContent)
print(result.structuredContent)
asyncio.run(main())历史帧采集
供 Monitor 这类活动采集客户端使用。只有采集会话运行时才产生滚动帧缓冲。普通 screenshot 依然按请求截取显示器。
工具 | 说明 |
| 打开显示器区域的采集会话。指定窗口 ID 时,区域需与前台窗口边界一致。区域用显示器内的原始物理像素表达,返回 |
| 按同机 Windows 输入事件时间找严格早于事件的合格帧。 |
| 查找事件后的第一张合格帧,可指定下一次动作的边界。 |
| 幂等停止并释放缓冲。 |
在 desktop-mcp.toml 的 [capture] 调整以下参数,重启 MCP 后生效。
参数 | 默认值 | 作用 |
|
| 采集目标帧率,支持 1–15 FPS。 |
|
| 历史帧入缓冲前等比缩放的尺寸上限。客户端请求更小的宽高时逐项取较小值。 |
|
| 新帧与最旧帧之间允许的最大时间差。 |
|
| 历史帧 RGB 像素数据的总量上限,须至少容纳一帧配置尺寸的图像。 |
写入新帧时,只要历史跨度或像素数据总量超限,就淘汰最旧帧。实际回看长度取决于帧尺寸、采集速率和内存上限。旧配置中显式设置的 max_frames 仍会额外限制帧数,删除该项即可使用默认策略。
源码入口从脚本所在目录读取配置,修改后重启 MCP。可用 python run_mcp.py --config path/to/desktop-mcp.toml 指定文件。安装后的入口默认从工作目录读取同名文件,找不到时使用内置默认值。
只为查中的帧编码 PNG。width/height 是返回图像的尺寸,source_width/source_height 是原始采集区域尺寸,帧时间取自缩放前。显示布局变化会清空旧帧,单窗口模式下的失焦、越界和遮挡也会清空旧帧。即时 screenshot 仍返回显示器的原始分辨率。
架构
flowchart LR
C["MCP 宿主或测试客户端"] -->|"stdio"| S["server.py<br/>工具发现、参数验证、结果编码"]
S --> D["desktop.py<br/>显示布局、帧元数据、动作串行化"]
S --> H["capture.py<br/>持续采样、缩放、历史帧检索"]
D --> B["DesktopBackend 接口"]
B --> W["windows.py<br/>MSS 截图与 Win32 输入"]
H --> W
W --> O["Windows 交互式桌面"]
T["自动化测试的假设备"] -.->|"替换后端"| Bserver.py用同一份注册表生成工具列表和执行路由,并把错误转为 MCP 工具结果。desktop.py关联截图与后续点击,用实际显示布局将图内坐标转换为桌面坐标。同一个进程内的设备调用串行执行。backends/windows.py接收采集或输入请求。截图使用 MSS 的 GDI 后端,输入使用 Win32SendInput。 MSS 截图 · Win32 SendInputcontracts.py定义显示器、帧和错误类型,使 MCP 层与设备后端可以分别演进。
Monitor 使用带时间戳的内存缓冲查找输入事件前后的画面。GUI Shortcut 执行器可使用即时截图和键鼠工具完成桌面操作。
开发验证
python -m pip install -r requirements.txt "pytest>=8,<10" "ruff>=0.11,<1"
python -m pytest -q
python -m ruff check run_mcp.py src tests自动化测试用假设备通过真实 stdio 连接验证握手、工具 schema、图片结果和六个工具的调用。帧过期、越界以及显示布局变更都有测试。真机可打开一个空白文本编辑器,截图后点击编辑区,输入中文,按一个导航键,再截图确认。
许可证
本项目采用 MIT 许可证。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Eyes and hands on real Windows PCs — observe, click, type via Glasswarp API.
Let AI see and use your own Windows PC with your permission: screen, apps, mouse and keyboard.
Connect ChatGPT, Claude, Cursor or VS Code to your Windows PC: files, terminal, browser, apps.
Remote desktop MCP: let AI see, click, type and run terminal commands on your own Windows or Mac.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI clients on Windows to control the local mouse, keyboard, and screen understanding via MCP stdio, allowing automated workflows like viewing the screen, locating elements, clicking, typing, and verifying results.1Apache 2.0
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to see and operate a Windows PC through mouse, keyboard, screenshots, OCR, window control, and shell commands.-
- AlicenseNot gradedqualityCmaintenanceEnables an agent to discover, observe, and operate visible Windows applications using UI Automation, screenshots, and foreground-validated input control through a local stdio connection.MIT
- AlicenseNot gradedqualityCmaintenanceEnables an AI client to inspect and control an interactive Windows desktop, including screenshots, mouse and keyboard input, Windows UI Automation, PowerShell commands with managed jobs, and authenticated file uploads/downloads. Connects over remote MCP Streamable HTTP or local stdio without a separate host-side gateway.Apache 2.0