screen-mcp
screen-mcp
一个 MCP(Model Context Protocol)服务器,为 AI 代理提供在 Omarchy / Hyprland Wayland 桌面上的眼睛。它通过 grim 捕获截图,并提供由 Gemini API 驱动的可选图像分析——当调用模型没有原生视觉编码器时非常有用。
功能
工具 | 功能 | 返回 |
| 通过 | 包含地址、标题、工作区和大小的文本列表 |
| 捕获像素矩形 | 内嵌 PNG 图像(base64) |
| 按标题、类、地址或 | 内嵌 PNG 图像(base64) |
| 捕获整个屏幕 | 内嵌 PNG 图像(base64) |
| 将图像(base64 或文件路径)发送给 Gemini 进行推理 | 文本响应 |
| 在一次调用中捕获区域并进行分析 | 文本(Gemini 响应) |
截图使用 grim(wlroots screencopy 协议)——无需 X11。
前提条件
Omarchy、Hyprland 或任何基于 wlroots 的 Wayland 合成器
grim— Wayland 截图工具slurp—(可选)交互式区域选择辅助工具hyprctl— Hyprland 窗口/查询 CLIjq—(可选)某些辅助脚本使用
使用以下命令检查:
grim --help && hyprctl clients -j | head -c 20用于图像分析(可选)
一个 Gemini API 密钥——在 https://aistudio.google.com 获取
在环境中导出它:
export GEMINI_API_KEY="your-api-key-here"没有密钥时,截图工具仍然可用;只有 analyze_image 和 screenshot_and_analyze 会返回错误。
安装
通过 Claude Desktop
将此添加到你的 Claude Desktop claude_desktop_config.json 中:
{
"mcpServers": {
"screen-mcp": {
"command": "npx",
"args": ["-y", "screen-mcp"],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}通过 npx
npx -y screen-mcp
# Or install globally:
npm install -g screen-mcp使用示例
捕获屏幕区域
screenshot_region(x=100, y=200, width=800, height=600, include_cursor=true)捕获特定窗口
首先列出可用窗口以获取地址或标题:
list_windows()然后按标题(子字符串匹配)、地址或 "focused" 捕获:
screenshot_window(window="Spotify")
screenshot_window(window="focused")
screenshot_window(window="0x557ba79b4900")使用 Gemini 分析图像
analyze_image(
image_path="/tmp/my-screenshot.png",
prompt="What applications are visible in this screenshot?",
model="gemini-2.5-flash"
)或直接传递 base64 编码的图像数据:
analyze_image(
image="<base64-encoded-image>",
prompt="Describe what you see in this image.",
mime_type="image/png"
)在一次调用中捕获并分析
screenshot_and_analyze(
x=0, y=0, width=1920, height=1080,
prompt="Count the number of windows open and list their titles.",
scale=0.5,
model="gemini-2.5-flash"
)开发
# Install deps
npm install
# Build
npm run build
# Run
npm start
# Development (recompile on change)
npm run dev工作原理
捕获:
src/capture.ts封装了grim(截图)和hyprctl(窗口枚举)。窗口捕获首先尝试grim -T <stableId>(foreign-toplevel 句柄),然后回退到grim -g "<x>,<y> <w>x<h>"(来自 hyprctl 的几何信息)。分析:
src/gemini.ts使用官方@google/genaiSDK。图像以 base64 内嵌形式传递给 Gemini API 的interactions.create端点。服务器:
src/index.ts使用@modelcontextprotocol/server将所有内容整合为一个基于 stdio 传输的 MCP 服务器。
许可证
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Generate images, GIFs, and PDFs from HTML, URLs, or templates — from your AI agent.
Screenshots, PDFs and Markdown from any URL or HTML for AI agents, via the SnapForge API
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/ferre-z/screen-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server