Skip to main content
Glama

screen-mcp

一个 MCP(Model Context Protocol)服务器,为 AI 代理提供在 Omarchy / Hyprland Wayland 桌面上的眼睛。它通过 grim 捕获截图,并提供由 Gemini API 驱动的可选图像分析——当调用模型没有原生视觉编码器时非常有用。

功能

工具

功能

返回

list_windows

通过 hyprctl 枚举 Hyprland 窗口

包含地址、标题、工作区和大小的文本列表

screenshot_region

捕获像素矩形 (x, y, width, height)

内嵌 PNG 图像(base64)

screenshot_window

按标题、类、地址或 "focused" 捕获窗口

内嵌 PNG 图像(base64)

screenshot_fullscreen

捕获整个屏幕

内嵌 PNG 图像(base64)

analyze_image

将图像(base64 或文件路径)发送给 Gemini 进行推理

文本响应

screenshot_and_analyze

在一次调用中捕获区域并进行分析

文本(Gemini 响应)

截图使用 grim(wlroots screencopy 协议)——无需 X11。

前提条件

  • Omarchy、Hyprland 或任何基于 wlroots 的 Wayland 合成器

  • grim — Wayland 截图工具

  • slurp —(可选)交互式区域选择辅助工具

  • hyprctl — Hyprland 窗口/查询 CLI

  • jq —(可选)某些辅助脚本使用

使用以下命令检查:

grim --help && hyprctl clients -j | head -c 20

用于图像分析(可选)

export GEMINI_API_KEY="your-api-key-here"

没有密钥时,截图工具仍然可用;只有 analyze_imagescreenshot_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/genai SDK。图像以 base64 内嵌形式传递给 Gemini API 的 interactions.create 端点。

  • 服务器src/index.ts 使用 @modelcontextprotocol/server 将所有内容整合为一个基于 stdio 传输的 MCP 服务器。

许可证

MIT

-
license - not tested
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

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

View all MCP Connectors

Latest Blog Posts

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