diff --git a/package.json b/package.json index b8feb89f4..10b7bbc77 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "version": "0.19.0", "description": "MCP server for Chrome DevTools", "type": "module", - "bin": "./build/src/index.js", - "main": "./build/src/server.js", + "bin": "./build/src/bin/chrome-devtools-mcp.js", + "main": "./build/src/index.js", "scripts": { "cli:generate": "node --experimental-strip-types scripts/generate-cli.ts", "clean": "node -e \"require('fs').rmSync('build', {recursive: true, force: true})\"", diff --git a/scripts/generate-cli.ts b/scripts/generate-cli.ts index 297a473e6..c8c0dc520 100644 --- a/scripts/generate-cli.ts +++ b/scripts/generate-cli.ts @@ -10,7 +10,7 @@ import path from 'node:path'; import {Client} from '@modelcontextprotocol/sdk/client/index.js'; import {StdioClientTransport} from '@modelcontextprotocol/sdk/client/stdio.js'; -import {parseArguments} from '../build/src/cli.js'; +import {parseArguments} from '../build/src/bin/chrome-devtools-mcp-cli-options.js'; import {labels} from '../build/src/tools/categories.js'; import {createTools} from '../build/src/tools/tools.js'; @@ -22,7 +22,10 @@ const OUTPUT_PATH = path.join( async function fetchTools() { console.log('Connecting to chrome-devtools-mcp to fetch tools...'); // Use the local build of the server - const serverPath = path.join(import.meta.dirname, '../build/src/index.js'); + const serverPath = path.join( + import.meta.dirname, + '../build/src/bin/chrome-devtools-mcp.js', + ); const transport = new StdioClientTransport({ command: 'node', diff --git a/scripts/generate-docs.ts b/scripts/generate-docs.ts index c2e5da7ca..280c0e332 100644 --- a/scripts/generate-docs.ts +++ b/scripts/generate-docs.ts @@ -11,8 +11,8 @@ import {StdioClientTransport} from '@modelcontextprotocol/sdk/client/stdio.js'; import type {Tool} from '@modelcontextprotocol/sdk/types.js'; import {get_encoding} from 'tiktoken'; -import {cliOptions} from '../build/src/cli.js'; -import type {ParsedArguments} from '../build/src/cli.js'; +import {cliOptions} from '../build/src/bin/chrome-devtools-mcp-cli-options.js'; +import type {ParsedArguments} from '../build/src/bin/chrome-devtools-mcp-cli-options.js'; import {ToolCategory, labels} from '../build/src/tools/categories.js'; import {createTools} from '../build/src/tools/tools.js'; @@ -24,7 +24,7 @@ async function measureServer(args: string[]) { // 1. Connect to your actual MCP server const transport = new StdioClientTransport({ command: 'node', - args: ['./build/src/index.js', ...args], // Point to your built MCP server + args: ['./build/src/bin/chrome-devtools-mcp.js', ...args], // Point to your built MCP server }); const client = new Client( diff --git a/src/McpResponse.ts b/src/McpResponse.ts index b1b2cef30..b6162c27c 100644 --- a/src/McpResponse.ts +++ b/src/McpResponse.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import type {ParsedArguments} from './cli.js'; +import type {ParsedArguments} from './bin/chrome-devtools-mcp-cli-options.js'; import {ConsoleFormatter} from './formatters/ConsoleFormatter.js'; import {IssueFormatter} from './formatters/IssueFormatter.js'; import {NetworkFormatter} from './formatters/NetworkFormatter.js'; diff --git a/src/bin/chrome-devtools-cli-options.ts b/src/bin/chrome-devtools-cli-options.ts new file mode 100644 index 000000000..6e317a333 --- /dev/null +++ b/src/bin/chrome-devtools-cli-options.ts @@ -0,0 +1,745 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +// NOTE: do not edit manually. Auto-generated by 'npm run cli:generate'. + +export interface ArgDef { + name: string; + type: string; + description: string; + required: boolean; + default?: string | number | boolean; + enum?: ReadonlyArray; +} +export type Commands = Record< + string, + { + description: string; + category: string; + args: Record; + } +>; +export const commands: Commands = { + click: { + description: 'Clicks on the provided element', + category: 'Input automation', + args: { + uid: { + name: 'uid', + type: 'string', + description: + 'The uid of an element on the page from the page content snapshot', + required: true, + }, + dblClick: { + name: 'dblClick', + type: 'boolean', + description: 'Set to true for double clicks. Default is false.', + required: false, + }, + includeSnapshot: { + name: 'includeSnapshot', + type: 'boolean', + description: + 'Whether to include a snapshot in the response. Default is false.', + required: false, + }, + }, + }, + close_page: { + description: + 'Closes the page by its index. The last open page cannot be closed.', + category: 'Navigation automation', + args: { + pageId: { + name: 'pageId', + type: 'number', + description: + 'The ID of the page to close. Call list_pages to list pages.', + required: true, + }, + }, + }, + drag: { + description: 'Drag an element onto another element', + category: 'Input automation', + args: { + from_uid: { + name: 'from_uid', + type: 'string', + description: 'The uid of the element to drag', + required: true, + }, + to_uid: { + name: 'to_uid', + type: 'string', + description: 'The uid of the element to drop into', + required: true, + }, + includeSnapshot: { + name: 'includeSnapshot', + type: 'boolean', + description: + 'Whether to include a snapshot in the response. Default is false.', + required: false, + }, + }, + }, + emulate: { + description: 'Emulates various features on the selected page.', + category: 'Emulation', + args: { + networkConditions: { + name: 'networkConditions', + type: 'string', + description: 'Throttle network. Omit to disable throttling.', + required: false, + enum: ['Offline', 'Slow 3G', 'Fast 3G', 'Slow 4G', 'Fast 4G'], + }, + cpuThrottlingRate: { + name: 'cpuThrottlingRate', + type: 'number', + description: + 'Represents the CPU slowdown factor. Omit or set the rate to 1 to disable throttling', + required: false, + }, + geolocation: { + name: 'geolocation', + type: 'string', + description: + 'Geolocation (`x`) to emulate. Latitude between -90 and 90. Longitude between -180 and 180. Omit clear the geolocation override.', + required: false, + }, + userAgent: { + name: 'userAgent', + type: 'string', + description: + 'User agent to emulate. Set to empty string to clear the user agent override.', + required: false, + }, + colorScheme: { + name: 'colorScheme', + type: 'string', + description: + 'Emulate the dark or the light mode. Set to "auto" to reset to the default.', + required: false, + enum: ['dark', 'light', 'auto'], + }, + viewport: { + name: 'viewport', + type: 'string', + description: + "Emulate device viewports 'xx[,mobile][,touch][,landscape]'. 'touch' and 'mobile' to emulate mobile devices. 'landscape' to emulate landscape mode.", + required: false, + }, + }, + }, + evaluate_script: { + description: + 'Evaluate a JavaScript function inside the currently selected page. Returns the response as JSON,\nso returned values have to be JSON-serializable.', + category: 'Debugging', + args: { + function: { + name: 'function', + type: 'string', + description: + 'A JavaScript function declaration to be executed by the tool in the currently selected page.\nExample without arguments: `() => {\n return document.title\n}` or `async () => {\n return await fetch("example.com")\n}`.\nExample with arguments: `(el) => {\n return el.innerText;\n}`\n', + required: true, + }, + args: { + name: 'args', + type: 'array', + description: 'An optional list of arguments to pass to the function.', + required: false, + }, + }, + }, + fill: { + description: + 'Type text into a input, text area or select an option from a