diff --git a/docs/slim-tool-reference.md b/docs/slim-tool-reference.md index b173ebf66..f8bfdf138 100644 --- a/docs/slim-tool-reference.md +++ b/docs/slim-tool-reference.md @@ -1,6 +1,6 @@ -# Chrome DevTools MCP Slim Tool Reference (~368 cl100k_base tokens) +# Chrome DevTools MCP Slim Tool Reference (~359 cl100k_base tokens) - **[Navigation automation](#navigation-automation)** (1 tools) - [`navigate`](#navigate) @@ -12,11 +12,11 @@ ### `navigate` -**Description:** Load URL in the browser +**Description:** Loads a URL. **Parameters:** -- **url** (string) **(required)**: Page URL +- **url** (string) **(required)**: URL to [`navigate`](#navigate) to. --- @@ -24,17 +24,17 @@ ### `evaluate` -**Description:** [`Evaluate`](#evaluate) a JavaScript function on the last loaded page +**Description:** Evaluates a JavaScript function. **Parameters:** -- **fn** (string) **(required)**: A JavaScript function to be executed on the active page +- **fn** (string) **(required)**: JS function to run on the page. --- ### `screenshot` -**Description:** Take a [`screenshot`](#screenshot) of the active page. +**Description:** Takes a [`screenshot`](#screenshot). **Parameters:** None diff --git a/docs/tool-reference.md b/docs/tool-reference.md index 776859acf..6bd1392a6 100644 --- a/docs/tool-reference.md +++ b/docs/tool-reference.md @@ -1,6 +1,6 @@ -# Chrome DevTools MCP Tool Reference (~6885 cl100k_base tokens) +# Chrome DevTools MCP Tool Reference (~6182 cl100k_base tokens) - **[Input automation](#input-automation)** (8 tools) - [`click`](#click) @@ -40,93 +40,93 @@ ### `click` -**Description:** Clicks on the provided element +**Description:** Clicks on an element. **Parameters:** -- **uid** (string) **(required)**: The uid of an element on the page from the page content snapshot -- **dblClick** (boolean) _(optional)_: Set to true for double clicks. Default is false. -- **includeSnapshot** (boolean) _(optional)_: Whether to include a snapshot in the response. Default is false. +- **uid** (string) **(required)**: uid of element from snapshot. +- **dblClick** (boolean) _(optional)_: true for double [`click`](#click). Default: false. +- **includeSnapshot** (boolean) _(optional)_: Include snapshot in response. Default: false. --- ### `drag` -**Description:** [`Drag`](#drag) an element onto another element +**Description:** Drags an element onto another element. **Parameters:** -- **from_uid** (string) **(required)**: The uid of the element to [`drag`](#drag) -- **to_uid** (string) **(required)**: The uid of the element to drop into -- **includeSnapshot** (boolean) _(optional)_: Whether to include a snapshot in the response. Default is false. +- **from_uid** (string) **(required)**: uid of element to [`drag`](#drag). +- **to_uid** (string) **(required)**: uid of element to drop into. +- **includeSnapshot** (boolean) _(optional)_: Include snapshot in response. Default: false. --- ### `fill` -**Description:** Type text into a input, text area or select an option from a <select> element. +**Description:** Types text into an input, textarea or selects an option from a <select> element. **Parameters:** -- **uid** (string) **(required)**: The uid of an element on the page from the page content snapshot -- **value** (string) **(required)**: The value to [`fill`](#fill) in -- **includeSnapshot** (boolean) _(optional)_: Whether to include a snapshot in the response. Default is false. +- **uid** (string) **(required)**: uid of element from snapshot. +- **value** (string) **(required)**: Value to [`fill`](#fill). +- **includeSnapshot** (boolean) _(optional)_: Include snapshot in response. Default: false. --- ### `fill_form` -**Description:** [`Fill`](#fill) out multiple form elements at once +**Description:** Fills out multiple form elements at once. **Parameters:** -- **elements** (array) **(required)**: Elements from snapshot to [`fill`](#fill) out. -- **includeSnapshot** (boolean) _(optional)_: Whether to include a snapshot in the response. Default is false. +- **elements** (array) **(required)**: Elements from snapshot to [`fill`](#fill). +- **includeSnapshot** (boolean) _(optional)_: Include snapshot in response. Default: false. --- ### `handle_dialog` -**Description:** If a browser dialog was opened, use this command to handle it +**Description:** Handles an open browser dialog. **Parameters:** -- **action** (enum: "accept", "dismiss") **(required)**: Whether to dismiss or accept the dialog -- **promptText** (string) _(optional)_: Optional prompt text to enter into the dialog. +- **action** (enum: "accept", "dismiss") **(required)**: Dialog action: accept or dismiss. +- **promptText** (string) _(optional)_: Optional prompt text for dialog. --- ### `hover` -**Description:** [`Hover`](#hover) over the provided element +**Description:** Hovers over an element. **Parameters:** -- **uid** (string) **(required)**: The uid of an element on the page from the page content snapshot -- **includeSnapshot** (boolean) _(optional)_: Whether to include a snapshot in the response. Default is false. +- **uid** (string) **(required)**: uid of element from snapshot. +- **includeSnapshot** (boolean) _(optional)_: Include snapshot in response. Default: false. --- ### `press_key` -**Description:** Press a key or key combination. Use this when other input methods like [`fill`](#fill)() cannot be used (e.g., keyboard shortcuts, navigation keys, or special key combinations). +**Description:** Presses a key or key combination. Use this when other input methods like [`fill`](#fill)() cannot be used (e.g., keyboard shortcuts, navigation keys, or special key combinations). **Parameters:** -- **key** (string) **(required)**: A key or a combination (e.g., "Enter", "Control+A", "Control++", "Control+Shift+R"). Modifiers: Control, Shift, Alt, Meta -- **includeSnapshot** (boolean) _(optional)_: Whether to include a snapshot in the response. Default is false. +- **key** (string) **(required)**: Key or combination (e.g., "Enter", "Control+A"). Modifiers: Control, Shift, Alt, Meta. +- **includeSnapshot** (boolean) _(optional)_: Include snapshot in response. Default: false. --- ### `upload_file` -**Description:** Upload a file through a provided element. +**Description:** Uploads a file through a provided element. **Parameters:** -- **filePath** (string) **(required)**: The local path of the file to upload -- **uid** (string) **(required)**: The uid of the file input element or an element that will open file chooser on the page from the page content snapshot -- **includeSnapshot** (boolean) _(optional)_: Whether to include a snapshot in the response. Default is false. +- **filePath** (string) **(required)**: Local path of file to upload. +- **uid** (string) **(required)**: uid of file input or element that opens file chooser. +- **includeSnapshot** (boolean) _(optional)_: Include snapshot in response. Default: false. --- @@ -134,17 +134,17 @@ ### `close_page` -**Description:** Closes the page by its index. The last open page cannot be closed. +**Description:** Closes a page by its index. The last open page cannot be closed. **Parameters:** -- **pageId** (number) **(required)**: The ID of the page to close. Call [`list_pages`](#list_pages) to list pages. +- **pageId** (number) **(required)**: ID of page to close. Use [`list_pages`](#list_pages). --- ### `list_pages` -**Description:** Get a list of pages open in the browser. +**Description:** Get a list of open pages. **Parameters:** None @@ -152,51 +152,51 @@ ### `navigate_page` -**Description:** Navigates the currently selected page to a URL. +**Description:** Navigates to a URL. **Parameters:** -- **handleBeforeUnload** (enum: "accept", "decline") _(optional)_: Whether to auto accept or beforeunload dialogs triggered by this navigation. Default is accept. -- **ignoreCache** (boolean) _(optional)_: Whether to ignore cache on reload. -- **initScript** (string) _(optional)_: A JavaScript script to be executed on each new document before any other scripts for the next navigation. -- **timeout** (integer) _(optional)_: Maximum wait time in milliseconds. If set to 0, the default timeout will be used. -- **type** (enum: "url", "back", "forward", "reload") _(optional)_: Navigate the page by URL, back or forward in history, or reload. -- **url** (string) _(optional)_: Target URL (only type=url) +- **handleBeforeUnload** (enum: "accept", "decline") _(optional)_: Auto-handle beforeunload dialogs. Default: accept. +- **ignoreCache** (boolean) _(optional)_: Ignore cache on reload. +- **initScript** (string) _(optional)_: JS script to run on new documents for next navigation. +- **timeout** (integer) _(optional)_: Max wait time in ms. 0 for default. +- **type** (enum: "url", "back", "forward", "reload") _(optional)_: Navigation type: url, back, forward, or reload. +- **url** (string) _(optional)_: Target URL (for type=url). --- ### `new_page` -**Description:** Creates a new page +**Description:** Creates a new page. **Parameters:** -- **url** (string) **(required)**: URL to load in a new page. -- **background** (boolean) _(optional)_: Whether to open the page in the background without bringing it to the front. Default is false (foreground). -- **isolatedContext** (string) _(optional)_: If specified, the page is created in an isolated browser context with the given name. Pages in the same browser context share cookies and storage. Pages in different browser contexts are fully isolated. -- **timeout** (integer) _(optional)_: Maximum wait time in milliseconds. If set to 0, the default timeout will be used. +- **url** (string) **(required)**: URL for new page. +- **background** (boolean) _(optional)_: Open in background. Default: false. +- **isolatedContext** (string) _(optional)_: Name for isolated browser context. Pages in same context share cookies/storage. +- **timeout** (integer) _(optional)_: Max wait time in ms. 0 for default. --- ### `select_page` -**Description:** Select a page as a context for future tool calls. +**Description:** Select a page as a context for future calls. **Parameters:** -- **pageId** (number) **(required)**: The ID of the page to select. Call [`list_pages`](#list_pages) to get available pages. -- **bringToFront** (boolean) _(optional)_: Whether to focus the page and bring it to the top. +- **pageId** (number) **(required)**: ID of page to select. Use [`list_pages`](#list_pages) to list pages. +- **bringToFront** (boolean) _(optional)_: Focus the page and bring it to top. --- ### `wait_for` -**Description:** Wait for the specified text to appear on the selected page. +**Description:** Waits for a text to appear. **Parameters:** -- **text** (string) **(required)**: Text to appear on the page -- **timeout** (integer) _(optional)_: Maximum wait time in milliseconds. If set to 0, the default timeout will be used. +- **text** (string) **(required)**: Text to find on the page. +- **timeout** (integer) _(optional)_: Max wait time in ms. 0 for default. --- @@ -204,27 +204,27 @@ ### `emulate` -**Description:** Emulates various features on the selected page. +**Description:** Emulates various features. **Parameters:** -- **colorScheme** (enum: "dark", "light", "auto") _(optional)_: [`Emulate`](#emulate) the dark or the light mode. Set to "auto" to reset to the default. -- **cpuThrottlingRate** (number) _(optional)_: Represents the CPU slowdown factor. Set the rate to 1 to disable throttling. If omitted, throttling remains unchanged. -- **geolocation** (unknown) _(optional)_: Geolocation to [`emulate`](#emulate). Set to null to clear the geolocation override. -- **networkConditions** (enum: "No emulation", "Offline", "Slow 3G", "Fast 3G", "Slow 4G", "Fast 4G") _(optional)_: Throttle network. Set to "No emulation" to disable. If omitted, conditions remain unchanged. -- **userAgent** (unknown) _(optional)_: User agent to [`emulate`](#emulate). Set to null to clear the user agent override. -- **viewport** (unknown) _(optional)_: Viewport to [`emulate`](#emulate). Set to null to reset to the default viewport. +- **colorScheme** (enum: "dark", "light", "auto") _(optional)_: [`Emulate`](#emulate) dark or light mode. "auto" to reset. +- **cpuThrottlingRate** (number) _(optional)_: CPU slowdown factor. 1 to disable. Omit to keep unchanged. +- **geolocation** (unknown) _(optional)_: Geolocation to [`emulate`](#emulate). null to clear override. +- **networkConditions** (enum: "No emulation", "Offline", "Slow 3G", "Fast 3G", "Slow 4G", "Fast 4G") _(optional)_: Throttle network. "No emulation" to disable. Omit to keep unchanged. +- **userAgent** (unknown) _(optional)_: User agent to [`emulate`](#emulate). null to clear override. +- **viewport** (unknown) _(optional)_: Viewport to [`emulate`](#emulate). null to reset. --- ### `resize_page` -**Description:** Resizes the selected page's window so that the page has specified dimension +**Description:** Resizes the page's window to a specified dimension. **Parameters:** -- **height** (number) **(required)**: Page height -- **width** (number) **(required)**: Page width +- **height** (number) **(required)**: Page height. +- **width** (number) **(required)**: Page width. --- @@ -232,44 +232,44 @@ ### `performance_analyze_insight` -**Description:** Provides more detailed information on a specific Performance Insight of an insight set that was highlighted in the results of a trace recording. +**Description:** Provides more details on a specific Performance Insight. **Parameters:** -- **insightName** (string) **(required)**: The name of the Insight you want more information on. For example: "DocumentLatency" or "LCPBreakdown" -- **insightSetId** (string) **(required)**: The id for the specific insight set. Only use the ids given in the "Available insight sets" list. +- **insightName** (string) **(required)**: Name of the insight, e.g., "DocumentLatency" or "LCPBreakdown". +- **insightSetId** (string) **(required)**: ID of the insight set from the "Available insight sets" list. --- ### `performance_start_trace` -**Description:** Starts a performance trace recording on the selected page. This can be used to look for performance problems and insights to improve the performance of the page. It will also report Core Web Vital (CWV) scores for the page. +**Description:** Starts a performance trace recording to find performance problems and insights. **Parameters:** -- **autoStop** (boolean) **(required)**: Determines if the trace recording should be automatically stopped. -- **reload** (boolean) **(required)**: Determines if, once tracing has started, the current selected page should be automatically reloaded. Navigate the page to the right URL using the [`navigate_page`](#navigate_page) tool BEFORE starting the trace if reload or autoStop is set to true. -- **filePath** (string) _(optional)_: The absolute file path, or a file path relative to the current working directory, to save the raw trace data. For example, trace.json.gz (compressed) or trace.json (uncompressed). +- **autoStop** (boolean) **(required)**: Auto-stop trace recording. +- **reload** (boolean) **(required)**: Auto-reload page on trace start. Use [`navigate_page`](#navigate_page) first if needed. +- **filePath** (string) _(optional)_: Path to save raw trace data, e.g., trace.json or trace.json.gz. --- ### `performance_stop_trace` -**Description:** Stops the active performance trace recording on the selected page. +**Description:** Stops the active performance trace recording. **Parameters:** -- **filePath** (string) _(optional)_: The absolute file path, or a file path relative to the current working directory, to save the raw trace data. For example, trace.json.gz (compressed) or trace.json (uncompressed). +- **filePath** (string) _(optional)_: Path to save raw trace data, e.g., trace.json or trace.json.gz. --- ### `take_memory_snapshot` -**Description:** Capture a memory heapsnapshot of the currently selected page to memory leak debugging +**Description:** Capture a memory heapsnapshot for memory leak debugging. **Parameters:** -- **filePath** (string) **(required)**: A path to a .heapsnapshot file to save the heapsnapshot to. +- **filePath** (string) **(required)**: Path to a .heapsnapshot file. --- @@ -281,22 +281,22 @@ **Parameters:** -- **reqid** (number) _(optional)_: The reqid of the network request. If omitted returns the currently selected request in the DevTools Network panel. -- **requestFilePath** (string) _(optional)_: The absolute or relative path to save the request body to. If omitted, the body is returned inline. -- **responseFilePath** (string) _(optional)_: The absolute or relative path to save the response body to. If omitted, the body is returned inline. +- **reqid** (number) _(optional)_: reqid of network request. Omit for selected in DevTools. +- **requestFilePath** (string) _(optional)_: Path to save request body. Omit for inline. +- **responseFilePath** (string) _(optional)_: Path to save response body. Omit for inline. --- ### `list_network_requests` -**Description:** List all requests for the currently selected page since the last navigation. +**Description:** List all requests since the last navigation. **Parameters:** -- **includePreservedRequests** (boolean) _(optional)_: Set to true to return the preserved requests over the last 3 navigations. -- **pageIdx** (integer) _(optional)_: Page number to return (0-based). When omitted, returns the first page. -- **pageSize** (integer) _(optional)_: Maximum number of requests to return. When omitted, returns all requests. -- **resourceTypes** (array) _(optional)_: Filter requests to only return requests of the specified resource types. When omitted or empty, returns all requests. +- **includePreservedRequests** (boolean) _(optional)_: Set to true for preserved requests over last 3 navigations. +- **pageIdx** (integer) _(optional)_: 0-based page number. Omit for first page. +- **pageSize** (integer) _(optional)_: Max requests to return. Omit for all. +- **resourceTypes** (array) _(optional)_: Filter by resource type. Omit or empty for all. --- @@ -304,22 +304,12 @@ ### `evaluate_script` -**Description:** Evaluate a JavaScript function inside the currently selected page. Returns the response as JSON, -so returned values have to be JSON-serializable. +**Description:** Evaluate a JavaScript function. Returns the response as JSON, so returned values have to be JSON-serializable. **Parameters:** -- **function** (string) **(required)**: A JavaScript function declaration to be executed by the tool in the currently selected page. - Example without arguments: `() => { - return document.title -}` or `async () => { - return await fetch("example.com") -}`. - Example with arguments: `(el) => { - return el.innerText; -}` - -- **args** (array) _(optional)_: An optional list of arguments to pass to the function. +- **function** (string) **(required)**: JS function to run on the page. Ex: `() => document.title`, or with args: `(el) => el.innerText`. +- **args** (array) _(optional)_: Optional arguments for the function. --- @@ -329,46 +319,44 @@ so returned values have to be JSON-serializable. **Parameters:** -- **msgid** (number) **(required)**: The msgid of a console message on the page from the listed console messages +- **msgid** (number) **(required)**: msgid of a console message from listed messages --- ### `list_console_messages` -**Description:** List all console messages for the currently selected page since the last navigation. +**Description:** List all console messages since the last navigation. **Parameters:** -- **includePreservedMessages** (boolean) _(optional)_: Set to true to return the preserved messages over the last 3 navigations. -- **pageIdx** (integer) _(optional)_: Page number to return (0-based). When omitted, returns the first page. -- **pageSize** (integer) _(optional)_: Maximum number of messages to return. When omitted, returns all requests. -- **types** (array) _(optional)_: Filter messages to only return messages of the specified resource types. When omitted or empty, returns all messages. +- **includePreservedMessages** (boolean) _(optional)_: Set to true for preserved messages over last 3 navigations. +- **pageIdx** (integer) _(optional)_: 0-based page number. Omit for first page. +- **pageSize** (integer) _(optional)_: Max messages to return. Omit for all. +- **types** (array) _(optional)_: Filter by message type. Omit or empty for all. --- ### `take_screenshot` -**Description:** Take a screenshot of the page or element. +**Description:** Takes a screenshot of the page or an element. **Parameters:** -- **filePath** (string) _(optional)_: The absolute path, or a path relative to the current working directory, to save the screenshot to instead of attaching it to the response. -- **format** (enum: "png", "jpeg", "webp") _(optional)_: Type of format to save the screenshot as. Default is "png" -- **fullPage** (boolean) _(optional)_: If set to true takes a screenshot of the full page instead of the currently visible viewport. Incompatible with uid. -- **quality** (number) _(optional)_: Compression quality for JPEG and WebP formats (0-100). Higher values mean better quality but larger file sizes. Ignored for PNG format. -- **uid** (string) _(optional)_: The uid of an element on the page from the page content snapshot. If omitted takes a pages screenshot. +- **filePath** (string) _(optional)_: Path to save screenshot. If omitted, attaches to response. +- **format** (enum: "png", "jpeg", "webp") _(optional)_: Screenshot format. Default: "png". +- **fullPage** (boolean) _(optional)_: true for full page screenshot. Incompatible with uid. +- **quality** (number) _(optional)_: JPEG/WebP quality (0-100). Higher is better. Ignored for PNG. +- **uid** (string) _(optional)_: uid of element from snapshot. Omit for page screenshot. --- ### `take_snapshot` -**Description:** Take a text snapshot of the currently selected page based on the a11y tree. The snapshot lists page elements along with a unique -identifier (uid). Always use the latest snapshot. Prefer taking a snapshot over taking a screenshot. The snapshot indicates the element selected -in the DevTools Elements panel (if any). +**Description:** Take a text snapshot based on the a11y tree. **Parameters:** -- **filePath** (string) _(optional)_: The absolute path, or a path relative to the current working directory, to save the snapshot to instead of attaching it to the response. -- **verbose** (boolean) _(optional)_: Whether to include all possible information available in the full a11y tree. Default is false. +- **filePath** (string) _(optional)_: Path to save snapshot. If omitted, attaches to response. +- **verbose** (boolean) _(optional)_: Include all info from the a11y tree. Default: false. --- diff --git a/scripts/dump_tools.mjs b/scripts/dump_tools.mjs new file mode 100644 index 000000000..d488e7bd9 --- /dev/null +++ b/scripts/dump_tools.mjs @@ -0,0 +1,24 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import {Client} from '@modelcontextprotocol/sdk/client/index.js'; +import {StdioClientTransport} from '@modelcontextprotocol/sdk/client/stdio.js'; + +const transport = new StdioClientTransport({ + command: 'node', + args: ['./build/src/index.js'], +}); + +const client = new Client( + {name: 'measurer', version: '1.0.0'}, + {capabilities: {}}, +); +await client.connect(transport); + +const toolsList = await client.listTools(); +const jsonString = JSON.stringify(toolsList.tools); +console.log(jsonString); +await client.close(); diff --git a/src/main.ts b/src/main.ts index 4c1fce50c..43dd03757 100644 --- a/src/main.ts +++ b/src/main.ts @@ -72,6 +72,8 @@ const server = new McpServer( name: 'chrome_devtools', title: 'Chrome DevTools MCP server', version: VERSION, + description: + 'All tools operate on the currently selected page. Many tools take a `uid` of an element from a page content snapshot.', }, {capabilities: {logging: {}}}, ); diff --git a/src/tools/ToolDefinition.ts b/src/tools/ToolDefinition.ts index aee562b71..5b582e095 100644 --- a/src/tools/ToolDefinition.ts +++ b/src/tools/ToolDefinition.ts @@ -178,9 +178,7 @@ export const timeoutSchema = { .number() .int() .optional() - .describe( - `Maximum wait time in milliseconds. If set to 0, the default timeout will be used.`, - ) + .describe(`Max wait time in ms. 0 for default.`) .transform(value => { return value && value <= 0 ? undefined : value; }), diff --git a/src/tools/console.ts b/src/tools/console.ts index ace8f6282..51352b045 100644 --- a/src/tools/console.ts +++ b/src/tools/console.ts @@ -39,8 +39,7 @@ const FILTERABLE_MESSAGE_TYPES: [ export const listConsoleMessages = defineTool({ name: 'list_console_messages', - description: - 'List all console messages for the currently selected page since the last navigation.', + description: 'List all console messages since the last navigation.', annotations: { category: ToolCategory.DEBUGGING, readOnlyHint: true, @@ -51,30 +50,22 @@ export const listConsoleMessages = defineTool({ .int() .positive() .optional() - .describe( - 'Maximum number of messages to return. When omitted, returns all requests.', - ), + .describe('Max messages to return. Omit for all.'), pageIdx: zod .number() .int() .min(0) .optional() - .describe( - 'Page number to return (0-based). When omitted, returns the first page.', - ), + .describe('0-based page number. Omit for first page.'), types: zod .array(zod.enum(FILTERABLE_MESSAGE_TYPES)) .optional() - .describe( - 'Filter messages to only return messages of the specified resource types. When omitted or empty, returns all messages.', - ), + .describe('Filter by message type. Omit or empty for all.'), includePreservedMessages: zod .boolean() .default(false) .optional() - .describe( - 'Set to true to return the preserved messages over the last 3 navigations.', - ), + .describe('Set to true for preserved messages over last 3 navigations.'), }, handler: async (request, response) => { response.setIncludeConsoleData(true, { @@ -96,9 +87,7 @@ export const getConsoleMessage = defineTool({ schema: { msgid: zod .number() - .describe( - 'The msgid of a console message on the page from the listed console messages', - ), + .describe('msgid of a console message from listed messages'), }, handler: async (request, response) => { response.attachConsoleMessage(request.params.msgid); diff --git a/src/tools/emulation.ts b/src/tools/emulation.ts index ea0538fd1..294b9807c 100644 --- a/src/tools/emulation.ts +++ b/src/tools/emulation.ts @@ -18,7 +18,7 @@ const throttlingOptions: [string, ...string[]] = [ export const emulate = defineTool({ name: 'emulate', - description: `Emulates various features on the selected page.`, + description: `Emulates various features.`, annotations: { category: ToolCategory.EMULATION, readOnlyHint: false, @@ -28,16 +28,14 @@ export const emulate = defineTool({ .enum(throttlingOptions) .optional() .describe( - `Throttle network. Set to "No emulation" to disable. If omitted, conditions remain unchanged.`, + `Throttle network. "No emulation" to disable. Omit to keep unchanged.`, ), cpuThrottlingRate: zod .number() .min(1) .max(20) .optional() - .describe( - 'Represents the CPU slowdown factor. Set the rate to 1 to disable throttling. If omitted, throttling remains unchanged.', - ), + .describe('CPU slowdown factor. 1 to disable. Omit to keep unchanged.'), geolocation: zod .object({ latitude: zod @@ -53,55 +51,41 @@ export const emulate = defineTool({ }) .nullable() .optional() - .describe( - 'Geolocation to emulate. Set to null to clear the geolocation override.', - ), + .describe('Geolocation to emulate. null to clear override.'), userAgent: zod .string() .nullable() .optional() - .describe( - 'User agent to emulate. Set to null to clear the user agent override.', - ), + .describe('User agent to emulate. null to clear override.'), colorScheme: zod .enum(['dark', 'light', 'auto']) .optional() - .describe( - 'Emulate the dark or the light mode. Set to "auto" to reset to the default.', - ), + .describe('Emulate dark or light mode. "auto" to reset.'), viewport: zod .object({ - width: zod.number().int().min(0).describe('Page width in pixels.'), - height: zod.number().int().min(0).describe('Page height in pixels.'), + width: zod.number().int().min(0).describe('Page width (px).'), + height: zod.number().int().min(0).describe('Page height (px).'), deviceScaleFactor: zod .number() .min(0) .optional() - .describe('Specify device scale factor (can be thought of as dpr).'), + .describe('Device scale factor (dpr).'), isMobile: zod .boolean() .optional() - .describe( - 'Whether the meta viewport tag is taken into account. Defaults to false.', - ), + .describe('Use meta viewport tag. Default: false.'), hasTouch: zod .boolean() .optional() - .describe( - 'Specifies if viewport supports touch events. This should be set to true for mobile devices.', - ), + .describe('Viewport supports touch. true for mobile.'), isLandscape: zod .boolean() .optional() - .describe( - 'Specifies if viewport is in landscape mode. Defaults to false.', - ), + .describe('Landscape mode. Default: false.'), }) .nullable() .optional() - .describe( - 'Viewport to emulate. Set to null to reset to the default viewport.', - ), + .describe('Viewport to emulate. null to reset.'), }, handler: async (request, _response, context) => { await context.emulate(request.params); diff --git a/src/tools/extensions.ts b/src/tools/extensions.ts index 0ab2d43ff..51b83beeb 100644 --- a/src/tools/extensions.ts +++ b/src/tools/extensions.ts @@ -20,9 +20,7 @@ export const installExtension = defineTool({ conditions: [EXTENSIONS_CONDITION], }, schema: { - path: zod - .string() - .describe('Absolute path to the unpacked extension folder.'), + path: zod.string().describe('Absolute path to unpacked extension.'), }, handler: async (request, response, context) => { const {path} = request.params; @@ -40,7 +38,7 @@ export const uninstallExtension = defineTool({ conditions: [EXTENSIONS_CONDITION], }, schema: { - id: zod.string().describe('ID of the extension to uninstall.'), + id: zod.string().describe('ID of extension to uninstall.'), }, handler: async (request, response, context) => { const {id} = request.params; @@ -51,8 +49,7 @@ export const uninstallExtension = defineTool({ export const listExtensions = defineTool({ name: 'list_extensions', - description: - 'Lists all extensions via this server, including their name, ID, version, and enabled status.', + description: 'Lists all extensions with name, ID, version, and status.', annotations: { category: ToolCategory.EXTENSIONS, readOnlyHint: true, @@ -73,7 +70,7 @@ export const reloadExtension = defineTool({ conditions: [EXTENSIONS_CONDITION], }, schema: { - id: zod.string().describe('ID of the extension to reload.'), + id: zod.string().describe('ID of extension to reload.'), }, handler: async (request, response, context) => { const {id} = request.params; diff --git a/src/tools/input.ts b/src/tools/input.ts index c309326e4..fe972d686 100644 --- a/src/tools/input.ts +++ b/src/tools/input.ts @@ -16,12 +16,12 @@ import {defineTool} from './ToolDefinition.js'; const dblClickSchema = zod .boolean() .optional() - .describe('Set to true for double clicks. Default is false.'); + .describe('true for double click. Default: false.'); const includeSnapshotSchema = zod .boolean() .optional() - .describe('Whether to include a snapshot in the response. Default is false.'); + .describe('Include snapshot in response. Default: false.'); function handleActionError(error: unknown, uid: string) { logger('failed to act using a locator', error); @@ -35,17 +35,13 @@ function handleActionError(error: unknown, uid: string) { export const click = defineTool({ name: 'click', - description: `Clicks on the provided element`, + description: `Clicks on an element.`, annotations: { category: ToolCategory.INPUT, readOnlyHint: false, }, schema: { - uid: zod - .string() - .describe( - 'The uid of an element on the page from the page content snapshot', - ), + uid: zod.string().describe('uid of element from snapshot.'), dblClick: dblClickSchema, includeSnapshot: includeSnapshotSchema, }, @@ -76,7 +72,7 @@ export const click = defineTool({ export const clickAt = defineTool({ name: 'click_at', - description: `Clicks at the provided coordinates`, + description: `Clicks at coordinates.`, annotations: { category: ToolCategory.INPUT, readOnlyHint: false, @@ -108,17 +104,13 @@ export const clickAt = defineTool({ export const hover = defineTool({ name: 'hover', - description: `Hover over the provided element`, + description: `Hovers over an element.`, annotations: { category: ToolCategory.INPUT, readOnlyHint: false, }, schema: { - uid: zod - .string() - .describe( - 'The uid of an element on the page from the page content snapshot', - ), + uid: zod.string().describe('uid of element from snapshot.'), includeSnapshot: includeSnapshotSchema, }, handler: async (request, response, context) => { @@ -210,18 +202,14 @@ async function fillFormElement( export const fill = defineTool({ name: 'fill', - description: `Type text into a input, text area or select an option from a element.`, annotations: { category: ToolCategory.INPUT, readOnlyHint: false, }, schema: { - uid: zod - .string() - .describe( - 'The uid of an element on the page from the page content snapshot', - ), - value: zod.string().describe('The value to fill in'), + uid: zod.string().describe('uid of element from snapshot.'), + value: zod.string().describe('Value to fill.'), includeSnapshot: includeSnapshotSchema, }, handler: async (request, response, context) => { @@ -241,14 +229,14 @@ export const fill = defineTool({ export const drag = defineTool({ name: 'drag', - description: `Drag an element onto another element`, + description: `Drags an element onto another element.`, annotations: { category: ToolCategory.INPUT, readOnlyHint: false, }, schema: { - from_uid: zod.string().describe('The uid of the element to drag'), - to_uid: zod.string().describe('The uid of the element to drop into'), + from_uid: zod.string().describe('uid of element to drag.'), + to_uid: zod.string().describe('uid of element to drop into.'), includeSnapshot: includeSnapshotSchema, }, handler: async (request, response, context) => { @@ -273,7 +261,7 @@ export const drag = defineTool({ export const fillForm = defineTool({ name: 'fill_form', - description: `Fill out multiple form elements at once`, + description: `Fills out multiple form elements at once.`, annotations: { category: ToolCategory.INPUT, readOnlyHint: false, @@ -286,7 +274,7 @@ export const fillForm = defineTool({ value: zod.string().describe('Value for the element'), }), ) - .describe('Elements from snapshot to fill out.'), + .describe('Elements from snapshot to fill.'), includeSnapshot: includeSnapshotSchema, }, handler: async (request, response, context) => { @@ -308,7 +296,7 @@ export const fillForm = defineTool({ export const uploadFile = defineTool({ name: 'upload_file', - description: 'Upload a file through a provided element.', + description: 'Uploads a file through a provided element.', annotations: { category: ToolCategory.INPUT, readOnlyHint: false, @@ -316,10 +304,8 @@ export const uploadFile = defineTool({ schema: { uid: zod .string() - .describe( - 'The uid of the file input element or an element that will open file chooser on the page from the page content snapshot', - ), - filePath: zod.string().describe('The local path of the file to upload'), + .describe('uid of file input or element that opens file chooser.'), + filePath: zod.string().describe('Local path of file to upload.'), includeSnapshot: includeSnapshotSchema, }, handler: async (request, response, context) => { @@ -359,7 +345,7 @@ export const uploadFile = defineTool({ export const pressKey = defineTool({ name: 'press_key', - description: `Press a key or key combination. Use this when other input methods like fill() cannot be used (e.g., keyboard shortcuts, navigation keys, or special key combinations).`, + description: `Presses a key or key combination. Use this when other input methods like fill() cannot be used (e.g., keyboard shortcuts, navigation keys, or special key combinations).`, annotations: { category: ToolCategory.INPUT, readOnlyHint: false, @@ -368,7 +354,7 @@ export const pressKey = defineTool({ key: zod .string() .describe( - 'A key or a combination (e.g., "Enter", "Control+A", "Control++", "Control+Shift+R"). Modifiers: Control, Shift, Alt, Meta', + 'Key or combination (e.g., "Enter", "Control+A"). Modifiers: Control, Shift, Alt, Meta.', ), includeSnapshot: includeSnapshotSchema, }, diff --git a/src/tools/memory.ts b/src/tools/memory.ts index 9c13be230..1f919c0fd 100644 --- a/src/tools/memory.ts +++ b/src/tools/memory.ts @@ -11,7 +11,7 @@ import {defineTool} from './ToolDefinition.js'; export const takeMemorySnapshot = defineTool({ name: 'take_memory_snapshot', - description: `Capture a memory heapsnapshot of the currently selected page to memory leak debugging`, + description: `Capture a memory heapsnapshot for memory leak debugging.`, annotations: { category: ToolCategory.PERFORMANCE, readOnlyHint: true, @@ -19,7 +19,7 @@ export const takeMemorySnapshot = defineTool({ schema: { filePath: zod .string() - .describe('A path to a .heapsnapshot file to save the heapsnapshot to.') + .describe('Path to a .heapsnapshot file.') .endsWith('.heapsnapshot'), }, handler: async (request, response, context) => { diff --git a/src/tools/network.ts b/src/tools/network.ts index 9a1d9da7c..fc27cbfb7 100644 --- a/src/tools/network.ts +++ b/src/tools/network.ts @@ -34,7 +34,7 @@ const FILTERABLE_RESOURCE_TYPES: readonly [ResourceType, ...ResourceType[]] = [ export const listNetworkRequests = defineTool({ name: 'list_network_requests', - description: `List all requests for the currently selected page since the last navigation.`, + description: `List all requests since the last navigation.`, annotations: { category: ToolCategory.NETWORK, readOnlyHint: true, @@ -45,30 +45,22 @@ export const listNetworkRequests = defineTool({ .int() .positive() .optional() - .describe( - 'Maximum number of requests to return. When omitted, returns all requests.', - ), + .describe('Max requests to return. Omit for all.'), pageIdx: zod .number() .int() .min(0) .optional() - .describe( - 'Page number to return (0-based). When omitted, returns the first page.', - ), + .describe('0-based page number. Omit for first page.'), resourceTypes: zod .array(zod.enum(FILTERABLE_RESOURCE_TYPES)) .optional() - .describe( - 'Filter requests to only return requests of the specified resource types. When omitted or empty, returns all requests.', - ), + .describe('Filter by resource type. Omit or empty for all.'), includePreservedRequests: zod .boolean() .default(false) .optional() - .describe( - 'Set to true to return the preserved requests over the last 3 navigations.', - ), + .describe('Set to true for preserved requests over last 3 navigations.'), }, handler: async (request, response, context) => { const data = await context.getDevToolsData(); @@ -97,21 +89,15 @@ export const getNetworkRequest = defineTool({ reqid: zod .number() .optional() - .describe( - 'The reqid of the network request. If omitted returns the currently selected request in the DevTools Network panel.', - ), + .describe('reqid of network request. Omit for selected in DevTools.'), requestFilePath: zod .string() .optional() - .describe( - 'The absolute or relative path to save the request body to. If omitted, the body is returned inline.', - ), + .describe('Path to save request body. Omit for inline.'), responseFilePath: zod .string() .optional() - .describe( - 'The absolute or relative path to save the response body to. If omitted, the body is returned inline.', - ), + .describe('Path to save response body. Omit for inline.'), }, handler: async (request, response, context) => { if (request.params.reqid) { diff --git a/src/tools/pages.ts b/src/tools/pages.ts index b63590dfe..730062d92 100644 --- a/src/tools/pages.ts +++ b/src/tools/pages.ts @@ -13,7 +13,7 @@ import {CLOSE_PAGE_ERROR, defineTool, timeoutSchema} from './ToolDefinition.js'; export const listPages = defineTool({ name: 'list_pages', - description: `Get a list of pages open in the browser.`, + description: `Get a list of open pages.`, annotations: { category: ToolCategory.NAVIGATION, readOnlyHint: true, @@ -26,7 +26,7 @@ export const listPages = defineTool({ export const selectPage = defineTool({ name: 'select_page', - description: `Select a page as a context for future tool calls.`, + description: `Select a page as a context for future calls.`, annotations: { category: ToolCategory.NAVIGATION, readOnlyHint: true, @@ -34,13 +34,11 @@ export const selectPage = defineTool({ schema: { pageId: zod .number() - .describe( - `The ID of the page to select. Call ${listPages.name} to get available pages.`, - ), + .describe(`ID of page to select. Use ${listPages.name} to list pages.`), bringToFront: zod .boolean() .optional() - .describe('Whether to focus the page and bring it to the top.'), + .describe('Focus the page and bring it to top.'), }, handler: async (request, response, context) => { const page = context.getPageById(request.params.pageId); @@ -54,15 +52,13 @@ export const selectPage = defineTool({ export const closePage = defineTool({ name: 'close_page', - description: `Closes the page by its index. The last open page cannot be closed.`, + description: `Closes a page by its index. The last open page cannot be closed.`, annotations: { category: ToolCategory.NAVIGATION, readOnlyHint: false, }, schema: { - pageId: zod - .number() - .describe('The ID of the page to close. Call list_pages to list pages.'), + pageId: zod.number().describe('ID of page to close. Use list_pages.'), }, handler: async (request, response, context) => { try { @@ -80,26 +76,22 @@ export const closePage = defineTool({ export const newPage = defineTool({ name: 'new_page', - description: `Creates a new page`, + description: `Creates a new page.`, annotations: { category: ToolCategory.NAVIGATION, readOnlyHint: false, }, schema: { - url: zod.string().describe('URL to load in a new page.'), + url: zod.string().describe('URL for new page.'), background: zod .boolean() .optional() - .describe( - 'Whether to open the page in the background without bringing it to the front. Default is false (foreground).', - ), + .describe('Open in background. Default: false.'), isolatedContext: zod .string() .optional() .describe( - 'If specified, the page is created in an isolated browser context with the given name. ' + - 'Pages in the same browser context share cookies and storage. ' + - 'Pages in different browser contexts are fully isolated.', + 'Name for isolated browser context. Pages in same context share cookies/storage.', ), ...timeoutSchema, }, @@ -124,7 +116,7 @@ export const newPage = defineTool({ export const navigatePage = defineTool({ name: 'navigate_page', - description: `Navigates the currently selected page to a URL.`, + description: `Navigates to a URL.`, annotations: { category: ToolCategory.NAVIGATION, readOnlyHint: false, @@ -133,26 +125,17 @@ export const navigatePage = defineTool({ type: zod .enum(['url', 'back', 'forward', 'reload']) .optional() - .describe( - 'Navigate the page by URL, back or forward in history, or reload.', - ), - url: zod.string().optional().describe('Target URL (only type=url)'), - ignoreCache: zod - .boolean() - .optional() - .describe('Whether to ignore cache on reload.'), + .describe('Navigation type: url, back, forward, or reload.'), + url: zod.string().optional().describe('Target URL (for type=url).'), + ignoreCache: zod.boolean().optional().describe('Ignore cache on reload.'), handleBeforeUnload: zod .enum(['accept', 'decline']) .optional() - .describe( - 'Whether to auto accept or beforeunload dialogs triggered by this navigation. Default is accept.', - ), + .describe('Auto-handle beforeunload dialogs. Default: accept.'), initScript: zod .string() .optional() - .describe( - 'A JavaScript script to be executed on each new document before any other scripts for the next navigation.', - ), + .describe('JS script to run on new documents for next navigation.'), ...timeoutSchema, }, handler: async (request, response, context) => { @@ -273,14 +256,14 @@ export const navigatePage = defineTool({ export const resizePage = defineTool({ name: 'resize_page', - description: `Resizes the selected page's window so that the page has specified dimension`, + description: `Resizes the page's window to a specified dimension.`, annotations: { category: ToolCategory.EMULATION, readOnlyHint: false, }, schema: { - width: zod.number().describe('Page width'), - height: zod.number().describe('Page height'), + width: zod.number().describe('Page width.'), + height: zod.number().describe('Page height.'), }, handler: async (request, response, context) => { const page = context.getSelectedPage(); @@ -312,7 +295,7 @@ export const resizePage = defineTool({ export const handleDialog = defineTool({ name: 'handle_dialog', - description: `If a browser dialog was opened, use this command to handle it`, + description: `Handles an open browser dialog.`, annotations: { category: ToolCategory.INPUT, readOnlyHint: false, @@ -320,11 +303,11 @@ export const handleDialog = defineTool({ schema: { action: zod .enum(['accept', 'dismiss']) - .describe('Whether to dismiss or accept the dialog'), + .describe('Dialog action: accept or dismiss.'), promptText: zod .string() .optional() - .describe('Optional prompt text to enter into the dialog.'), + .describe('Optional prompt text for dialog.'), }, handler: async (request, response, context) => { const dialog = context.getDialog(); @@ -362,7 +345,7 @@ export const handleDialog = defineTool({ export const getTabId = defineTool({ name: 'get_tab_id', - description: `Get the tab ID of the page`, + description: `Gets the tab ID of the page.`, annotations: { category: ToolCategory.NAVIGATION, readOnlyHint: true, @@ -372,7 +355,7 @@ export const getTabId = defineTool({ pageId: zod .number() .describe( - `The ID of the page to get the tab ID for. Call ${listPages.name} to get available pages.`, + `ID of page to get tab ID for. Use ${listPages.name} to list pages.`, ), }, handler: async (request, response, context) => { diff --git a/src/tools/performance.ts b/src/tools/performance.ts index 393d38f15..5cf177721 100644 --- a/src/tools/performance.ts +++ b/src/tools/performance.ts @@ -22,13 +22,11 @@ import {defineTool} from './ToolDefinition.js'; const filePathSchema = zod .string() .optional() - .describe( - 'The absolute file path, or a file path relative to the current working directory, to save the raw trace data. For example, trace.json.gz (compressed) or trace.json (uncompressed).', - ); + .describe('Path to save raw trace data, e.g., trace.json or trace.json.gz.'); export const startTrace = defineTool({ name: 'performance_start_trace', - description: `Starts a performance trace recording on the selected page. This can be used to look for performance problems and insights to improve the performance of the page. It will also report Core Web Vital (CWV) scores for the page.`, + description: `Starts a performance trace recording to find performance problems and insights.`, annotations: { category: ToolCategory.PERFORMANCE, readOnlyHint: false, @@ -37,13 +35,9 @@ export const startTrace = defineTool({ reload: zod .boolean() .describe( - 'Determines if, once tracing has started, the current selected page should be automatically reloaded. Navigate the page to the right URL using the navigate_page tool BEFORE starting the trace if reload or autoStop is set to true.', - ), - autoStop: zod - .boolean() - .describe( - 'Determines if the trace recording should be automatically stopped.', + 'Auto-reload page on trace start. Use navigate_page first if needed.', ), + autoStop: zod.boolean().describe('Auto-stop trace recording.'), filePath: filePathSchema, }, handler: async (request, response, context) => { @@ -114,8 +108,7 @@ export const startTrace = defineTool({ export const stopTrace = defineTool({ name: 'performance_stop_trace', - description: - 'Stops the active performance trace recording on the selected page.', + description: 'Stops the active performance trace recording.', annotations: { category: ToolCategory.PERFORMANCE, readOnlyHint: false, @@ -139,8 +132,7 @@ export const stopTrace = defineTool({ export const analyzeInsight = defineTool({ name: 'performance_analyze_insight', - description: - 'Provides more detailed information on a specific Performance Insight of an insight set that was highlighted in the results of a trace recording.', + description: 'Provides more details on a specific Performance Insight.', annotations: { category: ToolCategory.PERFORMANCE, readOnlyHint: true, @@ -149,12 +141,12 @@ export const analyzeInsight = defineTool({ insightSetId: zod .string() .describe( - 'The id for the specific insight set. Only use the ids given in the "Available insight sets" list.', + 'ID of the insight set from the "Available insight sets" list.', ), insightName: zod .string() .describe( - 'The name of the Insight you want more information on. For example: "DocumentLatency" or "LCPBreakdown"', + 'Name of the insight, e.g., "DocumentLatency" or "LCPBreakdown".', ), }, handler: async (request, response, context) => { diff --git a/src/tools/screencast.ts b/src/tools/screencast.ts index d24d9b0fd..844a0f778 100644 --- a/src/tools/screencast.ts +++ b/src/tools/screencast.ts @@ -21,8 +21,7 @@ async function generateTempFilePath(): Promise { export const startScreencast = defineTool({ name: 'screencast_start', - description: - 'Starts recording a screencast (video) of the selected page in mp4 format.', + description: 'Starts recording a screencast (video) in mp4 format.', annotations: { category: ToolCategory.DEBUGGING, readOnlyHint: false, @@ -32,9 +31,7 @@ export const startScreencast = defineTool({ path: zod .string() .optional() - .describe( - 'Output path. Uses mkdtemp to generate a unique path if not provided.', - ), + .describe('Output path. Uses a temp path if not provided.'), }, handler: async (request, response, context) => { if (context.getScreenRecorder() !== null) { @@ -76,7 +73,7 @@ export const startScreencast = defineTool({ export const stopScreencast = defineTool({ name: 'screencast_stop', - description: 'Stops the active screencast recording on the selected page.', + description: 'Stops the active screencast recording.', annotations: { category: ToolCategory.DEBUGGING, readOnlyHint: false, diff --git a/src/tools/screenshot.ts b/src/tools/screenshot.ts index 4312c02aa..a104502b7 100644 --- a/src/tools/screenshot.ts +++ b/src/tools/screenshot.ts @@ -12,7 +12,7 @@ import {defineTool} from './ToolDefinition.js'; export const screenshot = defineTool({ name: 'take_screenshot', - description: `Take a screenshot of the page or element.`, + description: `Takes a screenshot of the page or an element.`, annotations: { category: ToolCategory.DEBUGGING, // Not read-only due to filePath param. @@ -22,33 +22,27 @@ export const screenshot = defineTool({ format: zod .enum(['png', 'jpeg', 'webp']) .default('png') - .describe('Type of format to save the screenshot as. Default is "png"'), + .describe('Screenshot format. Default: "png".'), quality: zod .number() .min(0) .max(100) .optional() .describe( - 'Compression quality for JPEG and WebP formats (0-100). Higher values mean better quality but larger file sizes. Ignored for PNG format.', + 'JPEG/WebP quality (0-100). Higher is better. Ignored for PNG.', ), uid: zod .string() .optional() - .describe( - 'The uid of an element on the page from the page content snapshot. If omitted takes a pages screenshot.', - ), + .describe('uid of element from snapshot. Omit for page screenshot.'), fullPage: zod .boolean() .optional() - .describe( - 'If set to true takes a screenshot of the full page instead of the currently visible viewport. Incompatible with uid.', - ), + .describe('true for full page screenshot. Incompatible with uid.'), filePath: zod .string() .optional() - .describe( - 'The absolute path, or a path relative to the current working directory, to save the screenshot to instead of attaching it to the response.', - ), + .describe('Path to save screenshot. If omitted, attaches to response.'), }, handler: async (request, response, context) => { if (request.params.uid && request.params.fullPage) { diff --git a/src/tools/script.ts b/src/tools/script.ts index f3bc3c3c5..eab8c9fd3 100644 --- a/src/tools/script.ts +++ b/src/tools/script.ts @@ -12,37 +12,25 @@ import {defineTool} from './ToolDefinition.js'; export const evaluateScript = defineTool({ name: 'evaluate_script', - description: `Evaluate a JavaScript function inside the currently selected page. Returns the response as JSON, -so returned values have to be JSON-serializable.`, + description: `Evaluate a JavaScript function. Returns the response as JSON, so returned values have to be JSON-serializable.`, annotations: { category: ToolCategory.DEBUGGING, readOnlyHint: false, }, schema: { - function: zod.string().describe( - `A JavaScript function declaration to be executed by the tool in the currently selected page. -Example without arguments: \`() => { - return document.title -}\` or \`async () => { - return await fetch("example.com") -}\`. -Example with arguments: \`(el) => { - return el.innerText; -}\` -`, - ), + function: zod + .string() + .describe( + `JS function to run on the page. Ex: \`() => document.title\`, or with args: \`(el) => el.innerText\`.`, + ), args: zod .array( zod.object({ - uid: zod - .string() - .describe( - 'The uid of an element on the page from the page content snapshot', - ), + uid: zod.string().describe('uid of an element from the snapshot.'), }), ) .optional() - .describe(`An optional list of arguments to pass to the function.`), + .describe(`Optional arguments for the function.`), }, handler: async (request, response, context) => { const args: Array> = []; diff --git a/src/tools/slim/tools.ts b/src/tools/slim/tools.ts index 7b83a044b..b7e61e6b4 100644 --- a/src/tools/slim/tools.ts +++ b/src/tools/slim/tools.ts @@ -12,7 +12,7 @@ import {defineTool} from '../ToolDefinition.js'; export const screenshot = defineTool({ name: 'screenshot', - description: `Take a screenshot of the active page.`, + description: `Takes a screenshot.`, annotations: { category: ToolCategory.DEBUGGING, // Not read-only due to filePath param. @@ -32,13 +32,13 @@ export const screenshot = defineTool({ export const navigate = defineTool({ name: 'navigate', - description: `Load URL in the browser`, + description: `Loads a URL.`, annotations: { category: ToolCategory.NAVIGATION, readOnlyHint: false, }, schema: { - url: zod.string().describe('Page URL'), + url: zod.string().describe('URL to navigate to.'), }, handler: async (request, response, context) => { const page = context.getSelectedPage(); @@ -68,15 +68,13 @@ export const navigate = defineTool({ export const evaluate = defineTool({ name: 'evaluate', - description: `Evaluate a JavaScript function on the last loaded page`, + description: `Evaluates a JavaScript function.`, annotations: { category: ToolCategory.DEBUGGING, readOnlyHint: false, }, schema: { - fn: zod - .string() - .describe(`A JavaScript function to be executed on the active page`), + fn: zod.string().describe(`JS function to run on the page.`), }, handler: async (request, response, context) => { const page = context.getSelectedPage(); diff --git a/src/tools/snapshot.ts b/src/tools/snapshot.ts index 143d04093..e9332f950 100644 --- a/src/tools/snapshot.ts +++ b/src/tools/snapshot.ts @@ -11,9 +11,7 @@ import {defineTool, timeoutSchema} from './ToolDefinition.js'; export const takeSnapshot = defineTool({ name: 'take_snapshot', - description: `Take a text snapshot of the currently selected page based on the a11y tree. The snapshot lists page elements along with a unique -identifier (uid). Always use the latest snapshot. Prefer taking a snapshot over taking a screenshot. The snapshot indicates the element selected -in the DevTools Elements panel (if any).`, + description: `Take a text snapshot based on the a11y tree.`, annotations: { category: ToolCategory.DEBUGGING, // Not read-only due to filePath param. @@ -23,15 +21,11 @@ in the DevTools Elements panel (if any).`, verbose: zod .boolean() .optional() - .describe( - 'Whether to include all possible information available in the full a11y tree. Default is false.', - ), + .describe('Include all info from the a11y tree. Default: false.'), filePath: zod .string() .optional() - .describe( - 'The absolute path, or a path relative to the current working directory, to save the snapshot to instead of attaching it to the response.', - ), + .describe('Path to save snapshot. If omitted, attaches to response.'), }, handler: async (request, response) => { response.includeSnapshot({ @@ -43,13 +37,13 @@ in the DevTools Elements panel (if any).`, export const waitFor = defineTool({ name: 'wait_for', - description: `Wait for the specified text to appear on the selected page.`, + description: `Waits for a text to appear.`, annotations: { category: ToolCategory.NAVIGATION, readOnlyHint: true, }, schema: { - text: zod.string().describe('Text to appear on the page'), + text: zod.string().describe('Text to find on the page.'), ...timeoutSchema, }, handler: async (request, response, context) => {