Documentation for using the Chrome DevTools MCP server with Claude Code to enable browser automation and web interaction capabilities.
This setup allows Claude Code to interact with Chrome browser through the Model Context Protocol (MCP). The Chrome DevTools MCP server provides tools for:
- Page navigation and management
- Taking snapshots and screenshots of web pages
- Clicking, filling forms, and interacting with page elements
- Network request monitoring
- Performance analysis
- JavaScript execution in browser context
npm install -g @modelcontextprotocol/server-chrome-devtoolsOr using npx (no installation required):
npx @modelcontextprotocol/server-chrome-devtoolsAdd the MCP server to your Claude Code configuration file at ~/.config/claude/claude_desktop_config.json:
{
"mcpServers": {
"chrome-devtools": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-chrome-devtools"
]
}
}
}If you installed globally, you can use:
{
"mcpServers": {
"chrome-devtools": {
"command": "mcp-server-chrome-devtools"
}
}
}The MCP server connects to Chrome via the Chrome DevTools Protocol. You need to launch Chrome with remote debugging enabled:
macOS:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222Linux:
google-chrome --remote-debugging-port=9222Windows:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222After configuration, restart Claude Code to load the MCP server.
The Chrome DevTools MCP provides the following tools (all prefixed with mcp__chrome-devtools__):
list_pages- List all open browser tabsselect_page- Select a specific tab by indexnew_page- Open a new tab with URLnavigate_page- Navigate current tab to URLnavigate_page_history- Go back/forward in historyclose_page- Close a tabresize_page- Resize browser window
take_snapshot- Get text snapshot of page with UIDs for elementstake_screenshot- Capture screenshot of page or elementevaluate_script- Execute JavaScript in page context
click- Click on an element (by UID from snapshot)fill- Type into input fieldsfill_form- Fill multiple form fields at oncehover- Hover over an elementdrag- Drag and drop elementsupload_file- Upload files through file inputshandle_dialog- Handle browser alerts/confirms/prompts
list_network_requests- Get all network requests since last navigationget_network_request- Get specific request details by URLemulate_network- Simulate network conditions (3G, 4G, offline)
performance_start_trace- Start performance recordingperformance_stop_trace- Stop recording and get resultsperformance_analyze_insight- Get detailed performance insightsemulate_cpu- Throttle CPU for testing
list_console_messages- Get console logs, warnings, errors
wait_for- Wait for specific text to appear on page
-
List and select pages:
list_pages → select_page(0) -
Navigate to a URL:
navigate_page("https://example.com") -
Take a snapshot to see page structure:
take_snapshot → Returns UIDs for all interactive elements -
Interact with elements:
click(uid="1_28") fill(uid="1_86", value="search term") -
Monitor network activity:
list_network_requests → See all API calls, resources loaded
1. navigate_page("https://news.ycombinator.com")
2. take_snapshot
3. Read headlines and decide what to click
4. click(uid_of_interesting_article)
5. take_snapshot to read the article
1. navigate_page("https://x.com")
2. take_snapshot
3. fill(uid_of_tweet_box, "Your tweet content")
4. click(uid_of_post_button)
1. navigate_page("http://localhost:3000")
2. take_screenshot for visual comparison
3. fill_form with test data
4. click submit button
5. wait_for("Success message")
6. list_console_messages to check for errors
1. performance_start_trace(reload=true, autoStop=true)
2. Wait for trace to complete
3. performance_analyze_insight("LCPBreakdown")
4. Get detailed Core Web Vitals data
-
Always take a snapshot first - Before interacting with a page, take a snapshot to see available elements and their UIDs.
-
Use specific UIDs - Each element has a unique UID in the snapshot. Always use these for reliable interaction.
-
Handle dynamic content - Use
wait_forwhen waiting for content to load after navigation or interaction. -
Network monitoring - Enable network monitoring before navigating to capture all requests.
-
Error handling - Check console messages with
list_console_messagesto debug issues. -
Clean up - Close tabs you're done with using
close_pageto keep the browser manageable.
- Ensure Chrome is running with
--remote-debugging-port=9222 - Check that no other process is using port 9222
- Try restarting both Chrome and Claude Code
- Take a fresh snapshot before clicking - UIDs change when page updates
- Ensure page has fully loaded before taking snapshot
- Use
wait_forfor dynamic content
- Increase timeout parameter in navigation calls
- Check network conditions - use
emulate_networkto test - Verify page is actually loading in Chrome
- The remote debugging port (9222) allows full browser control
- Only use on trusted networks
- Don't expose the debugging port to external networks
- Consider using a separate Chrome profile for automation
- Chrome DevTools Protocol Documentation
- Model Context Protocol Specification
- Claude Code Documentation
Here's a real example from our session:
- Started by browsing Hacker News to find interesting articles
- Found an article about formally verified code
- Clicked through to read the full article
- Navigated to Twitter/X
- Composed and posted a tweet about the article with key insights
All of this was done through Claude Code using natural language commands, with the MCP server handling the browser automation behind the scenes.