Skip to content

Commit aa0a367

Browse files
authored
feat: add a skill for using chrome-devtools-mcp (#830)
Closes #710 Closes #709
1 parent 8e215e3 commit aa0a367

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

scripts/eval_gemini.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {TestServer} from '../build/tests/server.js';
1616

1717
const ROOT_DIR = path.resolve(import.meta.dirname, '..');
1818
const SCENARIOS_DIR = path.join(import.meta.dirname, 'eval_scenarios');
19+
const SKILL_PATH = path.join(ROOT_DIR, 'skills', 'chrome-devtools', 'SKILL.md');
1920

2021
// Define schema for our test scenarios
2122
export interface CapturedFunctionCall {
@@ -49,6 +50,7 @@ async function runSingleScenario(
4950
server: TestServer,
5051
modelId: string,
5152
debug: boolean,
53+
includeSkill: boolean,
5254
): Promise<void> {
5355
const debugLog = (...args: unknown[]) => {
5456
if (debug) {
@@ -67,6 +69,17 @@ async function runSingleScenario(
6769
const loadedScenario = await loadScenario(absolutePath);
6870
const scenario = {...loadedScenario};
6971

72+
// Prepend skill content if requested
73+
if (includeSkill) {
74+
if (!fs.existsSync(SKILL_PATH)) {
75+
throw new Error(
76+
`Skill file not found at ${SKILL_PATH}. Please ensure the skill file exists.`,
77+
);
78+
}
79+
const skillContent = fs.readFileSync(SKILL_PATH, 'utf-8');
80+
scenario.prompt = `${skillContent}\n\n---\n\n${scenario.prompt}`;
81+
}
82+
7083
// Append random queryid to avoid caching issues and test distinct runs
7184
const randomId = Math.floor(Math.random() * 1000000);
7285
scenario.prompt = `${scenario.prompt}\nqueryid=${randomId}`;
@@ -180,13 +193,18 @@ async function main() {
180193
type: 'boolean',
181194
default: false,
182195
},
196+
'include-skill': {
197+
type: 'boolean',
198+
default: false,
199+
},
183200
},
184201
allowPositionals: true,
185202
});
186203

187204
const modelId = values.model;
188205
const debug = values.debug;
189206
const repeat = values.repeat;
207+
const includeSkill = values['include-skill'];
190208

191209
const scenarioFiles =
192210
positionals.length > 0
@@ -211,7 +229,14 @@ async function main() {
211229
`Running scenario: ${path.relative(ROOT_DIR, scenarioPath)} (Run ${i}/3)`,
212230
);
213231
}
214-
await runSingleScenario(scenarioPath, apiKey, server, modelId, debug);
232+
await runSingleScenario(
233+
scenarioPath,
234+
apiKey,
235+
server,
236+
modelId,
237+
debug,
238+
includeSkill,
239+
);
215240
console.log(`✔ ${path.relative(ROOT_DIR, scenarioPath)} (Run ${i})`);
216241
successCount++;
217242
} catch (e) {

skills/chrome-devtools/SKILL.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
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.
4+
---
5+
6+
## Core Concepts
7+
8+
**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`.
9+
10+
**Page selection**: Tools operate on the currently selected page. Use `list_pages` to see available pages, then `select_page` to switch context.
11+
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.
13+
14+
## Workflow Patterns
15+
16+
### Before interacting with a page
17+
18+
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.
22+
23+
### Efficient data retrieval
24+
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
28+
29+
### Tool selection
30+
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
34+
35+
### Parallel execution
36+
37+
You can send multiple tool calls in parallel, but maintain correct order: navigate → wait → snapshot → interact.
38+
39+
## Troubleshooting
40+
41+
If `chrome-devtools-mcp` is insufficient, guide users to use Chrome DevTools UI:
42+
43+
- https://developer.chrome.com/docs/devtools
44+
- https://developer.chrome.com/docs/devtools/ai-assistance

0 commit comments

Comments
 (0)