Skip to main content

Screenshot feedback for coding agents — let your agent SEE what it builds (MCP server + Claude Code hook)

Project description

screenshot-feedback-hook-mcp 👁

让 coding agent 看到自己产出的真实画面 —— 跨平台截图反馈工具(MCP server + Claude Code hook 双层)。

Let your coding agent see what it builds: a cross-platform (Windows / Linux / macOS) screenshot-feedback tool for AI agents, shipped as an MCP server plus a Claude Code hook helper.

为什么需要它 / Why

Agent 写前端、画 EasyEDA/CAD 工程图时,没有视觉反馈就只能猜。给它一个「截图 → 看图 → 自我纠正」的回路,产出质量立刻不一样。

技术现实:Claude Code 的 hook 只能回传文本,而 MCP 工具可以回传原生图片。所以本工具做成双层:

触发方式 图片如何进入 agent 视野
MCP server agent 主动调用 take_screenshot 工具直接返回原生图片块(跨 MCP 客户端通用)
Claude Code hook 某操作后自动触发 hook 回传截图的绝对路径,agent 用 Read 工具读图

图片默认降采样(最长边 1568px)并按字节预算(~80KB)迭代压缩 JPEG,避开 Claude Code 对 MCP 输出 ~25k token 的限制。

安装 / Install

零安装运行(需要 uv):

# MCP server(无参数 = MCP server)
uvx screenshot-feedback-hook-mcp

# CLI 截图(带子命令 = CLI)
uvx screenshot-feedback-hook-mcp capture --monitor 0 --out shot.jpg
uvx screenshot-feedback-hook-mcp monitors

或常驻安装:pipx install screenshot-feedback-hook-mcp / uv tool install screenshot-feedback-hook-mcp

接入 MCP(推荐起点)

Claude Code 一行:

claude mcp add screenshot-feedback -- uvx screenshot-feedback-hook-mcp

或任意 MCP 客户端(Cursor / Cline / Windsurf...)的 mcp.json:

{
  "mcpServers": {
    "screenshot-feedback": {
      "command": "uvx",
      "args": ["screenshot-feedback-hook-mcp"]
    }
  }
}

工具:

  • take_screenshot(monitor=0) —— 截屏,直接返回图片。0=全部显示器拼接,1..N=单屏。
  • list_monitors() —— 列出显示器编号/分辨率。

接入 Claude Code hook(操作后自动截图)

把样例(见 examples/)复制进项目 .claude/settings.json。例如「每次 Claude 停下来时自动截图给它看」:

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "uvx screenshot-feedback-hook-mcp capture --delay 1 --hook-output stop"
          }
        ]
      }
    ]
  }
}

CLI 会输出正确的 hook JSON(Stop 用 decision:block 回传文字并自动处理 stop_hook_active 防死循环;PostToolUse 用 hookSpecificOutput.additionalContext),agent 看到「截图已保存到 …,请用 Read 工具读取」后会读图。

常用参数:--monitor N--delay 秒(等渲染完)、--max-edge 像素--target-kb 体积

平台注意事项 / Platform notes

  • Windows:开箱即用。
  • macOS:首次使用需在「系统设置 → 隐私与安全性 → 屏幕录制」勾选运行 agent 的终端/IDE 并重启该应用,否则截到黑屏/壁纸(工具会检测并提示)。
  • Linux:X11 开箱即用;纯 Wayland 下 mss 受限,工具启动时会探测并提示(grim/portal 后端在 roadmap)。

Roadmap

  • 区域截图(--region x,y,w,h
  • 按窗口标题截图(Win EnumWindows / mac CGWindowList / Linux wmctrl)
  • URL / 无头浏览器模式(前端确定性截图)
  • Wayland 后端(grim / xdg-desktop-portal)

开发 / Development

uv sync           # 安装依赖
uv run pytest     # 测试
uv run screenshot-feedback-hook-mcp capture --out shot.jpg   # CLI
uv run screenshot-feedback-hook-mcp                          # MCP server

MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

screenshot_feedback_hook_mcp-0.2.0.tar.gz (89.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

screenshot_feedback_hook_mcp-0.2.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file screenshot_feedback_hook_mcp-0.2.0.tar.gz.

File metadata

  • Download URL: screenshot_feedback_hook_mcp-0.2.0.tar.gz
  • Upload date:
  • Size: 89.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for screenshot_feedback_hook_mcp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 76b5c8b1682036db6f96c9f8e10f3abcd26d24b4e6268af20255d18c50e2c658
MD5 988c9ac12cca52724d283da85f35b82e
BLAKE2b-256 6db32faa15121bcf38a4ee2b58553299029570435b3ebacbbf20b93d239f9851

See more details on using hashes here.

File details

Details for the file screenshot_feedback_hook_mcp-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: screenshot_feedback_hook_mcp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for screenshot_feedback_hook_mcp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d98043f0f159511aa9e3fbbb033c63e85f7316a54b99f7911be91be27d719e0
MD5 84eb48289e4027fc240c33c2c2733327
BLAKE2b-256 b84c9faae3b31645d46334c0092e247997a49eb1e7c0d825e8d255df3ae21af5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page