Skip to content

Commit 65e5829

Browse files
authored
Merge branch 'main' into get-specific-console-message-tool
2 parents 35d3945 + 5a062ce commit 65e5829

File tree

17 files changed

+231
-215
lines changed

17 files changed

+231
-215
lines changed

.github/workflows/publish-to-npm-on-tag.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545

4646
- name: Build
4747
run: npm run build
48+
env:
49+
NODE_ENV: 'production'
4850

4951
- name: Publish
5052
run: |
@@ -76,6 +78,8 @@ jobs:
7678

7779
- name: Build
7880
run: npm run build
81+
env:
82+
NODE_ENV: 'production'
7983

8084
- name: Install MCP Publisher
8185
run: |

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ Configure the following fields and press `CTRL+S` to save the configuration:
125125

126126
- **Server name:** `chrome-devtools`
127127
- **Server Type:** `[1] Local`
128-
- **Command:** `npx`
129-
- **Arguments:** `-y, chrome-devtools-mcp@latest`
128+
- **Command:** `npx -y chrome-devtools-mcp@latest`
130129

131130
</details>
132131

package-lock.json

Lines changed: 129 additions & 141 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@
4040
"core-js": "3.46.0",
4141
"debug": "4.4.3",
4242
"puppeteer-core": "^24.24.1",
43-
"yargs": "18.0.0",
44-
"zod": "^3.25.76"
43+
"yargs": "18.0.0"
4544
},
4645
"devDependencies": {
4746
"@eslint/js": "^9.35.0",
48-
"@modelcontextprotocol/sdk": "1.20.0",
47+
"@modelcontextprotocol/sdk": "1.20.1",
4948
"@rollup/plugin-commonjs": "^28.0.8",
5049
"@rollup/plugin-json": "^6.1.0",
5150
"@rollup/plugin-node-resolve": "^16.0.3",
@@ -63,8 +62,8 @@
6362
"eslint-plugin-import": "^2.32.0",
6463
"globals": "^16.4.0",
6564
"prettier": "^3.6.2",
66-
"puppeteer": "24.24.1",
67-
"rollup": "4.52.4",
65+
"puppeteer": "24.25.0",
66+
"rollup": "4.52.5",
6867
"rollup-plugin-cleanup": "^3.2.1",
6968
"rollup-plugin-license": "^3.6.0",
7069
"sinon": "^21.0.0",

rollup.config.mjs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
/**
18+
* @fileoverview take from {@link https://github.com/GoogleChromeLabs/chromium-bidi/blob/main/rollup.config.mjs | chromium-bidi}
19+
* and modified to specific requirement.
20+
*/
21+
1722
import path from 'node:path';
1823

1924
import commonjs from '@rollup/plugin-commonjs';
@@ -22,11 +27,14 @@ import {nodeResolve} from '@rollup/plugin-node-resolve';
2227
import cleanup from 'rollup-plugin-cleanup';
2328
import license from 'rollup-plugin-license';
2429

30+
const isProduction = process.env.NODE_ENV === 'production';
31+
32+
/** @type {import('rollup').RollupOptions} */
2533
const sdk = {
2634
input: './build/src/third_party/modelcontextprotocol-sdk/index.js',
2735
output: {
2836
file: './build/src/third_party/modelcontextprotocol-sdk/index.js',
29-
sourcemap: false,
37+
sourcemap: !isProduction,
3038
format: 'esm',
3139
},
3240
plugins: [
@@ -37,7 +45,6 @@ const sdk = {
3745
comments: [/Copyright/i],
3846
}),
3947
license({
40-
debug: true,
4148
thirdParty: {
4249
allow: {
4350
test: dependency => {

src/third_party/modelcontextprotocol-sdk/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ export {
1212
type ImageContent,
1313
type TextContent,
1414
} from '@modelcontextprotocol/sdk/types.js';
15+
export {z as zod} from 'zod';

src/tools/ToolDefinition.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
*/
66

77
import type {Dialog, ElementHandle, Page} from 'puppeteer-core';
8-
import z from 'zod';
98

109
import type {TextSnapshotNode} from '../McpContext.js';
10+
import {zod} from '../third_party/modelcontextprotocol-sdk/index.js';
1111
import type {TraceResult} from '../trace-processing/parse.js';
1212
import type {PaginationOptions} from '../utils/types.js';
1313

1414
import type {ToolCategories} from './categories.js';
1515

16-
export interface ToolDefinition<Schema extends z.ZodRawShape = z.ZodRawShape> {
16+
export interface ToolDefinition<
17+
Schema extends zod.ZodRawShape = zod.ZodRawShape,
18+
> {
1719
name: string;
1820
description: string;
1921
annotations: {
@@ -32,8 +34,8 @@ export interface ToolDefinition<Schema extends z.ZodRawShape = z.ZodRawShape> {
3234
) => Promise<void>;
3335
}
3436

35-
export interface Request<Schema extends z.ZodRawShape> {
36-
params: z.objectOutputType<Schema, z.ZodTypeAny>;
37+
export interface Request<Schema extends zod.ZodRawShape> {
38+
params: zod.objectOutputType<Schema, zod.ZodTypeAny>;
3739
}
3840

3941
export interface ImageContentData {
@@ -93,7 +95,7 @@ export type Context = Readonly<{
9395
waitForEventsAfterAction(action: () => Promise<unknown>): Promise<void>;
9496
}>;
9597

96-
export function defineTool<Schema extends z.ZodRawShape>(
98+
export function defineTool<Schema extends zod.ZodRawShape>(
9799
definition: ToolDefinition<Schema>,
98100
) {
99101
return definition;
@@ -103,7 +105,7 @@ export const CLOSE_PAGE_ERROR =
103105
'The last open page cannot be closed. It is fine to keep it open.';
104106

105107
export const timeoutSchema = {
106-
timeout: z
108+
timeout: zod
107109
.number()
108110
.int()
109111
.optional()

src/tools/console.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66

77
import type {ConsoleMessageType} from 'puppeteer-core';
8-
import z from 'zod';
8+
9+
import {zod} from '../third_party/modelcontextprotocol-sdk/index.js';
910

1011
import {ToolCategories} from './categories.js';
1112
import {defineTool} from './ToolDefinition.js';
@@ -44,24 +45,24 @@ export const listConsoleMessages = defineTool({
4445
readOnlyHint: true,
4546
},
4647
schema: {
47-
pageSize: z
48+
pageSize: zod
4849
.number()
4950
.int()
5051
.positive()
5152
.optional()
5253
.describe(
5354
'Maximum number of messages to return. When omitted, returns all requests.',
5455
),
55-
pageIdx: z
56+
pageIdx: zod
5657
.number()
5758
.int()
5859
.min(0)
5960
.optional()
6061
.describe(
6162
'Page number to return (0-based). When omitted, returns the first page.',
6263
),
63-
types: z
64-
.array(z.enum(FILTERABLE_MESSAGE_TYPES))
64+
types: zod
65+
.array(zod.enum(FILTERABLE_MESSAGE_TYPES))
6566
.optional()
6667
.describe(
6768
'Filter messages to only return messages of the specified resource types. When omitted or empty, returns all messages.',

src/tools/emulation.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66

77
import {PredefinedNetworkConditions} from 'puppeteer-core';
8-
import z from 'zod';
8+
9+
import {zod} from '../third_party/modelcontextprotocol-sdk/index.js';
910

1011
import {ToolCategories} from './categories.js';
1112
import {defineTool} from './ToolDefinition.js';
@@ -24,7 +25,7 @@ export const emulateNetwork = defineTool({
2425
readOnlyHint: false,
2526
},
2627
schema: {
27-
throttlingOption: z
28+
throttlingOption: zod
2829
.enum(throttlingOptions)
2930
.describe(
3031
`The network throttling option to emulate. Available throttling options are: ${throttlingOptions.join(', ')}. Set to "No emulation" to disable. Set to "Offline" to simulate offline network conditions.`,
@@ -70,7 +71,7 @@ export const emulateCpu = defineTool({
7071
readOnlyHint: false,
7172
},
7273
schema: {
73-
throttlingRate: z
74+
throttlingRate: zod
7475
.number()
7576
.min(1)
7677
.max(20)

src/tools/input.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
*/
66

77
import type {ElementHandle} from 'puppeteer-core';
8-
import z from 'zod';
98

109
import type {McpContext, TextSnapshotNode} from '../McpContext.js';
10+
import {zod} from '../third_party/modelcontextprotocol-sdk/index.js';
1111

1212
import {ToolCategories} from './categories.js';
1313
import {defineTool} from './ToolDefinition.js';
@@ -20,12 +20,12 @@ export const click = defineTool({
2020
readOnlyHint: false,
2121
},
2222
schema: {
23-
uid: z
23+
uid: zod
2424
.string()
2525
.describe(
2626
'The uid of an element on the page from the page content snapshot',
2727
),
28-
dblClick: z
28+
dblClick: zod
2929
.boolean()
3030
.optional()
3131
.describe('Set to true for double clicks. Default is false.'),
@@ -59,7 +59,7 @@ export const hover = defineTool({
5959
readOnlyHint: false,
6060
},
6161
schema: {
62-
uid: z
62+
uid: zod
6363
.string()
6464
.describe(
6565
'The uid of an element on the page from the page content snapshot',
@@ -143,12 +143,12 @@ export const fill = defineTool({
143143
readOnlyHint: false,
144144
},
145145
schema: {
146-
uid: z
146+
uid: zod
147147
.string()
148148
.describe(
149149
'The uid of an element on the page from the page content snapshot',
150150
),
151-
value: z.string().describe('The value to fill in'),
151+
value: zod.string().describe('The value to fill in'),
152152
},
153153
handler: async (request, response, context) => {
154154
await context.waitForEventsAfterAction(async () => {
@@ -171,8 +171,8 @@ export const drag = defineTool({
171171
readOnlyHint: false,
172172
},
173173
schema: {
174-
from_uid: z.string().describe('The uid of the element to drag'),
175-
to_uid: z.string().describe('The uid of the element to drop into'),
174+
from_uid: zod.string().describe('The uid of the element to drag'),
175+
to_uid: zod.string().describe('The uid of the element to drop into'),
176176
},
177177
handler: async (request, response, context) => {
178178
const fromHandle = await context.getElementByUid(request.params.from_uid);
@@ -200,11 +200,11 @@ export const fillForm = defineTool({
200200
readOnlyHint: false,
201201
},
202202
schema: {
203-
elements: z
203+
elements: zod
204204
.array(
205-
z.object({
206-
uid: z.string().describe('The uid of the element to fill out'),
207-
value: z.string().describe('Value for the element'),
205+
zod.object({
206+
uid: zod.string().describe('The uid of the element to fill out'),
207+
value: zod.string().describe('Value for the element'),
208208
}),
209209
)
210210
.describe('Elements from snapshot to fill out.'),
@@ -232,12 +232,12 @@ export const uploadFile = defineTool({
232232
readOnlyHint: false,
233233
},
234234
schema: {
235-
uid: z
235+
uid: zod
236236
.string()
237237
.describe(
238238
'The uid of the file input element or an element that will open file chooser on the page from the page content snapshot',
239239
),
240-
filePath: z.string().describe('The local path of the file to upload'),
240+
filePath: zod.string().describe('The local path of the file to upload'),
241241
},
242242
handler: async (request, response, context) => {
243243
const {uid, filePath} = request.params;

0 commit comments

Comments
 (0)