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

@freelw/puppeteer-mcp-server

v1.1.2

Published

Puppeteer MCP Server for remote browser automation

Readme

Puppeteer MCP Server

A Model Context Protocol (MCP) server that provides browser automation capabilities through Puppeteer and remote CDP connections.

Features

  • Remote Browser Control: Connect to remote browser instances via CDP WebSocket
  • MCP Tools: Four essential browser automation tools
    • navigate: Navigate to web pages
    • click: Click elements using CSS selectors
    • evaluate: Execute JavaScript in browser context
    • fetch_content: Get current page HTML content
  • Multiple Transport Modes: Support for both stdio and HTTP/SSE transport
  • Session Management: Automatic browser instance lifecycle management
  • Error Handling: Robust error handling with automatic cleanup
  • NPX Support: Can be executed directly via npx without installation

Quick Start with NPX

The easiest way to use this server is via npx:

# Basic usage with stdio mode
npx @freelw/puppeteer-mcp-server --project_id <your_project_id> --api_key <your_api_key>

# Start HTTP server
npx @freelw/puppeteer-mcp-server --project_id <your_project_id> --api_key <your_api_key> --http --port 8089

# Enable debug logging
npx @freelw/puppeteer-mcp-server --project_id <your_project_id> --api_key <your_api_key> --debug

# Show help
npx @freelw/puppeteer-mcp-server --help

Installation (Alternative)

If you prefer to install the package locally:

npm install @freelw/puppeteer-mcp-server

Usage

Start the Server

Using NPX (Recommended)

# Basic usage with stdio mode
npx @freelw/puppeteer-mcp-server --project_id <your_project_id> --api_key <your_api_key>

# HTTP server mode
npx @freelw/puppeteer-mcp-server --project_id <your_project_id> --api_key <your_api_key> --http --port 8089

# Enable debug logging
npx @freelw/puppeteer-mcp-server --project_id <your_project_id> --api_key <your_api_key> --debug

# Using short form arguments
npx @freelw/puppeteer-mcp-server -p <your_project_id> -k <your_api_key> [--http] [--port <port>]

Local Installation

# After npm install
node src/server.js --project_id <your_project_id> --api_key <your_api_key>

# HTTP mode
node src/server.js --project_id <your_project_id> --api_key <your_api_key> --http --port 8089

# Using short form arguments
node src/server.js -p <your_project_id> -k <your_api_key> [-u <api_url>] [--http] [--port <port>]

Parameters

  • --project_id / -p: Required - Your project ID
  • --api_key / -k: Required - Your API key
  • --api_url / -u: Optional - API server base URL (defaults to https://api.lexmount.net/)
  • --http: Optional - Start HTTP server instead of stdio mode
  • --port: Optional - HTTP server port (defaults to 8089)

Environment Variables

Set the API server base URL (optional, defaults to https://api.lexmount.net/):

export API_BASE_URL=https://your-api-server.com

Logging Configuration

Note: Logging is disabled by default. To enable logging, set MCP_DEBUG=1 or use the --debug flag.

# Enable debug logging (logs will be written to ~/.puppeteer-browser/logs/)
export MCP_DEBUG=1

# Or use the --debug flag with npx
npx @freelw/puppeteer-mcp-server --debug --project_id <id> --api_key <key>

When debug logging is enabled, you can control specific log types:

# Disable CDP logs (browser events, requests, responses)
export ENABLE_CDP_LOGS=false

# Disable HTTP logs (API calls)
export ENABLE_HTTP_LOGS=false

# Disable MCP logs (tool calls)
export ENABLE_MCP_LOGS=false

# Disable file logging (only console output)
export ENABLE_FILE_LOGGING=false

MCP Tools

1. Navigate

Navigate to a specific URL.

{
  "name": "navigate",
  "arguments": {
    "url": "https://example.com"
  }
}

2. Click

Click an element using CSS selector.

{
  "name": "click",
  "arguments": {
    "selector": "#submit-button"
  }
}

3. Evaluate

Execute JavaScript code in the browser context.

{
  "name": "evaluate",
  "arguments": {
    "script": "document.title"
  }
}

4. Fetch Content

Get the HTML content of the current page.

{
  "name": "fetch_content",
  "arguments": {}
}

Configuration

The server uses the following configuration (see config.js):

  • API Base URL: Set via --api_url parameter or API_BASE_URL environment variable (defaults to https://api.lexmount.net/)
  • Connection Timeout: 30 seconds
  • Operation Timeout: 60 seconds

Error Handling

The server implements comprehensive error handling:

  • Initialization Errors: Fails fast if browser instance cannot be created
  • Tool Execution Errors: Returns structured error responses
  • Network Errors: Automatic retry and cleanup
  • Resource Cleanup: Automatic cleanup on server shutdown

Development

# Run in development mode with auto-restart
npm run dev

# Run normally
npm start

API Requirements

This server requires a compatible API server that provides:

  1. POST /instance - Create browser instance
  2. DELETE /instance - Delete browser instance
  3. GET /json/version?session_id={session_id} - Get CDP connection URL

See plan/API.md for detailed API specifications.