|
| 1 | +--- |
| 2 | +name: chrome-devtools-cli |
| 3 | +description: Use this to skill to write shell scripts or run shell commands to automate tasks in the browser or otherwise use Chrome DevTools via CLI. |
| 4 | +--- |
| 5 | + |
| 6 | +The `chrome-devtools-mcp` CLI lets you interact with the browser from your terminal. |
| 7 | + |
| 8 | +## Setup |
| 9 | + |
| 10 | +_Note: If this is your very first time using the CLI, see [references/installation.md](references/installation.md) for setup. Installation is a one-time prerequisite and is **not** part of the regular AI workflow._ |
| 11 | + |
| 12 | +## AI Workflow |
| 13 | + |
| 14 | +1. **Execute**: Run tools directly (e.g., `chrome-devtools list_pages`). The background server starts implicitly; **do not** run `start`/`status`/`stop` before each use. |
| 15 | +2. **Inspect**: Use `take_snapshot` to get an element `<uid>`. |
| 16 | +3. **Act**: Use `click`, `fill`, etc. State persists across commands. |
| 17 | + |
| 18 | +Snapshot example: |
| 19 | + |
| 20 | +``` |
| 21 | +uid=1_0 RootWebArea "Example Domain" url="https://example.com/" |
| 22 | + uid=1_1 heading "Example Domain" level="1" |
| 23 | +``` |
| 24 | + |
| 25 | +## Command Usage |
| 26 | + |
| 27 | +```sh |
| 28 | +chrome-devtools <tool> [arguments] [flags] |
| 29 | +``` |
| 30 | + |
| 31 | +Use `--help` on any command. Output defaults to Markdown, use `--output-format=json` for JSON. |
| 32 | + |
| 33 | +## Input Automation (<uid> from snapshot) |
| 34 | + |
| 35 | +```bash |
| 36 | +chrome-devtools take_snapshot --help # Help message for commands, works for any command. |
| 37 | +chrome-devtools take_snapshot # Take a text snapshot of the page to get UIDs for elements |
| 38 | +chrome-devtools click "id" # Clicks on the provided element |
| 39 | +chrome-devtools click "id" --dblClick true --includeSnapshot true # Double clicks and returns a snapshot |
| 40 | +chrome-devtools drag "src" "dst" # Drag an element onto another element |
| 41 | +chrome-devtools drag "src" "dst" --includeSnapshot true # Drag an element and return a snapshot |
| 42 | +chrome-devtools fill "id" "text" # Type text into an input or select an option |
| 43 | +chrome-devtools fill "id" "text" --includeSnapshot true # Fill an element and return a snapshot |
| 44 | +chrome-devtools handle_dialog accept # Handle a browser dialog |
| 45 | +chrome-devtools handle_dialog dismiss --promptText "hi" # Dismiss a dialog with prompt text |
| 46 | +chrome-devtools hover "id" # Hover over the provided element |
| 47 | +chrome-devtools hover "id" --includeSnapshot true # Hover over an element and return a snapshot |
| 48 | +chrome-devtools press_key "Enter" # Press a key or key combination |
| 49 | +chrome-devtools press_key "Control+A" --includeSnapshot true # Press a key and return a snapshot |
| 50 | +chrome-devtools type_text "hello" # Type text using keyboard into a focused input |
| 51 | +chrome-devtools type_text "hello" --submitKey "Enter" # Type text and press a submit key |
| 52 | +chrome-devtools upload_file "id" "file.txt" # Upload a file through a provided element |
| 53 | +chrome-devtools upload_file "id" "file.txt" --includeSnapshot true # Upload a file and return a snapshot |
| 54 | +``` |
| 55 | + |
| 56 | +## Navigation |
| 57 | + |
| 58 | +```bash |
| 59 | +chrome-devtools close_page 1 # Closes the page by its index |
| 60 | +chrome-devtools list_pages # Get a list of pages open in the browser |
| 61 | +chrome-devtools navigate_page --url "https://example.com" # Navigates the currently selected page to a URL |
| 62 | +chrome-devtools navigate_page --type "reload" --ignoreCache true # Reload page ignoring cache |
| 63 | +chrome-devtools navigate_page --url "https://example.com" --timeout 5000 # Navigate with a timeout |
| 64 | +chrome-devtools navigate_page --handleBeforeUnload "accept" # Handle before unload dialog |
| 65 | +chrome-devtools navigate_page --type "back" --initScript "foo()" # Navigate back and run an init script |
| 66 | +chrome-devtools new_page "https://example.com" # Creates a new page |
| 67 | +chrome-devtools new_page "https://example.com" --background true --timeout 5000 # Create new page in background |
| 68 | +chrome-devtools new_page "https://example.com" --isolatedContext "ctx" # Create new page with isolated context |
| 69 | +chrome-devtools select_page 1 # Select a page as a context for future tool calls |
| 70 | +chrome-devtools select_page 1 --bringToFront true # Select a page and bring it to front |
| 71 | +``` |
| 72 | + |
| 73 | +## Emulation |
| 74 | + |
| 75 | +```bash |
| 76 | +chrome-devtools emulate --networkConditions "Offline" # Emulate network conditions |
| 77 | +chrome-devtools emulate --cpuThrottlingRate 4 --geolocation "0,0" # Emulate CPU throttling and geolocation |
| 78 | +chrome-devtools emulate --colorScheme "dark" --viewport "1920x1080" # Emulate color scheme and viewport |
| 79 | +chrome-devtools emulate --userAgent "Mozilla/5.0..." # Emulate user agent |
| 80 | +chrome-devtools resize_page 1920 1080 # Resizes the selected page's window |
| 81 | +``` |
| 82 | + |
| 83 | +## Performance |
| 84 | + |
| 85 | +```bash |
| 86 | +chrome-devtools performance_analyze_insight "1" "LCPBreakdown" # Get more details on a specific Performance Insight |
| 87 | +chrome-devtools performance_start_trace true false # Starts a performance trace recording |
| 88 | +chrome-devtools performance_start_trace true true --filePath t.gz # Start trace and save to a file |
| 89 | +chrome-devtools performance_stop_trace # Stops the active performance trace |
| 90 | +chrome-devtools performance_stop_trace --filePath "t.json" # Stop trace and save to a file |
| 91 | +chrome-devtools take_memory_snapshot "./snap.heapsnapshot" # Capture a memory heapsnapshot |
| 92 | +``` |
| 93 | + |
| 94 | +## Network |
| 95 | + |
| 96 | +```bash |
| 97 | +chrome-devtools get_network_request # Get the currently selected network request |
| 98 | +chrome-devtools get_network_request --reqid 1 --requestFilePath req.md # Get request by id and save to file |
| 99 | +chrome-devtools get_network_request --responseFilePath res.md # Save response body to file |
| 100 | +chrome-devtools list_network_requests # List all network requests |
| 101 | +chrome-devtools list_network_requests --pageSize 50 --pageIdx 0 # List network requests with pagination |
| 102 | +chrome-devtools list_network_requests --resourceTypes Fetch # Filter requests by resource type |
| 103 | +chrome-devtools list_network_requests --includePreservedRequests true # Include preserved requests |
| 104 | +``` |
| 105 | + |
| 106 | +## Debugging & Inspection |
| 107 | + |
| 108 | +```bash |
| 109 | +chrome-devtools evaluate_script "() => document.title" # Evaluate a JavaScript function on the page |
| 110 | +evaluate_script "(a) => a.innerText" --args 1_4 # Evaluate JS with UID arguments |
| 111 | +chrome-devtools get_console_message 1 # Gets a console message by its ID |
| 112 | +chrome-devtools lighthouse_audit --mode "navigation" # Run Lighthouse audit for navigation |
| 113 | +chrome-devtools lighthouse_audit --mode "snapshot" --device "mobile" # Run Lighthouse audit for a snapshot on mobile |
| 114 | +chrome-devtools lighthouse_audit --outputDirPath ./out # Run Lighthouse audit and save reports |
| 115 | +chrome-devtools list_console_messages # List all console messages |
| 116 | +chrome-devtools list_console_messages --pageSize 20 --pageIdx 1 # List console messages with pagination |
| 117 | +chrome-devtools list_console_messages --types error --types info # Filter console messages by type |
| 118 | +chrome-devtools list_console_messages --includePreservedMessages true # Include preserved messages |
| 119 | +chrome-devtools take_screenshot # Take a screenshot of the page viewport |
| 120 | +chrome-devtools take_screenshot --fullPage true --format "jpeg" --quality 80 # Take a full page screenshot as JPEG with quality |
| 121 | +chrome-devtools take_screenshot --uid "id" --filePath "s.png" # Take a screenshot of an element |
| 122 | +chrome-devtools take_snapshot # Take a text snapshot of the page from the a11y tree |
| 123 | +chrome-devtools take_snapshot --verbose true --filePath "s.txt" # Take a verbose snapshot and save to file |
| 124 | +``` |
| 125 | + |
| 126 | +## Service Management |
| 127 | + |
| 128 | +```bash |
| 129 | +chrome-devtools start # Start or restart chrome-devtools-mcp |
| 130 | +chrome-devtools status # Checks if chrome-devtools-mcp is running |
| 131 | +chrome-devtools stop # Stop chrome-devtools-mcp if any |
| 132 | +``` |
0 commit comments