You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enables "third-party developer tools" feature. This allows the inspected
web page to expose tools which provide debugging information to Chrome
DevTools for Agents.
Third-party developer tools enable web applications to expose internal
state, component hierarchies, or specific debug data that cannot be
deduced through static analysis. This allows Chrome DevTools for Agents
to provide richer, more actionable context to AI agents during debugging
sessions.
2 additional tools are enabled in Chrome DevTools for Agents for
interacting with third-party developer tools:
`list_3p_developer_tools()` and `execute_3p_developer_tool`.
Code changes in this PR:
- Rename "in-page tools" to "third-party developer tools"
- Unhide
- Make available in CLI
- Add documentation
# Developer Guide: Building third-party developer tools
2
+
3
+
This documentation outlines how to expose custom runtime data and tools from your web application to Chrome DevTools for Agents.
4
+
5
+
## Overview
6
+
7
+
Third-party developer tools enable your web application to expose internal state, component hierarchies, or specific debug data that cannot be deduced through static analysis. This allows Chrome DevTools for Agents to provide richer, more actionable context to AI agents during debugging sessions.
8
+
9
+
## How It Works: Tool Discovery
10
+
11
+
Chrome DevTools for Agents uses an event-based mechanism to discover tools exposed by the page. The process follows these steps:
12
+
13
+
1.**Event Dispatch:** Chrome DevTools for Agents dispatches a `devtoolstooldiscovery` event on the global `window` object.
14
+
2.**Listener:** Your application listens for this event and provides the tool definitions.
15
+
3.**Response:** Your application must call `event.respondWith()` to register a `ToolGroup` object.
16
+
17
+
_Note: Chrome DevTools for Agents requests this list automatically after page navigations (e.g., `new_page`, `navigate_page`) or when explicitly requested via the `list_3p_developer_tools()` MCP tool._
18
+
19
+
## Implementation
20
+
21
+
To expose tools, implement a listener for the `devtoolstooldiscovery` event and provide a `ToolGroup` containing your tool definitions.
22
+
23
+
### Type Definitions
24
+
25
+
Your tools must follow the `ToolDefinition` and `ToolGroup` interfaces:
description: "Provide runtime info directly from the page's JavaScript",
51
+
tools: [
52
+
{
53
+
name: 'add',
54
+
description: 'Calculates the sum of two numbers.',
55
+
inputSchema: {
56
+
type: 'object',
57
+
properties: {
58
+
a: {type: 'number'},
59
+
b: {type: 'number'},
60
+
},
61
+
required: ['a', 'b'],
62
+
},
63
+
execute: async (input: {a:number; b:number}) => {
64
+
returninput.a+input.b;
65
+
},
66
+
},
67
+
],
68
+
});
69
+
},
70
+
);
71
+
```
72
+
73
+
## Tool Invocation
74
+
75
+
Once discovered, MCP clients can execute your tools through Chrome DevTools for Agents using:
76
+
77
+
-**`execute_3p_developer_tool`**: The standard way to invoke a specific registered tool by name with validated parameters.
78
+
-**`evaluate_script`**: Allows for more complex interactions by running a custom script that calls `window.__dtmcp.executeTool()` directly, enabling you to compose functionality.
79
+
80
+
## Important Considerations
81
+
82
+
-**Experimental Status:** This feature is currently experimental. APIs may change, and there are no guarantees regarding stability.
83
+
-**Security & Scope:**
84
+
-**Context:** Third-party developer tools execute only within the context of the page that defines them. They do not persist across origins.
85
+
-**Capabilities:** These tools do not grant expanded privileges; they can only execute code that an attacker would already be able to run on that page.
86
+
-**DOM Elements:** If your tools require DOM elements as inputs or outputs, they are handled via special UIDs referenced in the accessibility tree.
87
+
-**Flags:** The implementation is gated behind the `--categoryExperimentalThirdParty=true` command-line flag.
"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)",
450
+
category: 'Third-party',
451
+
args: {},
452
+
},
428
453
list_console_messages: {
429
454
description:
430
455
'List all console messages for the currently selected page since the last navigation.',
Copy file name to clipboardExpand all lines: src/bin/chrome-devtools-mcp-cli-options.ts
+2-3Lines changed: 2 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -237,12 +237,11 @@ export const cliOptions = {
237
237
describe:
238
238
'Set to true to include tools related to extensions. Note: This feature is currently only supported with a pipe connection. autoConnect, browserUrl, and wsEndpoint are not supported with this feature until 149 will be released.',
239
239
},
240
-
categoryExperimentalInPage: {
240
+
categoryExperimentalThirdParty: {
241
241
type: 'boolean',
242
-
hidden: true,
243
242
default: false,
244
243
describe:
245
-
'Set to true to enable tools exposed by the inspected page itself',
244
+
'Set to true to enable third-party developer tools exposed by the inspected page itself',
0 commit comments