npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tscodex/mcp-screenshot

v0.3.1

Published

MCP server for capturing web page screenshots using Playwright

Downloads

404

Readme

@tscodex/mcp-screenshot

MCP server for capturing web page screenshots using Playwright. Supports full page, viewport, and element screenshots with optional script execution for complex interactions.

Official website: http://tscodex.com/

Built on @tscodex/mcp-sdk - This project uses the official TSCodex MCP SDK for server infrastructure, authentication, configuration management, and protocol handling.

Managed by MCP Manager - Use the MCP Manager desktop application for workspace isolation, visual configuration, and seamless integration with Cursor. The MCP Manager Bridge VS Code extension provides a bridge to manage MCP servers directly from your IDE.

Features

  • Full page screenshots - capture entire scrollable content
  • Viewport screenshots - capture visible area only
  • Element screenshots - capture specific DOM elements by CSS selector
  • HTML capture - get DOM content instead of images
  • Script execution - run Playwright code for complex interactions (click menus, fill forms, hover elements)
  • Multiple formats - PNG, JPEG, WebP
  • Custom viewports - test responsive layouts
  • Preview generation - returns optimized base64 preview image

Installation

npm install @tscodex/mcp-screenshot

Playwright will automatically install Chromium browser during postinstall.

Usage

With MCP Manager

Register the server in MCP Manager:

  1. Open MCP Manager
  2. Add new server: @tscodex/mcp-screenshot
  3. Enable for your workspace

Standalone

npx @tscodex/mcp-screenshot

Or run from source:

npm run build
npm start

Tools

screenshot_capture

Main tool for capturing screenshots.

Parameters:

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | url | string | ✅ | URL of the page to screenshot | | outputPath | string | ✅ | Relative path for saving (from project root) | | selector | string | ❌ | CSS selector - screenshot only this element | | fullPage | boolean | ❌ | Screenshot entire page (default: false) | | waitFor | number | ❌ | Delay before screenshot in ms (0-30000) | | waitForSelector | string | ❌ | Wait for element before screenshot | | format | string | ❌ | Image format: png, jpeg, webp (default: png) | | quality | number | ❌ | Quality for jpeg/webp (1-100) | | viewport | object | ❌ | {width, height} - browser viewport | | deviceScaleFactor | number | ❌ | Device scale (1=normal, 2=retina) | | timeout | number | ❌ | Page load timeout in ms | | script | string | ❌ | Playwright script to execute |

Examples:

Simple screenshot:

{
  "url": "https://example.com",
  "outputPath": "screenshots/homepage.png"
}

Full page:

{
  "url": "https://example.com",
  "outputPath": "screenshots/full.png",
  "fullPage": true
}

Element screenshot:

{
  "url": "https://example.com",
  "outputPath": "screenshots/header.png",
  "selector": "#main-header"
}

Mobile viewport:

{
  "url": "https://example.com",
  "outputPath": "screenshots/mobile.png",
  "viewport": { "width": 375, "height": 812 },
  "deviceScaleFactor": 2
}

With script (dropdown menu):

{
  "url": "https://example.com/app",
  "outputPath": "screenshots/dropdown.png",
  "script": "await page.click('#menu-btn'); await page.waitForSelector('.dropdown'); await screenshot({ selector: '.dropdown' });"
}

With script (form validation):

{
  "url": "https://example.com/login",
  "outputPath": "screenshots/error.png",
  "script": "await page.fill('#email', 'invalid'); await page.click('button[type=submit]'); await page.waitForSelector('.error'); await screenshot();"
}

screenshot_element

Simplified tool for element screenshots only.

Parameters:

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | url | string | ✅ | Page URL | | selector | string | ✅ | CSS selector of element | | outputPath | string | ✅ | Path for saving | | waitFor | number | ❌ | Delay in ms |

html_capture

Capture HTML content from web pages instead of screenshots. Useful for debugging page structure, extracting DOM content, or capturing HTML after JavaScript execution.

