screenshot-feedback-hook-mcp 👁
中文 | English
让 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 工具读图 |
| DeepSeek Harness 插件 | agent 主动调用,或操作后 / 轮次结束时自动触发 | 截图存进 dsh 的持久附件库,作为图片块直接进上下文,agent 什么都不用做 |
图片默认降采样(最长边 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()—— 列出显示器编号/分辨率。
接入 DeepSeek Harness(dsh 原生插件)
DeepSeek Harness 用户请走原生插件,别走上面的 MCP:dsh 有持久图片附件服务,插件可以把截图直接变成图片块推进上下文,agent 不需要主动调任何工具。
dsh plugin --profile web add dsh-screenshot-feedback-hook-mcp
dsh web
本包是一个 dsh 组合包(bundle):package.json 里的 dsh.bundle.patch 指向包内自带的 cordis.patch.yml。dsh plugin add 认出这个 manifest 后,会把包名追加进 profile 的 dsh.profile.bundles,那一层 patch 随即组合进配置树 —— 你不需要手写任何 patch。装完用 dsh --profile web --dump-config 能看到多出来的 # == dsh-screenshot-feedback-hook-mcp 层和 id: screenshot-feedback 那一行。
要求 dsh ≥ v0.1.0-rc.8、PATH 上有 pnpm、Python 包 ≥ 0.3.0,以及一个支持图片输入的模型。
装好后可以在 设置 → 插件 → 插件配置 → 截图反馈 那张卡片上直接调参(显示器、各种等待时间、两个默认关闭的自动截图时机等),存完免重启即生效。完整字段表与工作原理见 dsh-plugin/README.zh.md。
接入 Claude Code hook(操作后自动截图)
手动配置步骤
第 1 步 · 选触发时机
| 触发 | 何时截图 | 适合 |
|---|---|---|
Stop |
Claude 每次回答结束时截一张 | 大多数场景,频率适中、省心 |
PostToolUse |
每次匹配到的工具(如 Edit/Write)执行后截 |
想在每次改动后立刻看到效果 |
第 2 步 · 按场景填参数
--monitor N:视觉输出所在的显示器。0=全部拼接,1..N=单屏。先跑uvx screenshot-feedback-hook-mcp monitors看编号。--delay 秒:截图前等待,确保画面渲染完成(前端1、EDA/CAD 视渲染速度可设2~5)。--max-edge 像素/--target-kb 体积:一般用默认即可(最长边 1568px、~80KB)。
第 3 步 · 写入 .claude/settings.json
项目级配置放项目根目录的 .claude/settings.json;想全局生效放用户级 ~/.claude/settings.json。模板见下方与 examples/。
第 4 步 · 验证
重启 Claude Code 会话,触发一次对应事件,确认 Claude 收到「截图已保存到 …」并主动用 Read 读了图。
模板 A:每次 Claude 停下来时截图(Stop,推荐起点)
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "uvx screenshot-feedback-hook-mcp capture --delay 1 --hook-output stop"
}
]
}
]
}
}
模板 B:每次改完文件后截图(PostToolUse)
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "uvx screenshot-feedback-hook-mcp capture --delay 2 --hook-output post-tool-use"
}
]
}
]
}
}
原理
CLI 会输出正确的 hook JSON(Stop 用 decision:block 回传文字并自动处理 stop_hook_active 防死循环;PostToolUse 用 hookSpecificOutput.additionalContext),agent 看到「截图已保存到 …,请用 Read 工具读取」后会读图。因为 hook 只能回传文本,所以走「回传路径 + agent 用 Read 读图」这条路;想让 agent 直接拿到图片块请用上面的 MCP 方式。
平台注意事项 / 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.
Metadata
Release files for screenshot-feedback-hook-mcp 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| screenshot_feedback_hook_mcp-0.3.0.tar.gz | 180.6 kB | Without provenance | Details for screenshot_feedback_hook_mcp-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| screenshot_feedback_hook_mcp-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for screenshot_feedback_hook_mcp-0.3.0-py3-none-any.whl |
Total release size: 196.8 kB
Release files / screenshot_feedback_hook_mcp-0.3.0.tar.gz
| Download URL | screenshot_feedback_hook_mcp-0.3.0.tar.gz |
|---|---|
| Size | 180.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d521237b45d31cd7befe3bf82ca90018bc1939a58c4c3644a079182cf28c28a
|
|
BLAKE2b-256 checksum How to use checksums |
bb47c1230337322b434cccd12345dfc612c8b995954aceaef0df6e510e18510e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / screenshot_feedback_hook_mcp-0.3.0-py3-none-any.whl
| Download URL | screenshot_feedback_hook_mcp-0.3.0-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
596e6c28857c142df0f63799904dd456d0e076926395026f9f54aaa3f85d67a3
|
|
BLAKE2b-256 checksum How to use checksums |
210fcee2bda6fda41cf16452723606859393c21c060f7682132fdaef679be2dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Security for screenshot-feedback-hook-mcp 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.