The chrome-devtools-mcp package includes a CLI interface that allows you to interact with the browser directly from your terminal. This is particularly useful for debugging or when you want an agent to generate scripts that automate browser actions.
Install the package globally to make the chrome-devtools command available:
npm i chrome-devtools-mcp@latest -g
chrome-devtools status # check if install worked.The CLI enables unrestricted filesystem access by default. Use --workspace
to limit file tools to specific directories. Repeat the flag for more than one
directory.
--allow-unrestricted-paths still works on its own for compatibility, but it
cannot be combined with --workspace.
chrome-devtools start --workspace=/path/to/project --workspace=/path/to/outputThe chrome-devtools-cli skill teaches your agent how to use the CLI. Plugin installs include this skill. To install it manually, copy the skill folder into the skills directory of your agent:
# Example for Claude Code. Use the skills directory of your agent.
mkdir -p ~/.claude/skills
cp -R "$(npm root -g)/chrome-devtools-mcp/skills/chrome-devtools-cli" ~/.claude/skills/See Skills for all skills and installation options.
Note
Copy the skill again each time you update the CLI. See Keep skills up to date.
The CLI acts as a client to a background chrome-devtools-mcp daemon (uses Unix sockets on Linux/Mac and named pipes on Windows).
- Automatic Start: The first time you call a tool (e.g.,
list_pages), the CLI automatically starts the MCP server and the browser in the background if they aren't already running. - Persistence: The same background instance is reused for subsequent commands, preserving the browser state (open pages, cookies, etc.).
- Manual Control: You can explicitly manage the background process using
start,stop, andstatus. Thestartcommand forwards all subsequent arguments to the underlying MCP server (e.g.,--headless,--userDataDir) but not all args are supported. Runchrome-devtools start --helpfor supported args. Headless is enabled by default. Isolated is enabled by default unless--userDataDiris provided. - Idle Timeout: By default, the daemon runs until you call
stop. Start it with--idleTimeoutand a duration in seconds, minutes or hours (e.g.,chrome-devtools start --idleTimeout=30m, or90s,2h) to close the browser it launched (along with all open pages) after that long without a tool call, or disconnect while leaving the browser open when using--browserUrl,--wsEndpointor--autoConnect, and exit the daemon shortly afterwards (statusdoes not count as a tool call). The next tool command starts a new daemon with only the default flags and the discovered config file: flags passed tostartapply only to that daemon, so re-runstartwith your flags if you need them, or set"idleTimeout": "30m"in a discovered configuration file to apply it to every daemon.
# Check if the daemon is running
chrome-devtools status
# Navigate page 1 to a URL
chrome-devtools navigate_page 1 --url "https://google.com"
# Take a screenshot of page 1 and save it to a file
chrome-devtools take_screenshot 1 --filePath screenshot.png
# Stop the background daemon when finished
chrome-devtools stopThe CLI supports all tools available in the MCP server even if they require a flag to activate in the MCP server (see Tool reference).
chrome-devtools <tool> [arguments] [flags]- Required Arguments: Passed as positional arguments. Page-scoped tools require
<pageId>as their first positional argument. - Optional Arguments: Passed as flags (e.g.,
--filePath,--fullPage).
New Page and Navigation:
chrome-devtools new_page "https://example.com"
chrome-devtools navigate_page 1 --url "https://web.dev"Interaction:
# Click an element by its UID from a snapshot on page 1
chrome-devtools click 1 "element-uid-123"
# Fill a form field on page 1
chrome-devtools fill 1 "input-uid-456" "search query"Script Evaluation:
- When
--categoryExtensionsand--pageIdRoutingare enabled:- Target a page using
--pageId <number>:chrome-devtools evaluate_script "() => document.title" --pageId 1 - Target an extension service worker using
--serviceWorkerId <string>:chrome-devtools evaluate_script "() => self.registration.scope" --serviceWorkerId sw-1
- Target a page using
# Evaluate a JavaScript expression on page 1
chrome-devtools evaluate_script "() => document.title" --pageId 1
# Evaluate inside an extension service worker
chrome-devtools evaluate_script "() => self.registration.scope" --serviceWorkerId sw-1Analysis:
# Run a Lighthouse audit on page 1 (defaults to navigation mode)
chrome-devtools lighthouse_audit 1 --mode snapshotLogpoints:
# Set a logpoint on page 1
chrome-devtools set_logpoints 1 "src/app.ts:42 'total', cart.total"
# Remove all logpoints on page 1
chrome-devtools set_logpoints 1By default, the CLI outputs a human-readable summary of the tool's result. For programmatic use, you can request raw JSON:
chrome-devtools list_pages --output-format=jsonThe CLI waits up to 180 seconds for a tool call. Pass --rpc-timeout with a duration in seconds, minutes or hours (e.g., 90s, 5m, 1h) to wait for a different time, for example for a Lighthouse audit of a heavy page or a large heap snapshot:
chrome-devtools lighthouse_audit 1 --rpc-timeout=5mA tool's own --timeout does not change how long the CLI waits. For --timeout values close to or above 180 seconds, also pass a longer --rpc-timeout.
When the time runs out, or when you stop the CLI (e.g., with Ctrl+C), the daemon cancels the tool call. A call that still waits for its turn or for the browser does not run. A tool that is already running is not interrupted: its result is discarded, and later calls that cannot run at the same time wait until it finishes. A cancelled call no longer counts as activity for --idleTimeout.
If the CLI hangs or fails to connect, try stopping the background process:
chrome-devtools stopFor more verbose logs, set the NODE_DEBUG environment variable. The background
process does not write to the terminal, so restart it with --logFile to
capture its logs in a file:
NODE_DEBUG=* chrome-devtools start --logFile=/tmp/chrome-devtools.log
chrome-devtools list_pagesImplemented in scripts/generate-cli.ts. Some commands are excluded from CLI
generation such as wait_for and fill_form.
chrome-devtools-mcp args are also filtered in src/bin/chrome-devtools.ts
because not all args make sense in a CLI interface.
By default, all commands share one daemon and browser. Pass --sessionId=<id>
or set CHROME_DEVTOOLS_SESSION_ID to scope start, status, stop, and
tool calls to an isolated daemon and browser. Session IDs use hex digits and
dashes (such as a UUID); --sessionId overrides CHROME_DEVTOOLS_SESSION_ID.
SESSION_ID=$(uuidgen)
chrome-devtools start --sessionId="$SESSION_ID"
chrome-devtools list_pages --sessionId="$SESSION_ID"
chrome-devtools stop --sessionId="$SESSION_ID"