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.
Install the package using npm:
npm install @nicholmikey/chrome-tools
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"
}
}
}
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 failsLaunch 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
Configure MCP settings:
{
"env": {
"CHROME_DEBUG_URL": "http://localhost:9222",
"CHROME_CONNECTION_TYPE": "direct"
}
}
When running in WSL, set up an SSH tunnel to connect to Chrome on Windows:
Launch Chrome on Windows with remote debugging enabled
Create an SSH tunnel:
ssh -N -L 9222:localhost:9222 windowsuser@host
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"
}
}
For running Chrome in Docker:
Launch Chrome container:
docker run -d --name chrome -p 9222:9222 chromedp/headless-shell
Configure MCP settings:
{
"env": {
"CHROME_DEBUG_URL": "http://localhost:9222",
"CHROME_CONNECTION_TYPE": "docker"
}
}
Lists all available Chrome tabs.
list_tabs
Executes JavaScript code in a specified tab.
Parameters:
tabId
: ID of the Chrome tabscript
: JavaScript code to executeexecute_script("TAB_ID", "document.title")
Captures a screenshot of a specified tab, automatically optimized for AI consumption.
Parameters:
tabId
: ID of the Chrome tabformat
: Image format (jpeg/png) - initial capture onlyquality
: JPEG quality (1-100) - initial capture onlyfullPage
: Capture full scrollable pageImage processing:
capture_screenshot("TAB_ID", "jpeg", 90, true)
Captures network events from a specified tab.
Parameters:
tabId
: ID of the Chrome tabduration
: Duration in seconds to capturefilters
: Optional type and URL pattern filterscapture_network_events("TAB_ID", 10, {types: ["XHR", "Fetch"], urlPattern: "api"})
Navigates a tab to a specified URL.
Parameters:
tabId
: ID of the Chrome taburl
: URL to loadload_url("TAB_ID", "https://example.com")
Queries and retrieves information about DOM elements matching a CSS selector.
Parameters:
tabId
: ID of the Chrome tabselector
: CSS selector to find elementsReturns:
query_dom_elements("TAB_ID", "button.submit")
Clicks on a DOM element and captures any console output triggered by the click.
Parameters:
tabId
: ID of the Chrome tabselector
: CSS selector to find the element to clickReturns:
click_element("TAB_ID", "button.submit")
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.
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"
]
}
}
}
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.
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.