屏幕截图mcp
用于编码代理的跨平台MCP服务器截图
通过模型上下文协议在Linux(Wayland/X11)、windows和macOS上捕获应用程序窗口。
版本: 0.6.0 | 更新日志
状态
| 平台 | 后端 | 状态 |
|---|---|---|
| Linux | Wayland | ✅ 生产就绪(门户+恢复令牌) |
| Linux | X11 | ✅ 生产就绪(直接捕获) |
| Windows | WGC | ✅ 生产就绪(图形捕获API) |
| macOS | 屏幕捕获工具包 | 📅 计划(M5) |
快速开始
git clone https://github.com/username/screenshot-mcp.git
cd screenshot-mcp
cargo build --release需要依赖关系? 看 平台设置 Linux软件包或Windows构建工具。
配置Claude桌面
Linux: ~/.config/Claude/claude_desktop_config.json 窗户: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"screenshot": {
"command": "/path/to/screenshot-mcp",
"env": { "RUST_LOG": "screenshot_mcp=info" }
}
}
}工具
| 工具 | 说明 |
|---|---|
health_check | 检测平台和后端状态 |
list_windows | 枚举可捕获的窗口 |
capture_window | 窗口截图(带裁剪/缩放选项) |
prime_wayland_consent | 仅限Wayland:启动许可流程 |
运作原理
flowchart LR
A[Agent] --> B{Platform?}
B -->|Wayland| C[prime_wayland_consent]
C --> D[User approves]
D --> E[Token stored]
E --> F[capture_window]
B -->|X11/Windows| F
F --> G[Screenshot + File]韦兰: 需要通过门户对话获得一次性同意。Token允许之后进行无头捕获。
X11/Windows: 直接捕获——无需同意流程。
输出
每次捕获都会返回:
- 图像数据: Base64编码的WebP(默认)、PNG或JPEG
- 文件链接: 临时目录中的带时间戳的文件
- 元数据: 尺寸、格式、大小和捕获选项
{
"content": [
{ "type": "image", "mimeType": "image/webp", "data": "UklGR..." },
{ "type": "text", "text": "[Screenshot](file:///tmp/screenshot-mcp/screenshot-2025-01-01.webp)" },
{ "type": "text", "text": "## Capture Metadata\n{\"dimensions\": [1920, 1080], \"format\": \"webp\"}" }
]
}捕获选项(v0.6.0+)
| 选项 | 默认值 | 描述 |
|---|---|---|
format | webp | 输出格式: webp, png, jpeg |
quality | 80 | 压缩(0-100,适用于webp/jpeg) |
scale | 1.0 | 调整因子(0.1-2.0) |
includeCursor | false | 在捕获中包含光标 |
region | - | 作物种植面积 {x, y, width, height} |
文档
演出
| 后端 | P95延迟 |
|---|---|
| Wayland | ~300ms(无头) |
| X11 | ~400ms |
| 窗口 | ~300ms |
看 发展.md 用于调整提示。
许可证
麻省理工学院
