Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions docs/tool-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,20 +347,13 @@

### `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 inside the currently selected page. 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;
}`
Example without arguments: `() => document.title` or `async () => await fetch("example.com")`.
Example with arguments: `(el) => el.innerText`

- **args** (array) _(optional)_: An optional list of arguments to pass to the function.
- **dialogAction** (string) _(optional)_: Handle dialogs while execution. "accept", "dismiss", or string for response of window.prompt. Defaults to accept.
Expand Down Expand Up @@ -653,7 +646,7 @@ in the DevTools Elements panel (if any).
Third-party developer tools can be called via the '[`execute_3p_developer_tool`](#execute_3p_developer_tool)()' MCP tool.
Alternatively, third-party developer tools can be executed by calling '[`evaluate_script`](#evaluate_script)' and adding the
following command to the script:
'window.__dtmcp.executeTool(toolName, params)'
`window.__dtmcp.executeTool(toolName, params)`
This might be helpful when the third-party developer tools return non-serializable values or when composing
third-party developer tools with additional functionality. (requires flag: --categoryExperimentalThirdParty=true)

Expand Down
6 changes: 3 additions & 3 deletions src/bin/chrome-devtools-cli-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,14 @@ export const commands: Commands = {
},
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.',
'Evaluate a JavaScript function inside the currently selected page. Returns the response as JSON, so 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',
'A JavaScript function declaration to be executed by the tool in the currently selected page.\nExample without arguments: `() => document.title` or `async () => await fetch("example.com")`.\nExample with arguments: `(el) => el.innerText`\n',
required: true,
},
args: {
Expand Down Expand Up @@ -653,7 +653,7 @@ export const commands: Commands = {
},
list_3p_developer_tools: {
description:
"Lists all third-party developer tools the page exposes for providing runtime information.\n Third-party developer tools can be called via the 'execute_3p_developer_tool()' MCP tool.\n Alternatively, third-party developer tools can be executed by calling 'evaluate_script' and adding the\n following command to the script:\n 'window.__dtmcp.executeTool(toolName, params)'\n This might be helpful when the third-party developer tools return non-serializable values or when composing\n third-party developer tools with additional functionality. (requires flag: --categoryExperimentalThirdParty=true)",
"Lists all third-party developer tools the page exposes for providing runtime information.\nThird-party developer tools can be called via the 'execute_3p_developer_tool()' MCP tool.\nAlternatively, third-party developer tools can be executed by calling 'evaluate_script' and adding the\nfollowing command to the script:\n`window.__dtmcp.executeTool(toolName, params)`\nThis might be helpful when the third-party developer tools return non-serializable values or when composing\nthird-party developer tools with additional functionality. (requires flag: --categoryExperimentalThirdParty=true)",
category: 'Third-party',
args: {},
},
Expand Down
13 changes: 3 additions & 10 deletions src/tools/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export type Evaluatable = Page | Frame | WebWorker;
export const evaluateScript = defineTool(cliArgs => {
return {
name: 'evaluate_script',
description: `Evaluate a JavaScript function inside the currently selected page${cliArgs?.categoryExtensions ? ' or service worker' : ''}. Returns the response as JSON,
so returned values have to be JSON-serializable.`,
description: `Evaluate a JavaScript function inside the currently selected page${cliArgs?.categoryExtensions ? ' or service worker' : ''}. Returns the response as JSON, so returned values have to be JSON-serializable.`,
annotations: {
category: ToolCategory.DEBUGGING,
readOnlyHint: false,
Expand All @@ -27,14 +26,8 @@ so returned values have to be JSON-serializable.`,
...(cliArgs?.experimentalPageIdRouting ? pageIdSchema : {}),
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;
}\`
Example without arguments: \`() => document.title\` or \`async () => await fetch("example.com")\`.
Example with arguments: \`(el) => el.innerText\`
`,
),
args: zod
Expand Down
12 changes: 6 additions & 6 deletions src/tools/thirdPartyDeveloper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ declare global {
export const listThirdPartyDeveloperTools = definePageTool({
name: 'list_3p_developer_tools',
description: `Lists all third-party developer tools the page exposes for providing runtime information.
Third-party developer tools can be called via the 'execute_3p_developer_tool()' MCP tool.
Alternatively, third-party developer tools can be executed by calling 'evaluate_script' and adding the
following command to the script:
'window.__dtmcp.executeTool(toolName, params)'
This might be helpful when the third-party developer tools return non-serializable values or when composing
third-party developer tools with additional functionality.`,
Third-party developer tools can be called via the 'execute_3p_developer_tool()' MCP tool.
Alternatively, third-party developer tools can be executed by calling 'evaluate_script' and adding the
following command to the script:
\`window.__dtmcp.executeTool(toolName, params)\`
This might be helpful when the third-party developer tools return non-serializable values or when composing
third-party developer tools with additional functionality.`,
annotations: {
category: ToolCategory.THIRD_PARTY,
readOnlyHint: true,
Expand Down
Loading