Skip to content

Commit 9f17a7b

Browse files
omalleyandyclaude
andcommitted
docs: expand skill docs with scraping, WebSocket, and network workflows
Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b5369a6 commit 9f17a7b

6 files changed

Lines changed: 419 additions & 20 deletions

File tree

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,7 @@ build/
148148

149149
log.txt
150150

151-
.DS_Store
151+
.DS_Store
152+
153+
# Claude Code local config
154+
.claude/

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ Chrome DevTools MCP will not start the browser instance automatically using this
113113
claude mcp add chrome-devtools --scope user npx chrome-devtools-mcp@latest
114114
```
115115

116+
**Don’t start automatically, preserve context, and defer tool use:** The Chrome DevTools MCP server does not start the browser until the first tool that needs it runs. To avoid loading all MCP tool definitions up front and to preserve context, use **MCP Tool Search** in Claude Code so tools are loaded on demand:
117+
118+
- Claude Code turns on **Tool Search** automatically when your MCP tools would use more than 10% of the context window (see <a href="https://code.claude.com/docs/en/mcp#scale-with-mcp-tool-search">Scale with MCP Tool Search</a>). When that happens, tools are deferred and Claude uses a search tool to load only the tools it needs.
119+
- To rely on this behavior, no extra config is required. To force it on (or adjust the threshold), use **Configure tool search** in Claude Code (e.g. run `/config` and check MCP / tool search options, or set <code>enable_tool_search</code> in your Claude Code settings as documented in the <a href="https://code.claude.com/docs/en/mcp#configure-tool-search">MCP docs</a>).
120+
- Optionally add <code>serverInstructions</code> to your MCP server config so Tool Search can discover Chrome DevTools tools more reliably (e.g. describe browser automation, debugging, network inspection, performance traces).
121+
116122
</details>
117123

118124
<details>

skills/chrome-devtools/SKILL.md

Lines changed: 90 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,115 @@
11
---
22
name: chrome-devtools
3-
description: Uses Chrome DevTools via MCP for efficient debugging, troubleshooting and browser automation. Use when debugging web pages, automating browser interactions, analyzing performance, or inspecting network requests.
3+
description: Uses Chrome DevTools via MCP for debugging, browser automation, web scraping with Puppeteer, WebSocket inspection, performance analysis, and network debugging. Use when automating browsers, scraping pages, intercepting or analyzing WebSocket traffic, debugging web apps, or recording performance traces.
44
---
55

6-
## Core Concepts
6+
## Project overview
7+
8+
**Chrome DevTools MCP** is an MCP server that controls a live Chrome instance via Puppeteer and Chrome DevTools Protocol (CDP). It gives AI assistants tools for navigation, interaction, snapshots, network inspection (including WebSocket), console messages, performance traces, and script evaluation. The server starts Chrome on first tool use; you can also connect to an existing Chrome with `--browser-url` or `--wsEndpoint`.
9+
10+
- **Docs**: [Tool reference](../../docs/tool-reference.md), [Design principles](../../docs/design-principles.md), [Troubleshooting](../../docs/troubleshooting.md)
11+
- **Puppeteer**: Used under the hood for browser launch, pages, and CDP; you interact via MCP tools, not Puppeteer API directly.
12+
13+
## Core concepts
714

815
**Browser lifecycle**: Browser starts automatically on first tool call using a persistent Chrome profile. Configure via CLI args in the MCP server configuration: `npx chrome-devtools-mcp@latest --help`.
916

1017
**Page selection**: Tools operate on the currently selected page. Use `list_pages` to see available pages, then `select_page` to switch context.
1118

12-
**Element interaction**: Use `take_snapshot` to get page structure with element `uid`s. Each element has a unique `uid` for interaction. If an element isn't found, take a fresh snapshot - the element may have been removed or the page changed.
19+
**Element interaction**: Use `take_snapshot` to get page structure with element `uid`s. Each element has a unique `uid` for interaction. If an element isn't found, take a fresh snapshot—the element may have been removed or the page changed.
20+
21+
## Discovering scraping opportunities (Network-first)
22+
23+
**Best first step**: Use the **Network** tools to see *how* the page gets its data. Many sites load content via **XHR** or **fetch**; if you find that API and its response is JSON (or structured), you can often use the same API instead of parsing HTML.
24+
25+
1. **Load and trigger**: `navigate_page` to the target URL; if needed, interact (click, search) so the data you want is loaded.
26+
2. **List API requests**: `list_network_requests` with **resourceTypes: `['xhr', 'fetch']`** to see only API-style requests. Scan for URLs that look like data endpoints (e.g. `api/`, `graphql`, query params).
27+
3. **Inspect one**: `get_network_request(reqid)` for a promising request. Check **response body**—if it’s JSON with the data you need, prefer **reusing that API** (same URL, method, headers, body) over DOM scraping.
28+
4. **Decide**: Structured response → use the API. No usable API or auth-only → use DOM: snapshot + `evaluate_script` (see “Workflow: Web scraping” below).
29+
30+
Full step-by-step and “API vs DOM” guidance: [network-for-scraping-discovery.md](./network-for-scraping-discovery.md).
31+
32+
## Workflow: Web scraping (Puppeteer-style)
33+
34+
Use the MCP tools as a “Puppeteer-like” scraping pipeline: navigate, wait, snapshot, then extract data with snapshots and/or page scripts.
35+
36+
1. **Navigate**: `navigate_page` (type=url, url=…) or `new_page` (url=…).
37+
2. **Wait**: `wait_for` (text=…) to wait for specific content, or use a short delay and then snapshot.
38+
3. **Snapshot**: `take_snapshot` to get the accessibility tree and element `uid`s. Prefer snapshot over screenshot for automation (faster, text-based).
39+
4. **Extract**:
40+
- **From tree**: Use the snapshot text and structure; click/fill by `uid` if you need to open modals or paginate.
41+
- **From page**: Use `evaluate_script` to run JavaScript in the page and return JSON-serializable data (e.g. `() => document.querySelectorAll('h2').length`, or extract table rows, meta tags, or any DOM/data).
42+
5. **Pagination or multi-page**: Use `click` on “next” (by `uid`), then wait + snapshot again, or `navigate_page` to new URLs and repeat.
43+
44+
**Tips**: Use `filePath` on `take_snapshot` for large pages. For data not in the a11y tree (e.g. attributes, computed styles), use `evaluate_script`. Iframes are not in the snapshot—only the main frame is represented.
1345

14-
## Workflow Patterns
46+
## Workflow: WebSocket inspection / “interception”
1547

16-
### Before interacting with a page
48+
The server does not inject code into the page; it uses DevTools network data. You can **list and inspect** WebSocket (and other) requests.
49+
50+
1. **Navigate** to the page that opens WebSockets: `navigate_page` (url=…).
51+
2. **Trigger** the WebSocket (use the app or wait for it to connect).
52+
3. **List requests**: `list_network_requests` with `resourceTypes: ['websocket']` to see only WebSocket requests. Omit `resourceTypes` to see all (document, xhr, fetch, websocket, etc.).
53+
4. **Inspect one request**: `get_network_request` with the `reqid` from the list. Use `requestFilePath` / `responseFilePath` to save bodies to files (useful for large or binary payloads).
54+
55+
**Resource types** (for `list_network_requests`) include: `document`, `stylesheet`, `image`, `media`, `font`, `script`, `xhr`, `fetch`, `eventsource`, **`websocket`**, `manifest`, `ping`, `preflight`, `other`, etc. Use these to filter by kind of traffic.
56+
57+
**Note**: You see WebSocket *requests* (URL, timing, headers). Live message-by-message capture is limited to what DevTools exposes in the network list and request/response details.
58+
59+
## General workflow (before interacting)
1760

1861
1. Navigate: `navigate_page` or `new_page`
19-
2. Wait: `wait_for` to ensure content is loaded if you know what you look for.
20-
3. Snapshot: `take_snapshot` to understand page structure
21-
4. Interact: Use element `uid`s from snapshot for `click`, `fill`, etc.
62+
2. Wait: `wait_for` if you know what text to wait for
63+
3. Snapshot: `take_snapshot` to get structure and `uid`s
64+
4. Interact: Use `uid`s from snapshot for `click`, `fill`, `fill_form`, `hover`, `drag`, `press_key`, `upload_file`
65+
5. Dialogs: Use `handle_dialog` (accept/dismiss, optional `promptText`) when alerts/confirms appear
66+
67+
## Tool selection quick reference
68+
69+
| Goal | Preferred tool(s) |
70+
|------|-------------------|
71+
| Automation / scraping | `take_snapshot`, `click`, `fill`, `evaluate_script` |
72+
| Visual check | `take_screenshot` (optionally `fullPage`, `uid` for element) |
73+
| Data not in a11y tree | `evaluate_script` (must return JSON-serializable values) |
74+
| List HTTP/WebSocket requests | `list_network_requests` (optional `resourceTypes: ['websocket']`) |
75+
| Inspect one request/response | `get_network_request` (reqid, optional file paths for bodies) |
76+
| Console errors/warnings | `list_console_messages` (optional `types`), `get_console_message` |
77+
| Performance / CWV | `performance_start_trace`, `performance_stop_trace`, `performance_analyze_insight` |
78+
| Emulation | `emulate` (viewport, userAgent, networkConditions, etc.), `resize_page` |
2279

23-
### Efficient data retrieval
80+
See [Tool reference](../../docs/tool-reference.md) for full parameters.
2481

25-
- Use `filePath` parameter for large outputs (screenshots, snapshots, traces)
26-
- Use pagination (`pageIdx`, `pageSize`) and filtering (`types`) to minimize data
27-
- Set `includeSnapshot: false` on input actions unless you need updated page state
82+
## Formatters (internal)
2883

29-
### Tool selection
84+
Tool responses are shaped by internal formatters. You don’t call them directly; they affect what the agent sees:
3085

31-
- **Automation/interaction**: `take_snapshot` (text-based, faster, better for automation)
32-
- **Visual inspection**: `take_screenshot` (when user needs to see visual state)
33-
- **Additional details**: `evaluate_script` for data not in accessibility tree
86+
- **SnapshotFormatter**: Turns the a11y tree into the text snapshot with `uid`s and optional “selected in DevTools” hint. Use `verbose: true` on `take_snapshot` for more detail.
87+
- **NetworkFormatter**: Formats request/response (URL, status, headers, body). Large bodies can be truncated or written to `requestFilePath`/`responseFilePath`.
88+
- **ConsoleFormatter**: Formats console messages (level, text, stack, resolved arguments when detailed data is requested).
89+
- **IssueFormatter**: Formats DevTools “issues” (e.g. deprecations, violations) when included in responses.
3490

35-
### Parallel execution
91+
A full **Network & Console breakdown** (data flow, collectors, filter options, what you see in responses) is in [network-and-console-breakdown.md](./network-and-console-breakdown.md).
3692

37-
You can send multiple tool calls in parallel, but maintain correct order: navigate → wait → snapshot → interact.
93+
## Telemetry
94+
95+
Google collects usage statistics (e.g. tool invocation success, latency, environment) to improve the server. Collection is **on by default**.
96+
97+
- **Opt-out**: Start the server with `--no-usage-statistics` (or set `CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS` or `CI`).
98+
- **Config example**: `"args": ["-y", "chrome-devtools-mcp@latest", "--no-usage-statistics"]`
99+
- Data is handled per [Google Privacy Policy](https://policies.google.com/privacy); independent of Chrome browser metrics.
100+
101+
## Efficient usage
102+
103+
- Use `filePath` for large outputs (screenshots, snapshots, traces, request/response bodies).
104+
- Use pagination (`pageIdx`, `pageSize`) and filters (`resourceTypes`, `types` for console) to limit data.
105+
- Set `includeSnapshot: false` on input actions (click, fill, etc.) unless you need an updated snapshot in the same response.
106+
- Run independent tool calls in parallel when order allows (e.g. multiple `get_network_request` by reqid); keep sequence for navigate → wait → snapshot → interact.
38107

39108
## Troubleshooting
40109

41-
If `chrome-devtools-mcp` is insufficient, guide users to use Chrome DevTools UI:
110+
If the MCP tools are insufficient, suggest using Chrome DevTools directly:
42111

43112
- https://developer.chrome.com/docs/devtools
44113
- https://developer.chrome.com/docs/devtools/ai-assistance
114+
115+
For connection issues, headless vs headed, or remote debugging, see [Troubleshooting](../../docs/troubleshooting.md).

0 commit comments

Comments
 (0)