Skip to main content

A MCP server for generating web page screenshots using Playwright

Project description

webshot-mcp

中文文档 | English

A MCP (Model Context Protocol) server for generating web page screenshots, implemented with Playwright.

Features

  • 🌐 Support for any web page screenshots
  • 📱 Support for multiple device types (desktop, mobile, tablet)
  • 🎨 Support for multiple image formats (PNG, JPEG, WebP)
  • 📏 Support for custom dimensions and DPI scaling
  • 🖼️ Support for full-page screenshots
  • 🗜️ Support for image quality compression
  • ⚡ Asynchronous processing for excellent performance

Usage

As MCP Server

Method 1: Run directly with uvx (Recommended)

{
  "mcpServers": {
    "webshot": {
      "command": "uvx",
      "args": ["webshot-mcp"]
    }
  }
}

Method 2: Use with Claude Code

Claude Code can be configured to use this MCP server in two ways:

Option A: Using the CLI wizard

claude mcp add

Then follow the prompts to add webshot-mcp.

Option B: Direct config file editing (Recommended)

Edit your Claude Code configuration file (~/.claude.json) and add:

{
  "mcpServers": {
    "webshot": {
      "type": "stdio",
      "command": "uvx",
      "args": ["webshot-mcp"]
    }
  }
}

After editing the config file, restart Claude Code to apply the changes.

Method 3: Install with pip and run

# Install webshot-mcp
pip install webshot-mcp
# Install chromium browser
playwright install chromium

Then add to your MCP client configuration:

For Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "webshot": {
      "command": "webshot-mcp"
    }
  }
}

For Claude Code (~/.claude.json):

{
  "mcpServers": {
    "webshot": {
      "type": "stdio",
      "command": "webshot-mcp"
    }
  }
}

Tool Parameters

The webshot tool supports the following parameters:

Required Parameters

  • url (string): URL of the web page to screenshot
  • output (string): Path to save the screenshot file

Optional Parameters

  • width (integer): Browser window width, default 1280
  • height (integer): Browser window height, default 768. Set to 0 for full-page screenshot
  • dpi_scale (number): DPI scaling ratio, default 2
  • device (string): Device type, options:
    • desktop (default): Desktop device
    • mobile: Mobile device (iPhone 13)
    • tablet: Tablet device (iPad Pro)
  • format (string): Image format, options:
    • png (default): PNG format
    • jpeg: JPEG format
    • webp: WebP format
  • quality (integer): Image quality (0-100), default 100. Only effective for JPEG and WebP formats

Usage Examples

Basic Screenshot

{
  "name": "webshot",
  "arguments": {
    "url": "https://example.com",
    "output": "/tmp/screenshot.png"
  }
}

Full-page Screenshot

{
  "name": "webshot", 
  "arguments": {
    "url": "https://example.com",
    "output": "/tmp/fullpage.png",
    "height": 0
  }
}

Mobile Device Screenshot

{
  "name": "webshot",
  "arguments": {
    "url": "https://example.com",
    "output": "/tmp/mobile.png",
    "device": "mobile"
  }
}

High-quality JPEG Screenshot

{
  "name": "webshot",
  "arguments": {
    "url": "https://example.com", 
    "output": "/tmp/screenshot.jpg",
    "format": "jpeg",
    "quality": 90
  }
}

Custom Size Screenshot

{
  "name": "webshot",
  "arguments": {
    "url": "https://example.com",
    "output": "/tmp/custom.png",
    "width": 1920,
    "height": 1080,
    "dpi_scale": 1
  }
}

Development

Run Tests

uv run pytest

Code Structure

webshot-mcp/
├── src/webshot_mcp/
│   ├── __init__.py
│   ├── cli.py          # CLI entry point
│   └── server.py       # MCP server implementation
├── tests/
│   └── test_server.py  # Test cases
├── pyproject.toml      # Project configuration
└── README.md

Tech Stack

  • MCP: Model Context Protocol framework
  • Playwright: Browser automation and screenshots
  • Pillow: Image processing and compression
  • asyncio: Asynchronous programming support

Publishing

Build and Publish to PyPI

# Install build tools
uv add --dev build twine

# Build package
uv run python -m build

# Publish to PyPI
uv run twine upload dist/*

License

MIT License

Contributing

Issues and Pull Requests are welcome!

Changelog

v0.1.0

  • Initial release
  • Support for basic web page screenshot functionality
  • Support for multiple device types and image formats
  • Support for image quality compression and size adjustment

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

webshot_mcp-0.1.2.tar.gz (81.9 kB view details)

Uploaded Source

Built Distribution

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

webshot_mcp-0.1.2-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file webshot_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: webshot_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 81.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for webshot_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7e18e75e1bb42103097fdc511f28b09790b4b334a1e977d5b8c5fdfb3fa90f76
MD5 b4496a368754d993f7196d77d469eb0d
BLAKE2b-256 61978c8af620c04ab11767687f068b7dec5ed905be4f12f595928e67222b983c

See more details on using hashes here.

File details

Details for the file webshot_mcp-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: webshot_mcp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for webshot_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 24bae0fb001172a87634093d214b4d83dd831f34a20a157fdb368df7b930befb
MD5 be13822cd9c1d047933e97c5a0aac5f5
BLAKE2b-256 331849c58496b853255c535d7b8302f192e82a5e8d314fdebe88b3841dc7d463

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