Webpage Screenshot MCP Server

Webpage Screenshot MCP Server

Captures screenshots of web pages using Puppeteer, allowing AI agents to visually verify web applications and see their progress when generating web apps.

Category
访问服务器

README

Webpage Screenshot MCP Server

An MCP (Model Context Protocol) server that captures screenshots of web pages using Puppeteer. This server allows AI agents to visually verify web applications and see their progress when generating web apps.

Screen Recording May 27 2025 (2)

Features

  • Full page screenshots: Capture entire web pages or just the viewport
  • Element screenshots: Target specific elements using CSS selectors
  • Multiple formats: Support for PNG, JPEG, and WebP formats
  • Customizable options: Set viewport size, image quality, wait conditions, and delays
  • Base64 encoding: Returns screenshots as base64 encoded images for easy integration
  • Authentication support: Manual login and cookie persistence
  • Default browser integration: Use your system's default browser for a more natural experience
  • Session persistence: Keep browser sessions open for multi-step workflows

Installation

To install and build the MCP:

# Clone the repository (if you haven't already)
git clone https://github.com/ananddtyagi/webpage-screenshot-mcp.git
cd webpage-screenshot-mcp

# Install dependencies
npm install

# Build the project
npm run build

The MCP server is built using TypeScript and compiled to JavaScript. The dist folder contains the compiled JavaScript files.

Adding to Claude or Cursor

To add this MCP to Claude Desktop or Cursor:

  1. Claude Desktop:

    • Go to Settings > Developer
    • Click "Edit Config"
    • Add the following:
     "webpage-screenshot": {
       "command": "node",
       "args": [
         "~/path/to/webpage-screenshot-mcp/dist/index.js"
       ]
     }
    
    • Save and reload Claude
  2. Cursor:

    • Open Cursor and go to Cursor Settings > MCP
    • Click "Add new global MCP server"
    • Add the following:
  "webpage-screenshot": {
    "command": "node",
    "args": ["~/path/to/webpage-screenshot-mcp/dist/index.js"]
  }
  • Save and reload Cursor

Usage

Tools

This MCP server provides several tools:

1. login-and-wait

Opens a webpage in a visible browser window for manual login, waits for user to complete login, then saves cookies.

{
  "url": "https://example.com/login",
  "waitMinutes": 5,
  "successIndicator": ".dashboard-welcome",
  "useDefaultBrowser": true
}
  • url (required): The URL of the login page
  • waitMinutes (optional): Maximum minutes to wait for login (default: 5)
  • successIndicator (optional): CSS selector or URL pattern that indicates successful login
  • useDefaultBrowser (optional): Whether to use the system's default browser (default: true)

2. screenshot-page

Captures a screenshot of a given URL and returns it as base64 encoded image.

{
  "url": "https://example.com/dashboard",
  "fullPage": true,
  "width": 1920,
  "height": 1080,
  "format": "png",
  "quality": 80,
  "waitFor": "networkidle2",
  "delay": 500,
  "useSavedAuth": true,
  "reuseAuthPage": true,
  "useDefaultBrowser": true,
  "visibleBrowser": true
}
  • url (required): The URL of the webpage to screenshot
  • fullPage (optional): Whether to capture the full page or just the viewport (default: true)
  • width (optional): Viewport width in pixels (default: 1920)
  • height (optional): Viewport height in pixels (default: 1080)
  • format (optional): Image format - "png", "jpeg", or "webp" (default: "png")
  • quality (optional): Quality of the image (0-100), only applicable for jpeg and webp
  • waitFor (optional): When to consider page loaded - "load", "domcontentloaded", "networkidle0", or "networkidle2" (default: "networkidle2")
  • delay (optional): Additional delay in milliseconds after page load (default: 0)
  • useSavedAuth (optional): Whether to use saved cookies from previous login (default: true)
  • reuseAuthPage (optional): Whether to use the existing authenticated page (default: false)
  • useDefaultBrowser (optional): Whether to use the system's default browser (default: false)
  • visibleBrowser (optional): Whether to show the browser window (default: false)

3. screenshot-element

Captures a screenshot of a specific element on a webpage using a CSS selector.

