webshot-mcp
Enables agents to take screenshots and extract text from web pages using a persistent Chrome browser via CDP, with built-in SSRF protection.
README
webshot-mcp
Give your agent eyes — without giving it a browser or your network.
An MCP server with two tools, screenshot and page_text, that connects to a
Chrome you already have running (over CDP) and captures full pages or single
elements. No browser is ever launched or downloaded; private-network targets
are blocked by an SSRF-aware URL policy.
Why this exists
Two lessons from running visual check → fix loops with coding agents:
- Launching a browser per screenshot is the slow, flaky way. A persistent
headless Chromium (Docker sidecar, CI service, your desktop Chrome with
--remote-debugging-port) is warm, shared, and reliable. The missing piece is a disciplined client: connect over CDP, open a fresh context per shot, close only what you opened, never kill the shared browser. That discipline is this repo. - A screenshot tool inside your network is an SSRF proxy with a camera.
An agent that can be talked into "screenshot
http://169.254.169.254/…" orhttp://redis.internal:6379/will happily photograph your cloud metadata endpoint. So the URL policy blocks loopback, RFC-1918, link-local, CGNAT, and v6-local targets — including hostnames that resolve to them — unless you allowlist the hostname explicitly. Local dev servers are the legitimate exception, and you name them one by one.
Quick start
npm install
npm test # URL-policy test suite — no browser needed
npm run demo # policy walkthrough + a real screenshot if a CDP Chrome is reachable
Get a CDP-enabled Chrome (any one of):
# your installed Chrome, headless
chrome --headless --remote-debugging-port=9222 --remote-debugging-address=127.0.0.1 about:blank
# or a Docker sidecar you keep running
docker run -d -p 127.0.0.1:9222:9222 chromedp/headless-shell
Wire into Claude Code:
claude mcp add webshot \
-e WEBSHOT_CDP_URL=http://127.0.0.1:9222 \
-e WEBSHOT_ALLOW_HOSTS=localhost,127.0.0.1 \
-- npx tsx src/server.ts
Then ask the agent things like "screenshot the hero section of
localhost:5173 — just .hero — and tell me what's off": selector crops to
one element, which keeps the agent's attention (and your tokens) on the part
under discussion instead of a 4,000-px page.
Tools
| Tool | Contract |
|---|---|
screenshot |
url, optional selector (element crop), fullPage, viewport width/height, settleMs. Returns the PNG as MCP image content + {finalUrl, title, httpStatus}. Refuses to capture HTTP ≥ 400 — a screenshot of an error page silently poisons whatever the agent does next. |
page_text |
Body innerText — the cheap check when the agent needs to read, not see. Same URL policy. |
Design notes
- Fresh context per shot, shared browser for life. Contexts are cheap and
isolated (cookies, cache, viewport); the browser is expensive and shared.
browser.close()on a CDP connection disconnects without killing the remote browser — the server can restart all day without touching Chrome. - DNS is checked, rebinding is documented. Non-IP hostnames are resolved and every returned address re-verified against the private ranges. A malicious DNS server that answers differently on the browser's own second resolution (classic rebinding) is out of scope for a screenshot tool — noted here rather than hand-waved.
deviceScaleFactor: 2— retina captures, because agents (and humans) misread blurry text in screenshots more often than you'd think.- Policy is fail-closed and testable.
evaluateUrlis a pure function with the entire threat table in its test file; the server never calls the browser before the policy says yes.
Stack
TypeScript · @modelcontextprotocol/sdk (stdio) · playwright-core (CDP
client only — no bundled browsers) · zod · vitest.
License
MIT © Brandon Ta
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。