About Playwright Screenshot
Playwright Screenshot is an MCP server published by Mr-wang007s in the Browser category: mCP server: Playwright Screenshot.
The repository has 1 stars and 0 forks, with the last commit a year ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues before depending on it in production.
Install
git clone https://github.com/Mr-wang007s/mcp-playwright-screenshotThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about Playwright Screenshot
Powered by Claude · Grounded in docs
Security checks
Static checks derived from the repository 21 hours ago. Heuristics on the source, not an audit.
- ✓README presentThe repository ships documentation.
- !License declaredNo license file. Legally you have no right to use it in a product.
- !Tests presentNo tests found. Behaviour changes may go unnoticed between versions.
- ✓Dependencies pinnedA lockfile pins dependency versions.
- ✓No dynamic code executionSource scan found no eval, dynamic Function, or shell execution.
- !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.
README
mcp-playwright-screenshot
MCP server that captures webpage screenshots using Playwright and returns the PNG image as base64 via MCP "image" content. Includes domain safety guards and size limits.
- Tech: TypeScript, Playwright, MCP SDK, stdio transport
- Tool name: screenshot
- Output: image/png (base64)
Features
- Playwright chromium, headless
- Full-page or viewport screenshots
- Viewport and deviceScaleFactor control
- Navigation waitUntil: load | domcontentloaded | networkidle (default)
- Security:
- Only http/https
- Blocks government domains (*.gov, *.gov.TLD)
- Blocks localhost and private IP ranges (127/8, 10/8, 172.16–31/12, 192.168/16, ::1, fc00::/7, fe80::/10)
- Limits:
- Max viewport width: 12000
- Max viewport and full-page height: 100000
Project structure
- src/server.ts: MCP server (stdio), tool wiring, Zod input schema
- src/screenshot.ts: Playwright logic, validation, PNG base64 result
- src/types.ts: Types, ErrorCodes, CodedError
- src/security/domainGuard.ts: URL normalization and domain/IP guard
- src/security/sizeGuard.ts: Viewport/full-page size guards
- src/utils/file.ts: File utilities (not used by tool output; kept for potential file saving)
Requirements
- Node.js 18+ (ESM, NodeNext)
- npm
- Playwright browsers: install with npx playwright install
Install
npm install
npx playwright install
Scripts
# Dev (TypeScript via ts-node/esm)
npm run dev
# Build to dist/
npm run build
# Start built server
npm start
Server runs as an MCP stdio server (reads/writes JSON-RPC over stdio).
MCP tool
- Name: screenshot
- Description: Capture a URL as PNG; returns base64 image content; includes domain/size guards.
Input schema (Zod, defaults shown):
- url: string (required, http/https only)
- fullPage: boolean = true
- viewport: { width: number; height: number } (default 1280x800)
- deviceScaleFactor: number = 1 (> 0)
- waitUntil: "load" | "domcontentloaded" | "networkidle" = "networkidle"
- timeoutMs: number = 30000 (positive integer)
- darkMode: boolean = false
Output:
- content: [{ type: "image", data: , mimeType: "image/png" }]
Example (JSON-RPC over stdio)
List tools:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}
Call screenshot:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "screenshot",
"arguments": {
"url": "https://example.com",
"fullPage": true,
"viewport": { "width": 1280, "height": 800 },
"deviceScaleFactor": 1,
"waitUntil": "networkidle",
"timeoutMs": 30000,
"darkMode": false
}
}
}
Successful result (truncated):
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"content": [
{
"type": "image",
"data": "iVBORw0KGgoAAA... (base64) ...",
"mimeType": "image/png"
}
]
}
}
Error handling
All errors return isError: true with a text message. Error codes:
- E_INVALID_URL: URL invalid or not http/https
- E_BLOCKED_DOMAIN: Government domain or localhost/private IP is blocked
- E_SIZE_EXCEEDED: Viewport or page size out of bounds; invalid numeric params
- E_NAVIGATION_TIMEOUT: Page navigation timed out
- E_SCREENSHOT_FAILED: Navigation or screenshot failure
- E_IO_ERROR: Generic I/O error
Example error response:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"isError": true,
"content": [
{ "type": "text", "text": "E_BLOCKED_DOMAIN: 禁止访问政府类站点: example.gov" }
]
}
}
Security notes
- Hostname normalized (lowercase, Punycode) before checks
- Blocks: *.gov and *.gov.TLD; localhost; private IP literals (IPv4, IPv6)
- No DNS resolution is performed for security checks
Behavior notes
- Headless chromium
- PNG only
- darkMode switches
colorSchemeto "dark" - Full page height is validated before screenshot
Development
- ESM + TypeScript (NodeNext)
- Zod for request validation
- Stdio transport via @modelcontextprotocol/sdk
License
MIT (add a LICENSE file if required).
README fetched from the repository 21 hours ago. The original is authoritative.