{
  "url": "https://example.com/dashboard",
  "selector": ".user-profile",
  "waitForSelector": true,
  "format": "png",
  "quality": 80,
  "padding": 10,
  "useSavedAuth": true,
  "useDefaultBrowser": true,
  "visibleBrowser": true
}
  • url (required): The URL of the webpage
  • selector (required): CSS selector for the element to screenshot
  • waitForSelector (optional): Whether to wait for the selector to appear (default: true)
  • format (optional): Image format - "png", "jpeg", or "webp" (default: "png")
  • quality (optional): Quality of the image (0-100), only applicable for jpeg and webp
  • padding (optional): Padding around the element in pixels (default: 0)
  • useSavedAuth (optional): Whether to use saved cookies from previous login (default: true)
  • useDefaultBrowser (optional): Whether to use the system's default browser (default: false)
  • visibleBrowser (optional): Whether to show the browser window (default: false)

4. clear-auth-cookies

Clears saved authentication cookies for a specific domain or all domains.

{
  "url": "https://example.com"
}
  • url (optional): URL of the domain to clear cookies for. If not provided, clears all cookies.

Default Browser Mode

The default browser mode allows you to use your system's regular browser (Chrome, Edge, etc.) instead of Puppeteer's bundled Chromium. This is useful for:

  1. Using your existing browser sessions and extensions
  2. Manually logging in to websites with your saved credentials
  3. Having a more natural browsing experience for multi-step workflows
  4. Testing with the same browser environment as your users

To enable default browser mode, set useDefaultBrowser: true and visibleBrowser: true in your tool parameters.

How Default Browser Mode Works

When you enable default browser mode:

  1. The tool will attempt to locate your system's default browser (Chrome, Edge, etc.)
  2. It launches your browser with remote debugging enabled on a random port
  3. Puppeteer connects to this browser instance instead of launching its own
  4. Your existing profiles, extensions, and cookies are available during the session
  5. The browser window remains visible so you can interact with it manually

This mode is particularly useful for workflows that require authentication or complex user interactions.

Browser Persistence

The MCP server can maintain a persistent browser session across multiple tool calls:

  1. When you use login-and-wait, the browser session is kept open
  2. Subsequent calls to screenshot-page or screenshot-element with reuseAuthPage: true will use the same page
  3. This allows for multi-step workflows without having to re-authenticate

Cookie Management

Cookies are automatically saved for each domain you visit:

  1. After using login-and-wait, cookies are saved to the .mcp-screenshot-cookies directory in your home folder
  2. These cookies are automatically loaded when visiting the same domain again with useSavedAuth: true
  3. You can clear cookies using the clear-auth-cookies tool

Example Workflow: Protected Page Screenshots

Here's an example workflow for taking screenshots of pages that require authentication:

  1. Manual Login Phase
{
  "name": "login-and-wait",
  "parameters": {
    "url": "https://example.com/login",
    "waitMinutes": 3,
    "successIndicator": ".dashboard-welcome",
    "useDefaultBrowser": true
  }
}

This will open your default browser with the login page. You can manually log in, and once complete (either by detecting the success indicator or after navigating away from the login page), the session cookies will be saved.

  1. Take Screenshots Using Saved Session
{
  "name": "screenshot-page",
  "parameters": {
    "url": "https://example.com/account",
    "fullPage": true,
    "useSavedAuth": true,
    "reuseAuthPage": true,
    "useDefaultBrowser": true,
    "visibleBrowser": true
  }
}

This will take a screenshot of the account page using your saved authentication cookies in the same browser window.

  1. Take Screenshots of Specific Elements
{
  "name": "screenshot-element",
  "parameters": {
    "url": "https://example.com/dashboard",
    "selector": ".user-profile-section",
    "useSavedAuth": true,
    "useDefaultBrowser": true,
    "visibleBrowser": true
  }
}
  1. Clear Cookies When Done
{
  "name": "clear-auth-cookies",
  "parameters": {
    "url": "https://example.com"
  }
}

This workflow allows you to interact with protected pages as if you were a regular user, completing the full authentication flow in your default browser.

Headless vs. Visible Mode

  • Headless mode (visibleBrowser: false): Faster and more suitable for automated workflows where no user interaction is needed.
  • Visible mode (visibleBrowser: true): Shows the browser window, allowing for user interaction and manual verification. Required for useDefaultBrowser: true.

Platform Support

The default browser detection works on:

  • macOS: Detects Chrome, Edge, and Safari
  • Windows: Detects Chrome and Edge via registry or common installation paths
  • Linux: Detects Chrome and Chromium via system commands

Troubleshooting

Common Issues

  1. Default browser not found: If the system can't find your default browser, it will fall back to Puppeteer's bundled Chromium.
  2. Connection issues: If there are problems connecting to the browser's debugging port, check if another instance is already using that port.
  3. Cookie issues: If authentication isn't working, try clearing cookies with the clear-auth-cookies tool.

Debugging

The MCP server logs helpful error messages to the console when issues occur. Check these messages for troubleshooting information.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选