mcp-page-capture

mcp-page-capture is a Model Context Protocol (MCP) server that orchestrates headless Chromium via Puppeteer to capture pixel-perfect screenshots of arbitrary URLs. It is optimized for Copilot/MCP-enabled environments and can be embedded into automated workflows or run as a standalone developer tool.
Features
- šø High-fidelity screenshots powered by Puppeteer and headless Chromium
- āļø LLM-optimized schema with minimal parameters exposed and sensible defaults
- š Structured DOM extraction with optional CSS selectors for AI-friendly consumption
- š± Device presets for mobile emulation (iPhone, iPad, Android, desktop)
- šÆ 6 simplified steps for LLM friendliness:
viewport,wait,fill,click,scroll,screenshot - š¤ Smart defaults - screenshot auto-captured, field types auto-detected
- š Consistent parameters -
targetfor elements,forfor waiting,tofor scrolling,devicefor viewport - š Automatic retry with exponential backoff for transient failures
- š Telemetry hooks for centralized observability and monitoring
- š¾ Pluggable storage backends (local filesystem, S3, memory)
- š”ļø Structured logging plus defensive error handling for operational visibility
- š Launch via
npm start,npm run dev, or as a long-lived MCP sidecar - š³ Docker image with multi-platform support (amd64, arm64)
How It Works
- The MCP transport boots a Node.js server and registers the
captureScreenshotandextractDomtools. - Incoming tool invocations are validated against the relevant type definitions.
- Puppeteer starts (or reuses) a Chromium instance, navigates to the requested URL, and either captures a screenshot or serializes the DOM according to the tool parameters.
- The server returns structured content (images, text, DOM trees, metadata) to the caller or downstream workflow.
Requirements
- Node.js ā„ 18.x
- npm ā„ 9.x
- Chromium package download permissions (first run)
- Network access to the target URLs
š LLM-Friendly Features
Simplified Schema (5-Star LLM Rating)
- ā
Only 4 top-level parameters:
url,steps,headers,validate - ā Exactly 6 step types (no more, no less)
- ā Consistent parameter naming across all steps
- ā Automatic screenshot if omitted
- ā Smart field type detection
- ā Actionable error messages with recovery suggestions
- ā Single source of truth for all schemas
- ā Deprecation warnings for legacy parameters
- ā NEW: Validate mode for pre-flight step checking
- ā NEW: Step order enforcement with auto-correction
- ā NEW: Embedded LLM reference in MCP server instructions
Quick Start for LLMs
See LLM Quick Reference for the 6 primary step types and common patterns.
For advanced features, see Advanced Steps.
The 6 Step Types (Exactly 6, No More)
| Step | Purpose | Key Parameters | Example |
|---|---|---|---|
viewport | Set device | device, width, height | { "type": "viewport", "device": "mobile" } |
wait | Wait for element/time | for OR duration, timeout | { "type": "wait", "for": ".loaded" } |
fill | Fill form field | target, value, submit | { "type": "fill", "target": "#email", "value": "a@b.com" } |
click | Click element | target, waitFor | { "type": "click", "target": "button", "waitFor": ".result" } |
scroll | Scroll page | to, y | { "type": "scroll", "to": "#footer" } |
screenshot | Capture (auto-added) | fullPage, element | { "type": "screenshot", "fullPage": true } |
Step Order: Auto-fixed! viewport auto-moves to first, screenshot auto-added at end.
Composite Patterns (NEW)
High-level patterns that auto-expand to multiple steps:
// Login pattern
{
"type": "login",
"email": { "selector": "#email", "value": "user@example.com" },
"password": { "selector": "#password", "value": "secret" },
"submit": "button[type=submit]",
"successIndicator": ".dashboard"
}
// Search pattern
{
"type": "search",
"input": "#search-box",
"query": "MCP protocol",
"resultsIndicator": ".search-results"
}Installation
From source (recommended during development)
git clone https://github.com/chasesaurabh/mcp-page-capture.git
npm installFrom npm
# Run without installing globally
npx mcp-page-capture
# Or add it to your toolchain
npm install -g mcp-page-capture
mcp-page-captureRunning the server
npm install
npm run build
npm startFor hot reload while iterating locally, run npm run dev.
Why Docker?
- Guarantees a consistent Puppeteer + Chromium environment with all system libraries when teammates or CI run the server. No more "it works on my machine" mismatches.
- Provides a ready-to-deploy container image for hosting mcp-page-capture as a sidecar/service on Kubernetes, ECS, Fly.io, etc.
If you need those guarantees, build and run via:
docker build -t mcp-page-capture .
docker run --rm -it mcp-page-captureOtherwise you can keep using the standard npm scripts locally.
IDE MCP configuration
{
"mcpServers": {
"page-capture": {
"command": "node",
"args": ["dist/cli.js"]
}
}
}Note: You may need to use the full path to dist/cli.js or node depending on your working directory and Node.js module resolution configuration.
Programmatic usage
If you want to embed the server inside another Node.js process, import the helpers exposed by the package:
import { startMcpPageCaptureServer } from "mcp-page-capture";
await startMcpPageCaptureServer();
// Optionally pass a custom Transport implementation if you don't want stdio.Usage
Tool invocation examples
Basic Screenshot
{
"tool": "captureScreenshot",
"params": {
"url": "https://example.com"
}
}Note: A screenshot is automatically captured at the end if no explicit screenshot step is provided.
Search with Fill Step (Recommended)
The fill step auto-detects field types and handles text inputs, selects, checkboxes, and radio buttons.
{
"tool": "captureScreenshot",
"params": {
"url": "https://example.com",
"steps": [
{ "type": "fill", "target": "#search", "value": "MCP protocol", "submit": true },
{ "type": "wait", "for": ".search-results" },
{ "type": "screenshot" }
]
}
}Login Form Example
{
"tool": "captureScreenshot",
"params": {
"url": "https://example.com/login",
"steps": [
{ "type": "wait", "for": "#login-form" },
{ "type": "fill", "target": "#email", "value": "user@example.com" },
{ "type": "fill", "target": "#password", "value": "secretpassword" },
{ "type": "fill", "target": "#remember-me", "value": "true" },
{ "type": "click", "target": "button[type=submit]", "waitFor": ".dashboard" },
{ "type": "screenshot" }
]
}
}Full Page Screenshot
{
"tool": "captureScreenshot",
"params": {
"url": "https://docs.modelcontextprotocol.io",
"steps": [
{ "type": "screenshot", "fullPage": true }
]
}
}With Authentication and Cookies
{
"tool": "captureScreenshot",
"params": {
"url": "https://example.com/dashboard",
"headers": {
"authorization": "Bearer dev-token"
},
"steps": [
{
"type": "cookie",
"action": "set",
"name": "session",
"value": "abc123",
"path": "/secure"
},
{ "type": "screenshot" }
]
}
}Extract DOM Content
{
"tool": "extractDom",
"params": {
"url": "https://docs.modelcontextprotocol.io",
"selector": "main article"
}
}Mobile Device Emulation
{
"tool": "captureScreenshot",
"params": {
"url": "https://example.com",
"steps": [
{ "type": "viewport", "device": "ipad-pro" },
{ "type": "scroll", "to": "#main-content" },
{ "type": "screenshot" }
]
}
}Step Types
6 Primary Steps (LLM-Exposed)
These are the only steps exposed to LLMs. They cover 95%+ of use cases:
| Step | Purpose | Parameters |
|---|---|---|
viewport | Set device/screen size | device, width, height |
wait | Wait for element/time | for OR duration, timeout |
fill | Fill form field | target, value, submit |
click | Click element | target, waitFor |
scroll | Scroll page | to (selector), y (pixels) |
screenshot | Capture (auto-added) | fullPage, element |
Validate Mode (NEW)
Use validate: true to check steps before execution:
{
"tool": "captureScreenshot",
"params": {
"url": "https://example.com",
"steps": [
{ "type": "fill", "target": "#email", "value": "test@example.com" },
{ "type": "click", "target": "button" }
],
"validate": true
}
}Returns validation analysis including:
- Errors: Missing required parameters
- Warnings: Step order issues (e.g., viewport not first)
- Suggestions: Recommended improvements (e.g., add
waitForto click) - Step analysis: Per-step status and notes
Deprecated Steps (Legacy Support Only)
These work at runtime but are not exposed in the LLM schema. Use the 6 primary steps instead:
| Deprecated | Use Instead |
|---|---|
quickFill | fill with submit: true |
fillForm | Multiple fill steps |
waitForSelector | wait with for parameter |
delay | wait with duration parameter |
fullPage | screenshot with fullPage: true |
Internal Steps (Not Exposed)
These are for power users only and are not documented in the tool schema:
type, hover, cookie, storage, evaluate, keypress, focus, blur, clear, upload, submit
Legacy Parameter Support
For backward compatibility, these parameters work at runtime but are not exposed in the LLM schema:
| Legacy Parameter | Canonical | Notes |
|---|---|---|
selector | target | Use target for element selectors |
awaitElement | for | Use for in wait steps |
scrollTo | to | Use to in scroll steps |
preset | device | Use device in viewport steps |
captureElement | element | Use element in screenshot steps |
waitAfter | wait | Use wait in click steps |
Deprecation warnings are logged when legacy parameters are used.
Example response
{
"content": [
{
"type": "text",
"text": "mcp-page-capture screenshot\nURL: https://example.com\nCaptured: 2025-12-13T08:30:12.713Z\nFull page: false\nViewport: 1280x720\nDocument: 1280x2000\nScroll position: (0, 0)\nSize: 45.2 KB\nSteps executed: 5"
},
{
"type": "image",
"mimeType": "image/png",
"data": "iVBORw0KGgoAAAANSUhEUgA..."
}
]
}
## Supported options
### `captureScreenshot`
- `url` (string, required): Fully-qualified URL to capture
- `headers` (object, optional): Key/value map of HTTP headers to send with the initial page navigation
- `cookies` (array, optional): List of cookies to set before navigation. Each cookie supports `name`, `value`, and optional `url`, `domain`, `path`, `secure`, `httpOnly`, `sameSite`, and `expires` (Unix timestamp, sec
ā¦