Chrome Tools MCP server

Integrates with Chrome's DevTools Protocol to enable remote control of browser tabs, including JavaScript execution, screenshot capture, and network traffic monitoring.
Back to servers
Provider
nicholmikey
Release date
Feb 18, 2025
Language
TypeScript
Package
Stats
682 downloads
20 stars

The Chrome Tools MCP Server provides a powerful interface for interacting with Chrome through its DevTools Protocol. This server allows you to remotely control Chrome tabs, execute JavaScript, capture screenshots, monitor network traffic, and perform various browser automation tasks.

Installation

Install the package using npm:

npm install @nicholmikey/chrome-tools

Configuration

Configure the server through environment variables in your MCP settings:

{
  "chrome-tools": {
    "command": "node",
    "args": ["path/to/chrome-tools/dist/index.js"],
    "env": {
      "CHROME_DEBUG_URL": "http://localhost:9222",
      "CHROME_CONNECTION_TYPE": "direct",
      "CHROME_ERROR_HELP": "custom error message"
    }
  }
}

Environment Variables

  • CHROME_DEBUG_URL: Chrome's remote debugging interface URL (default: http://localhost:9222)
  • CHROME_CONNECTION_TYPE: Connection type identifier for logging (e.g., "direct", "ssh-tunnel", "docker")
  • CHROME_ERROR_HELP: Custom error message shown when connection fails

Setup Guide

Native Setup (Windows/Mac/Linux)

  1. Launch Chrome with remote debugging enabled:

    # Windows
    "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
    
    # Mac
    /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
    
    # Linux
    google-chrome --remote-debugging-port=9222
    
  2. Configure MCP settings:

    {
      "env": {
        "CHROME_DEBUG_URL": "http://localhost:9222",
        "CHROME_CONNECTION_TYPE": "direct"
      }
    }
    

WSL Setup

When running in WSL, set up an SSH tunnel to connect to Chrome on Windows:

  1. Launch Chrome on Windows with remote debugging enabled

  2. Create an SSH tunnel:

    ssh -N -L 9222:localhost:9222 windowsuser@host
    
  3. Configure MCP settings:

    {
      "env": {
        "CHROME_DEBUG_URL": "http://localhost:9222",
        "CHROME_CONNECTION_TYPE": "ssh-tunnel",
        "CHROME_ERROR_HELP": "Make sure the SSH tunnel is running: ssh -N -L 9222:localhost:9222 windowsuser@host"
      }
    }
    

Docker Setup

For running Chrome in Docker:

  1. Launch Chrome container:

    docker run -d --name chrome -p 9222:9222 chromedp/headless-shell
    
  2. Configure MCP settings:

    {
      "env": {
        "CHROME_DEBUG_URL": "http://localhost:9222",
        "CHROME_CONNECTION_TYPE": "docker"
      }
    }
    

Available Tools

List Tabs

Lists all available Chrome tabs.

list_tabs

Execute JavaScript

Executes JavaScript code in a specified tab.

Parameters:

  • tabId: ID of the Chrome tab
  • script: JavaScript code to execute
execute_script("TAB_ID", "document.title")

Capture Screenshot

Captures a screenshot of a specified tab, automatically optimized for AI consumption.

Parameters:

  • tabId: ID of the Chrome tab
  • format: Image format (jpeg/png) - initial capture only
  • quality: JPEG quality (1-100) - initial capture only
  • fullPage: Capture full scrollable page

Image processing:

  • Primary format: WebP with quality optimization
  • Fallback: PNG with compression
  • Size constraints: Max dimensions 900x600, max file size 1MB
capture_screenshot("TAB_ID", "jpeg", 90, true)

Monitor Network Traffic

Captures network events from a specified tab.

Parameters:

  • tabId: ID of the Chrome tab
  • duration: Duration in seconds to capture
  • filters: Optional type and URL pattern filters
capture_network_events("TAB_ID", 10, {types: ["XHR", "Fetch"], urlPattern: "api"})

Navigate to URL

Navigates a tab to a specified URL.

Parameters:

  • tabId: ID of the Chrome tab
  • url: URL to load
load_url("TAB_ID", "https://example.com")

Query DOM Elements

Queries and retrieves information about DOM elements matching a CSS selector.

Parameters:

  • tabId: ID of the Chrome tab
  • selector: CSS selector to find elements

Returns:

  • Array of DOM elements with properties including nodeId, tagName, textContent, attributes, boundingBox, visibility, and ARIA attributes
query_dom_elements("TAB_ID", "button.submit")

Click Element

Clicks on a DOM element and captures any console output triggered by the click.

Parameters:

  • tabId: ID of the Chrome tab
  • selector: CSS selector to find the element to click

Returns:

  • Object containing success/failure message and console output from the click
click_element("TAB_ID", "button.submit")

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later