Skip to content

Commit 532add2

Browse files
committed
tool for listing in-page tools
1 parent fb79e82 commit 532add2

3 files changed

Lines changed: 41 additions & 18 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ If you run into any issues, checkout our [troubleshooting guide](./docs/troubles
464464
- [`list_console_messages`](docs/tool-reference.md#list_console_messages)
465465
- [`take_screenshot`](docs/tool-reference.md#take_screenshot)
466466
- [`take_snapshot`](docs/tool-reference.md#take_snapshot)
467+
- **In-page tools** (1 tools)
468+
- [`list_in_page_tools`](docs/tool-reference.md#list_in_page_tools)
467469

468470
<!-- END AUTO GENERATED TOOLS -->
469471

@@ -555,6 +557,11 @@ The Chrome DevTools MCP server supports the following configuration option:
555557
- **Type:** boolean
556558
- **Default:** `true`
557559

560+
- **`--categoryInPageTools`/ `--category-in-page-tools`**
561+
Set to true to enable tools exposed by the inspected page itself
562+
- **Type:** boolean
563+
- **Default:** `false`
564+
558565
- **`--performanceCrux`/ `--performance-crux`**
559566
Set to false to disable sending URLs from performance traces to CrUX API to get field performance data.
560567
- **Type:** boolean

docs/tool-reference.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
- [`list_console_messages`](#list_console_messages)
3838
- [`take_screenshot`](#take_screenshot)
3939
- [`take_snapshot`](#take_snapshot)
40+
- **[In-page tools](#in-page-tools)** (1 tools)
41+
- [`list_in_page_tools`](#list_in_page_tools)
4042

4143
## Input automation
4244

@@ -397,3 +399,15 @@ in the DevTools Elements panel (if any).
397399
- **verbose** (boolean) _(optional)_: Whether to include all possible information available in the full a11y tree. Default is false.
398400

399401
---
402+
403+
## In-page tools
404+
405+
### `list_in_page_tools`
406+
407+
**Description:** Lists all in-page-tools the page exposes for providing runtime information.
408+
In-page-tools are exposed on the page via the 'window.\_\_dtmcp.executeTool(toolName, params)'
409+
function where they can be called by '[`evaluate_script`](#evaluate_script)'.
410+
411+
**Parameters:** None
412+
413+
---

tests/McpResponse.test.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,24 +1022,26 @@ describe('in-page tools', () => {
10221022
// @ts-expect-error Internal API
10231023
const client = page._client();
10241024
const originalSend = client.send.bind(client);
1025-
sinon.stub(client, 'send').callsFake(async (method: string, params?: Record<string, unknown>) => {
1026-
if (method === 'DOMDebugger.getEventListeners') {
1027-
return {
1028-
listeners: [
1029-
{
1030-
type: 'devtoolstooldiscovery',
1031-
useCapture: false,
1032-
passive: false,
1033-
once: false,
1034-
scriptId: '0',
1035-
lineNumber: 0,
1036-
columnNumber: 0,
1037-
},
1038-
],
1039-
};
1040-
}
1041-
return originalSend(method, params);
1042-
});
1025+
sinon
1026+
.stub(client, 'send')
1027+
.callsFake(async (method: string, params?: Record<string, unknown>) => {
1028+
if (method === 'DOMDebugger.getEventListeners') {
1029+
return {
1030+
listeners: [
1031+
{
1032+
type: 'devtoolstooldiscovery',
1033+
useCapture: false,
1034+
passive: false,
1035+
once: false,
1036+
scriptId: '0',
1037+
lineNumber: 0,
1038+
columnNumber: 0,
1039+
},
1040+
],
1041+
};
1042+
}
1043+
return originalSend(method, params);
1044+
});
10431045
}
10441046

10451047
it('lists in-page tools', async t => {

0 commit comments

Comments
 (0)