Skip to content

Commit 52b9774

Browse files
committed
fix: optimize token usage
1 parent 7ffdc5e commit 52b9774

18 files changed

Lines changed: 242 additions & 342 deletions

docs/slim-tool-reference.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- AUTO GENERATED DO NOT EDIT - run 'npm run docs' to update-->
22

3-
# Chrome DevTools MCP Slim Tool Reference (~368 cl100k_base tokens)
3+
# Chrome DevTools MCP Slim Tool Reference (~359 cl100k_base tokens)
44

55
- **[Navigation automation](#navigation-automation)** (1 tools)
66
- [`navigate`](#navigate)
@@ -12,29 +12,29 @@
1212

1313
### `navigate`
1414

15-
**Description:** Load URL in the browser
15+
**Description:** Loads a URL.
1616

1717
**Parameters:**
1818

19-
- **url** (string) **(required)**: Page URL
19+
- **url** (string) **(required)**: URL to [`navigate`](#navigate) to.
2020

2121
---
2222

2323
## Debugging
2424

2525
### `evaluate`
2626

27-
**Description:** [`Evaluate`](#evaluate) a JavaScript function on the last loaded page
27+
**Description:** Evaluates a JavaScript function.
2828

2929
**Parameters:**
3030

31-
- **fn** (string) **(required)**: A JavaScript function to be executed on the active page
31+
- **fn** (string) **(required)**: JS function to run on the page.
3232

3333
---
3434

3535
### `screenshot`
3636

37-
**Description:** Take a [`screenshot`](#screenshot) of the active page.
37+
**Description:** Takes a [`screenshot`](#screenshot).
3838

3939
**Parameters:** None
4040

docs/tool-reference.md

Lines changed: 97 additions & 109 deletions
Large diffs are not rendered by default.

scripts/dump_tools.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import {Client} from '@modelcontextprotocol/sdk/client/index.js';
8+
import {StdioClientTransport} from '@modelcontextprotocol/sdk/client/stdio.js';
9+
10+
const transport = new StdioClientTransport({
11+
command: 'node',
12+
args: ['./build/src/index.js'],
13+
});
14+
15+
const client = new Client(
16+
{name: 'measurer', version: '1.0.0'},
17+
{capabilities: {}},
18+
);
19+
await client.connect(transport);
20+
21+
const toolsList = await client.listTools();
22+
const jsonString = JSON.stringify(toolsList.tools);
23+
console.log(jsonString);
24+
await client.close();

src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ const server = new McpServer(
7272
name: 'chrome_devtools',
7373
title: 'Chrome DevTools MCP server',
7474
version: VERSION,
75+
description:
76+
'All tools operate on the currently selected page. Many tools take a `uid` of an element from a page content snapshot.',
7577
},
7678
{capabilities: {logging: {}}},
7779
);

src/tools/ToolDefinition.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,7 @@ export const timeoutSchema = {
178178
.number()
179179
.int()
180180
.optional()
181-
.describe(
182-
`Maximum wait time in milliseconds. If set to 0, the default timeout will be used.`,
183-
)
181+
.describe(`Max wait time in ms. 0 for default.`)
184182
.transform(value => {
185183
return value && value <= 0 ? undefined : value;
186184
}),

src/tools/console.ts

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ const FILTERABLE_MESSAGE_TYPES: [
3939

4040
export const listConsoleMessages = defineTool({
4141
name: 'list_console_messages',
42-
description:
43-
'List all console messages for the currently selected page since the last navigation.',
42+
description: 'List all console messages since the last navigation.',
4443
annotations: {
4544
category: ToolCategory.DEBUGGING,
4645
readOnlyHint: true,
@@ -51,30 +50,22 @@ export const listConsoleMessages = defineTool({
5150
.int()
5251
.positive()
5352
.optional()
54-
.describe(
55-
'Maximum number of messages to return. When omitted, returns all requests.',
56-
),
53+
.describe('Max messages to return. Omit for all.'),
5754
pageIdx: zod
5855
.number()
5956
.int()
6057
.min(0)
6158
.optional()
62-
.describe(
63-
'Page number to return (0-based). When omitted, returns the first page.',
64-
),
59+
.describe('0-based page number. Omit for first page.'),
6560
types: zod
6661
.array(zod.enum(FILTERABLE_MESSAGE_TYPES))
6762
.optional()
68-
.describe(
69-
'Filter messages to only return messages of the specified resource types. When omitted or empty, returns all messages.',
70-
),
63+
.describe('Filter by message type. Omit or empty for all.'),
7164
includePreservedMessages: zod
7265
.boolean()
7366
.default(false)
7467
.optional()
75-
.describe(
76-
'Set to true to return the preserved messages over the last 3 navigations.',
77-
),
68+
.describe('Set to true for preserved messages over last 3 navigations.'),
7869
},
7970
handler: async (request, response) => {
8071
response.setIncludeConsoleData(true, {
@@ -96,9 +87,7 @@ export const getConsoleMessage = defineTool({
9687
schema: {
9788
msgid: zod
9889
.number()
99-
.describe(
100-
'The msgid of a console message on the page from the listed console messages',
101-
),
90+
.describe('msgid of a console message from listed messages'),
10291
},
10392
handler: async (request, response) => {
10493
response.attachConsoleMessage(request.params.msgid);

src/tools/emulation.ts

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const throttlingOptions: [string, ...string[]] = [
1818

1919
export const emulate = defineTool({
2020
name: 'emulate',
21-
description: `Emulates various features on the selected page.`,
21+
description: `Emulates various features.`,
2222
annotations: {
2323
category: ToolCategory.EMULATION,
2424
readOnlyHint: false,
@@ -28,16 +28,14 @@ export const emulate = defineTool({
2828
.enum(throttlingOptions)
2929
.optional()
3030
.describe(
31-
`Throttle network. Set to "No emulation" to disable. If omitted, conditions remain unchanged.`,
31+
`Throttle network. "No emulation" to disable. Omit to keep unchanged.`,
3232
),
3333
cpuThrottlingRate: zod
3434
.number()
3535
.min(1)
3636
.max(20)
3737
.optional()
38-
.describe(
39-
'Represents the CPU slowdown factor. Set the rate to 1 to disable throttling. If omitted, throttling remains unchanged.',
40-
),
38+
.describe('CPU slowdown factor. 1 to disable. Omit to keep unchanged.'),
4139
geolocation: zod
4240
.object({
4341
latitude: zod
@@ -53,55 +51,41 @@ export const emulate = defineTool({
5351
})
5452
.nullable()
5553
.optional()
56-
.describe(
57-
'Geolocation to emulate. Set to null to clear the geolocation override.',
58-
),
54+
.describe('Geolocation to emulate. null to clear override.'),
5955
userAgent: zod
6056
.string()
6157
.nullable()
6258
.optional()
63-
.describe(
64-
'User agent to emulate. Set to null to clear the user agent override.',
65-
),
59+
.describe('User agent to emulate. null to clear override.'),
6660
colorScheme: zod
6761
.enum(['dark', 'light', 'auto'])
6862
.optional()
69-
.describe(
70-
'Emulate the dark or the light mode. Set to "auto" to reset to the default.',
71-
),
63+
.describe('Emulate dark or light mode. "auto" to reset.'),
7264
viewport: zod
7365
.object({
74-
width: zod.number().int().min(0).describe('Page width in pixels.'),
75-
height: zod.number().int().min(0).describe('Page height in pixels.'),
66+
width: zod.number().int().min(0).describe('Page width (px).'),
67+
height: zod.number().int().min(0).describe('Page height (px).'),
7668
deviceScaleFactor: zod
7769
.number()
7870
.min(0)
7971
.optional()
80-
.describe('Specify device scale factor (can be thought of as dpr).'),
72+
.describe('Device scale factor (dpr).'),
8173
isMobile: zod
8274
.boolean()
8375
.optional()
84-
.describe(
85-
'Whether the meta viewport tag is taken into account. Defaults to false.',
86-
),
76+
.describe('Use meta viewport tag. Default: false.'),
8777
hasTouch: zod
8878
.boolean()
8979
.optional()
90-
.describe(
91-
'Specifies if viewport supports touch events. This should be set to true for mobile devices.',
92-
),
80+
.describe('Viewport supports touch. true for mobile.'),
9381
isLandscape: zod
9482
.boolean()
9583
.optional()
96-
.describe(
97-
'Specifies if viewport is in landscape mode. Defaults to false.',
98-
),
84+
.describe('Landscape mode. Default: false.'),
9985
})
10086
.nullable()
10187
.optional()
102-
.describe(
103-
'Viewport to emulate. Set to null to reset to the default viewport.',
104-
),
88+
.describe('Viewport to emulate. null to reset.'),
10589
},
10690
handler: async (request, _response, context) => {
10791
await context.emulate(request.params);

src/tools/extensions.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ export const installExtension = defineTool({
2020
conditions: [EXTENSIONS_CONDITION],
2121
},
2222
schema: {
23-
path: zod
24-
.string()
25-
.describe('Absolute path to the unpacked extension folder.'),
23+
path: zod.string().describe('Absolute path to unpacked extension.'),
2624
},
2725
handler: async (request, response, context) => {
2826
const {path} = request.params;
@@ -40,7 +38,7 @@ export const uninstallExtension = defineTool({
4038
conditions: [EXTENSIONS_CONDITION],
4139
},
4240
schema: {
43-
id: zod.string().describe('ID of the extension to uninstall.'),
41+
id: zod.string().describe('ID of extension to uninstall.'),
4442
},
4543
handler: async (request, response, context) => {
4644
const {id} = request.params;
@@ -51,8 +49,7 @@ export const uninstallExtension = defineTool({
5149

5250
export const listExtensions = defineTool({
5351
name: 'list_extensions',
54-
description:
55-
'Lists all extensions via this server, including their name, ID, version, and enabled status.',
52+
description: 'Lists all extensions with name, ID, version, and status.',
5653
annotations: {
5754
category: ToolCategory.EXTENSIONS,
5855
readOnlyHint: true,
@@ -73,7 +70,7 @@ export const reloadExtension = defineTool({
7370
conditions: [EXTENSIONS_CONDITION],
7471
},
7572
schema: {
76-
id: zod.string().describe('ID of the extension to reload.'),
73+
id: zod.string().describe('ID of extension to reload.'),
7774
},
7875
handler: async (request, response, context) => {
7976
const {id} = request.params;

0 commit comments

Comments
 (0)