Parameters:

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | url | string | ✅ | URL of the page to capture HTML from | | selector | string | ❌ | CSS selector - capture only this element's outerHTML | | waitFor | number | ❌ | Delay before capture in ms (0-30000) | | waitForSelector | string | ❌ | Wait for element before capture | | viewport | object | ❌ | {width, height} - browser viewport | | timeout | number | ❌ | Page load timeout in ms | | script | string | ❌ | Playwright script to execute (must call html()) |

Examples:

Full page HTML:

{
  "url": "https://example.com"
}

Element HTML:

{
  "url": "https://example.com",
  "selector": "nav.main-menu"
}

With script (capture after interaction):

{
  "url": "https://example.com/app",
  "script": "await page.click('#load-more'); await page.waitForSelector('.loaded'); await html({ selector: '.results' });"
}

html_element

Simplified tool for capturing HTML of specific elements.

Parameters:

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | url | string | ✅ | Page URL | | selector | string | ✅ | CSS selector of element | | waitFor | number | ❌ | Delay in ms |

Script Execution

When using the script parameter, you write Playwright code that runs in a secure VM sandbox.

Important: Your script MUST call screenshot() or html() to capture. These functions terminate the script.

Available Functions

// Screenshot (for screenshot_capture tool)
await screenshot();                          // viewport
await screenshot({ fullPage: true });        // full page
await screenshot({ selector: '.element' });  // specific element

// HTML capture (for html_capture tool)
await html();                                // full page HTML
await html({ selector: '.element' });        // element outerHTML

// Page interactions
await page.click('#button');
await page.dblclick('#item');
await page.fill('#input', 'text');
await page.type('#input', 'text');
await page.press('Enter');
await page.hover('.element');
await page.focus('#input');
await page.check('#checkbox');
await page.uncheck('#checkbox');
await page.selectOption('#select', 'value');

// Waiting
await page.waitForSelector('.loaded');
await page.waitForTimeout(1000);
await page.waitForLoadState('networkidle');
await page.waitForURL('https://...');
await wait(500);  // helper function

// Locators
await page.locator('.item').click();
await page.getByText('Click me').click();
await page.getByRole('button', { name: 'Submit' }).click();
await page.getByPlaceholder('Email').fill('[email protected]');
await page.getByLabel('Password').fill('secret');
await page.getByTestId('submit-btn').click();

// Evaluate in browser
await page.evaluate(() => window.scrollTo(0, 100));

NOT Available (blocked for security)

  • require, import
  • process, global
  • File system access
  • Network access outside browser
  • Any Node.js APIs

Timeouts

  • Script execution: 60 seconds max
  • wait() / waitForTimeout(): 30 seconds max

Configuration

Create .mcp-screenshot.json in your project root:

{
  "defaultViewportWidth": 1920,
  "defaultViewportHeight": 1080,
  "defaultFormat": "png",
  "defaultQuality": 80,
  "defaultTimeout": 30000,
  "headless": true,
  "includePreview": true,
  "previewMaxSize": 400
}

Response Format

{
  "content": [
    {
      "type": "text",
      "text": "Screenshot saved successfully!\n\nPath: screenshots/homepage.png\nSize: 1920x1080\nFormat: png\nFile size: 245KB\n\nFull path: /path/to/project/screenshots/homepage.png"
    },
    {
      "type": "image",
      "mimeType": "image/jpeg",
      "data": "<base64-preview-400x400>"
    }
  ]
}

Error Handling

| Error | Description | |-------|-------------| | Invalid URL | Only http/https protocols supported | | Invalid output path | Path traversal or outside project root | | Element not found | Selector didn't match any element | | Script timeout | Script exceeded 60 seconds | | Script must call screenshot() | Script finished without capturing (screenshot tools) | | Script must call html() | Script finished without capturing (html tools) | | Wrong capture function | Used html() in screenshot tool or vice versa |

Requirements

  • Node.js >= 18.0.0
  • Chromium (installed automatically)

Links

License

MIT