Skip to content

Commit 895fc65

Browse files
authored
docs: update generate-docs.ts tools output order (#1991)
Closes: #1932
1 parent 510ec0f commit 895fc65

3 files changed

Lines changed: 176 additions & 35 deletions

File tree

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ If you run into any issues, checkout our [troubleshooting guide](./docs/troubles
477477

478478
<!-- BEGIN AUTO GENERATED TOOLS -->
479479

480-
- **Input automation** (9 tools)
480+
- **Input automation** (10 tools)
481481
- [`click`](docs/tool-reference.md#click)
482482
- [`drag`](docs/tool-reference.md#drag)
483483
- [`fill`](docs/tool-reference.md#fill)
@@ -487,6 +487,7 @@ If you run into any issues, checkout our [troubleshooting guide](./docs/troubles
487487
- [`press_key`](docs/tool-reference.md#press_key)
488488
- [`type_text`](docs/tool-reference.md#type_text)
489489
- [`upload_file`](docs/tool-reference.md#upload_file)
490+
- [`click_at`](docs/tool-reference.md#click_at)
490491
- **Navigation automation** (6 tools)
491492
- [`close_page`](docs/tool-reference.md#close_page)
492493
- [`list_pages`](docs/tool-reference.md#list_pages)
@@ -504,21 +505,28 @@ If you run into any issues, checkout our [troubleshooting guide](./docs/troubles
504505
- **Network** (2 tools)
505506
- [`get_network_request`](docs/tool-reference.md#get_network_request)
506507
- [`list_network_requests`](docs/tool-reference.md#list_network_requests)
507-
- **Debugging** (6 tools)
508+
- **Debugging** (10 tools)
508509
- [`evaluate_script`](docs/tool-reference.md#evaluate_script)
509510
- [`get_console_message`](docs/tool-reference.md#get_console_message)
510511
- [`lighthouse_audit`](docs/tool-reference.md#lighthouse_audit)
511512
- [`list_console_messages`](docs/tool-reference.md#list_console_messages)
512513
- [`take_screenshot`](docs/tool-reference.md#take_screenshot)
513514
- [`take_snapshot`](docs/tool-reference.md#take_snapshot)
515+
- [`execute_webmcp_tool`](docs/tool-reference.md#execute_webmcp_tool)
516+
- [`list_webmcp_tools`](docs/tool-reference.md#list_webmcp_tools)
517+
- [`screencast_start`](docs/tool-reference.md#screencast_start)
518+
- [`screencast_stop`](docs/tool-reference.md#screencast_stop)
519+
- **Memory** (4 tools)
520+
- [`take_memory_snapshot`](docs/tool-reference.md#take_memory_snapshot)
521+
- [`get_memory_snapshot_details`](docs/tool-reference.md#get_memory_snapshot_details)
522+
- [`get_nodes_by_class`](docs/tool-reference.md#get_nodes_by_class)
523+
- [`load_memory_snapshot`](docs/tool-reference.md#load_memory_snapshot)
514524
- **Extensions** (5 tools)
515525
- [`install_extension`](docs/tool-reference.md#install_extension)
516526
- [`list_extensions`](docs/tool-reference.md#list_extensions)
517527
- [`reload_extension`](docs/tool-reference.md#reload_extension)
518528
- [`trigger_extension_action`](docs/tool-reference.md#trigger_extension_action)
519529
- [`uninstall_extension`](docs/tool-reference.md#uninstall_extension)
520-
- **Memory** (1 tools)
521-
- [`take_memory_snapshot`](docs/tool-reference.md#take_memory_snapshot)
522530

523531
<!-- END AUTO GENERATED TOOLS -->
524532

docs/tool-reference.md

Lines changed: 114 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Chrome DevTools MCP Tool Reference (~7010 cl100k_base tokens)
44

5-
- **[Input automation](#input-automation)** (9 tools)
5+
- **[Input automation](#input-automation)** (10 tools)
66
- [`click`](#click)
77
- [`drag`](#drag)
88
- [`fill`](#fill)
@@ -12,6 +12,7 @@
1212
- [`press_key`](#press_key)
1313
- [`type_text`](#type_text)
1414
- [`upload_file`](#upload_file)
15+
- [`click_at`](#click_at)
1516
- **[Navigation automation](#navigation-automation)** (6 tools)
1617
- [`close_page`](#close_page)
1718
- [`list_pages`](#list_pages)
@@ -29,21 +30,28 @@
2930
- **[Network](#network)** (2 tools)
3031
- [`get_network_request`](#get_network_request)
3132
- [`list_network_requests`](#list_network_requests)
32-
- **[Debugging](#debugging)** (6 tools)
33+
- **[Debugging](#debugging)** (10 tools)
3334
- [`evaluate_script`](#evaluate_script)
3435
- [`get_console_message`](#get_console_message)
3536
- [`lighthouse_audit`](#lighthouse_audit)
3637
- [`list_console_messages`](#list_console_messages)
3738
- [`take_screenshot`](#take_screenshot)
3839
- [`take_snapshot`](#take_snapshot)
40+
- [`execute_webmcp_tool`](#execute_webmcp_tool)
41+
- [`list_webmcp_tools`](#list_webmcp_tools)
42+
- [`screencast_start`](#screencast_start)
43+
- [`screencast_stop`](#screencast_stop)
44+
- **[Memory](#memory)** (4 tools)
45+
- [`take_memory_snapshot`](#take_memory_snapshot)
46+
- [`get_memory_snapshot_details`](#get_memory_snapshot_details)
47+
- [`get_nodes_by_class`](#get_nodes_by_class)
48+
- [`load_memory_snapshot`](#load_memory_snapshot)
3949
- **[Extensions](#extensions)** (5 tools)
4050
- [`install_extension`](#install_extension)
4151
- [`list_extensions`](#list_extensions)
4252
- [`reload_extension`](#reload_extension)
4353
- [`trigger_extension_action`](#trigger_extension_action)
4454
- [`uninstall_extension`](#uninstall_extension)
45-
- **[Memory](#memory)** (1 tools)
46-
- [`take_memory_snapshot`](#take_memory_snapshot)
4755

4856
## Input automation
4957

@@ -150,6 +158,19 @@
150158

151159
---
152160

161+
### `click_at`
162+
163+
**Description:** Clicks at the provided coordinates (requires flag: --experimentalVision=true)
164+
165+
**Parameters:**
166+
167+
- **x** (number) **(required)**: The x coordinate
168+
- **y** (number) **(required)**: The y coordinate
169+
- **dblClick** (boolean) _(optional)_: Set to true for double clicks. Default is false.
170+
- **includeSnapshot** (boolean) _(optional)_: Whether to include a snapshot in the response. Default is false.
171+
172+
---
173+
153174
## Navigation automation
154175

155176
### `close_page`
@@ -396,13 +417,97 @@ in the DevTools Elements panel (if any).
396417

397418
---
398419

420+
### `execute_webmcp_tool`
421+
422+
**Description:** Executes a WebMCP tool exposed by the page. (requires flag: --experimentalWebmcp=true)
423+
424+
**Parameters:**
425+
426+
- **toolName** (string) **(required)**: The name of the WebMCP tool to execute
427+
- **input** (string) _(optional)_: The JSON-stringified parameters to pass to the WebMCP tool
428+
429+
---
430+
431+
### `list_webmcp_tools`
432+
433+
**Description:** Lists all WebMCP tools the page exposes. (requires flag: --experimentalWebmcp=true)
434+
435+
**Parameters:** None
436+
437+
---
438+
439+
### `screencast_start`
440+
441+
**Description:** Starts recording a screencast (video) of the selected page in specified format. (requires flag: --experimentalScreencast=true)
442+
443+
**Parameters:**
444+
445+
- **filePath** (string) _(optional)_: Output file path (.webm,.mp4 are supported). Uses mkdtemp to generate a unique path if not provided.
446+
447+
---
448+
449+
### `screencast_stop`
450+
451+
**Description:** Stops the active screencast recording on the selected page. (requires flag: --experimentalScreencast=true)
452+
453+
**Parameters:** None
454+
455+
---
456+
457+
## Memory
458+
459+
### `take_memory_snapshot`
460+
461+
**Description:** Capture a heap snapshot of the currently selected page. Use to analyze the memory distribution of JavaScript objects and debug memory leaks.
462+
463+
**Parameters:**
464+
465+
- **filePath** (string) **(required)**: A path to a .heapsnapshot file to save the heapsnapshot to.
466+
467+
---
468+
469+
### `get_memory_snapshot_details`
470+
471+
**Description:** Loads a memory heapsnapshot and returns all available information including statistics, static data, and aggregated node information. Supports pagination for aggregates. (requires flag: --experimentalMemory=true)
472+
473+
**Parameters:**
474+
475+
- **filePath** (string) **(required)**: A path to a .heapsnapshot file to read.
476+
- **pageIdx** (number) _(optional)_: The page index for pagination of aggregates.
477+
- **pageSize** (number) _(optional)_: The page size for pagination of aggregates.
478+
479+
---
480+
481+
### `get_nodes_by_class`
482+
483+
**Description:** Loads a memory heapsnapshot and returns instances of a specific class with their stable IDs. (requires flag: --experimentalMemory=true)
484+
485+
**Parameters:**
486+
487+
- **filePath** (string) **(required)**: A path to a .heapsnapshot file to read.
488+
- **uid** (number) **(required)**: The unique UID for the class, obtained from aggregates listing.
489+
- **pageIdx** (number) _(optional)_: The page index for pagination.
490+
- **pageSize** (number) _(optional)_: The page size for pagination.
491+
492+
---
493+
494+
### `load_memory_snapshot`
495+
496+
**Description:** Loads a memory heapsnapshot and returns snapshot summary stats. (requires flag: --experimentalMemory=true)
497+
498+
**Parameters:**
499+
500+
- **filePath** (string) **(required)**: A path to a .heapsnapshot file to read.
501+
502+
---
503+
399504
## Extensions
400505

401506
> NOTE: Extensions are not active by default. Use the '--categoryExtensions' flag
402507
403508
### `install_extension`
404509

405-
**Description:** Installs a Chrome extension from the given path.
510+
**Description:** Installs a Chrome extension from the given path. (requires flag: --categoryExtensions=true)
406511

407512
**Parameters:**
408513

@@ -412,15 +517,15 @@ in the DevTools Elements panel (if any).
412517

413518
### `list_extensions`
414519

415-
**Description:** Lists all the Chrome extensions installed in the browser. This includes their name, ID, version, and enabled status.
520+
**Description:** Lists all the Chrome extensions installed in the browser. This includes their name, ID, version, and enabled status. (requires flag: --categoryExtensions=true)
416521

417522
**Parameters:** None
418523

419524
---
420525

421526
### `reload_extension`
422527

423-
**Description:** Reloads an unpacked Chrome extension by its ID.
528+
**Description:** Reloads an unpacked Chrome extension by its ID. (requires flag: --categoryExtensions=true)
424529

425530
**Parameters:**
426531

@@ -430,7 +535,7 @@ in the DevTools Elements panel (if any).
430535

431536
### `trigger_extension_action`
432537

433-
**Description:** Triggers the default action of an extension by its ID.
538+
**Description:** Triggers the default action of an extension by its ID. (requires flag: --categoryExtensions=true)
434539

435540
**Parameters:**
436541

@@ -440,22 +545,10 @@ in the DevTools Elements panel (if any).
440545

441546
### `uninstall_extension`
442547

443-
**Description:** Uninstalls a Chrome extension by its ID.
548+
**Description:** Uninstalls a Chrome extension by its ID. (requires flag: --categoryExtensions=true)
444549

445550
**Parameters:**
446551

447552
- **id** (string) **(required)**: ID of the extension to uninstall.
448553

449554
---
450-
451-
## Memory
452-
453-
### `take_memory_snapshot`
454-
455-
**Description:** Capture a heap snapshot of the currently selected page. Use to analyze the memory distribution of JavaScript objects and debug memory leaks.
456-
457-
**Parameters:**
458-
459-
- **filePath** (string) **(required)**: A path to a .heapsnapshot file to save the heapsnapshot to.
460-
461-
---

scripts/generate-docs.ts

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,20 @@ function addCrossLinks(text: string, tools: ToolWithAnnotations[]): string {
131131
return result;
132132
}
133133

134+
function sortTools(a: ToolWithAnnotations, b: ToolWithAnnotations): number {
135+
const aHasConditions = Boolean(a.annotations?.conditions?.length > 0);
136+
const bHasConditions = Boolean(b.annotations?.conditions?.length > 0);
137+
138+
if (aHasConditions && !bHasConditions) {
139+
return 1;
140+
}
141+
if (!aHasConditions && bHasConditions) {
142+
return -1;
143+
}
144+
145+
return a.name.localeCompare(b.name);
146+
}
147+
134148
function generateToolsTOC(
135149
categories: Record<string, ToolWithAnnotations[]>,
136150
sortedCategories: string[],
@@ -143,7 +157,7 @@ function generateToolsTOC(
143157
toc += `- **${categoryName}** (${categoryTools.length} tools)\n`;
144158

145159
// Sort tools within category for TOC
146-
categoryTools.sort((a: Tool, b: Tool) => a.name.localeCompare(b.name));
160+
categoryTools.sort(sortTools);
147161
for (const tool of categoryTools) {
148162
const anchorLink = tool.name.toLowerCase();
149163
toc += ` - [\`${tool.name}\`](docs/tool-reference.md#${anchorLink})\n`;
@@ -341,7 +355,7 @@ async function generateReference(
341355
markdown += `- **[${categoryName}](#${anchorName})** (${categoryTools.length} tools)\n`;
342356

343357
// Sort tools within category for TOC
344-
categoryTools.sort((a: Tool, b: Tool) => a.name.localeCompare(b.name));
358+
categoryTools.sort(sortTools);
345359
for (const tool of categoryTools) {
346360
// Generate proper markdown anchor link: backticks are removed, keep underscores, lowercase
347361
const anchorLink = tool.name.toLowerCase();
@@ -363,7 +377,7 @@ async function generateReference(
363377
}
364378

365379
// Sort tools within category
366-
categoryTools.sort((a: Tool, b: Tool) => a.name.localeCompare(b.name));
380+
categoryTools.sort(sortTools);
367381

368382
for (const tool of categoryTools) {
369383
markdown += `### \`${tool.name}\`\n\n`;
@@ -372,6 +386,23 @@ async function generateReference(
372386
// Escape HTML tags but preserve JS function syntax
373387
let escapedDescription = escapeHtmlTags(tool.description);
374388

389+
const requiredFlags: string[] = [];
390+
391+
const isOffByDefault = OFF_BY_DEFAULT_CATEGORIES.includes(category);
392+
if (isOffByDefault) {
393+
const categoryFlag = buildFlag(category);
394+
requiredFlags.push(`--${categoryFlag}=true`);
395+
}
396+
397+
const conditions = tool.annotations?.conditions || [];
398+
for (const condition of conditions) {
399+
requiredFlags.push(`--${condition}=true`);
400+
}
401+
402+
if (requiredFlags.length > 0) {
403+
escapedDescription += ` (requires flag: ${requiredFlags.join(', ')})`;
404+
}
405+
375406
// Add cross-links to mentioned tools
376407
escapedDescription = addCrossLinks(
377408
escapedDescription,
@@ -448,16 +479,17 @@ function getToolsAndCategories(tools: any) {
448479
const toolsWithAnnotations: ToolWithAnnotations[] = tools
449480
.filter(tool => {
450481
// Skipping in_page tools as they are not launched yet
451-
if (tool.annotations.category.includes('experimental')) {
482+
if (tool.annotations.category === ToolCategory.IN_PAGE) {
452483
return false;
453484
}
454485

455-
if (!tool.annotations.conditions) {
456-
return true;
486+
// Skipping internal interop tools not meant for public documentation
487+
const skipTools = ['get_tab_id'];
488+
if (skipTools.includes(tool.name)) {
489+
return false;
457490
}
458491

459-
// Only include unconditional tools.
460-
return tool.annotations.conditions.length === 0;
492+
return true;
461493
})
462494
.map(tool => {
463495
const properties: Record<string, TypeInfo> = {};
@@ -497,8 +529,16 @@ function getToolsAndCategories(tools: any) {
497529
// Sort categories using the enum order
498530
const categoryOrder = Object.values(ToolCategory);
499531
const sortedCategories = Object.keys(categories).sort((a, b) => {
500-
const aIndex = categoryOrder.indexOf(a);
501-
const bIndex = categoryOrder.indexOf(b);
532+
const aOff = OFF_BY_DEFAULT_CATEGORIES.includes(a as ToolCategory);
533+
const bOff = OFF_BY_DEFAULT_CATEGORIES.includes(b as ToolCategory);
534+
535+
if (aOff !== bOff) {
536+
return aOff ? 1 : -1;
537+
}
538+
539+
const aIndex = categoryOrder.indexOf(a as ToolCategory);
540+
const bIndex = categoryOrder.indexOf(b as ToolCategory);
541+
502542
// Put known categories first, unknown categories last
503543
if (aIndex === -1 && bIndex === -1) {
504544
return a.localeCompare(b);

0 commit comments

Comments
 (0)