Skip to content

Commit 0abdf77

Browse files
authored
Merge branch 'main' into support-multiple-chrome-profiles
2 parents e15f5dc + 8f3fcf6 commit 0abdf77

25 files changed

Lines changed: 689 additions & 252 deletions

.github/workflows/convetional-commit.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: 'Conventional Commit'
22

33
on:
4+
merge_group:
45
pull_request_target:
56
types:
67
# Defaults
@@ -19,6 +20,7 @@ jobs:
1920
permissions:
2021
pull-requests: read
2122
steps:
22-
- uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
23+
- if: github.event_name != 'merge_group'
24+
uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
2325
env:
2426
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/presubmit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Check code before submitting
33
permissions: read-all
44

55
on:
6+
merge_group:
67
push:
78
branches:
89
- main

.github/workflows/run-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Compile and run tests
33
permissions: read-all
44

55
on:
6+
merge_group:
67
push:
78
branches:
89
- main

GEMINI.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Instructions
2+
3+
- use `npm run build` to run tsc and test build
4+
- use `npm run test` to run tests, run all tests to verify correctness

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Chrome DevTools MCP will not start the browser instance automatically using this
9191

9292
<details>
9393
<summary>Claude Code</summary>
94-
Use the Claude Code CLI to add the Chrome DevTools MCP server (<a href="https://docs.anthropic.com/en/docs/claude-code/mcp">guide</a>):
94+
Use the Claude Code CLI to add the Chrome DevTools MCP server (<a href="https://code.claude.com/docs/en/mcp">guide</a>):
9595

9696
```bash
9797
claude mcp add chrome-devtools npx chrome-devtools-mcp@latest
@@ -428,6 +428,10 @@ The Chrome DevTools MCP server supports the following configuration option:
428428
Additional arguments for Chrome. Only applies when Chrome is launched by chrome-devtools-mcp.
429429
- **Type:** array
430430

431+
- **`--ignoreDefaultChromeArg`/ `--ignore-default-chrome-arg`**
432+
Explicitly disable default arguments for Chrome. Only applies when Chrome is launched by chrome-devtools-mcp.
433+
- **Type:** array
434+
431435
- **`--categoryEmulation`/ `--category-emulation`**
432436
Set to false to exclude tools related to emulation.
433437
- **Type:** boolean

package-lock.json

Lines changed: 59 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@
5353
"@types/yargs": "^17.0.33",
5454
"@typescript-eslint/eslint-plugin": "^8.43.0",
5555
"@typescript-eslint/parser": "^8.43.0",
56-
"chrome-devtools-frontend": "1.0.1565595",
56+
"chrome-devtools-frontend": "1.0.1566234",
5757
"core-js": "3.47.0",
5858
"debug": "4.4.3",
5959
"eslint": "^9.35.0",
6060
"eslint-import-resolver-typescript": "^4.4.4",
6161
"eslint-plugin-import": "^2.32.0",
6262
"globals": "^17.0.0",
6363
"prettier": "^3.6.2",
64-
"puppeteer": "24.34.0",
64+
"puppeteer": "24.35.0",
6565
"rollup": "4.55.1",
6666
"rollup-plugin-cleanup": "^3.2.1",
6767
"rollup-plugin-license": "^3.6.0",

src/McpResponse.ts

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
getShortDescriptionForRequest,
1818
getStatusFromRequest,
1919
} from './formatters/networkFormatter.js';
20-
import {formatSnapshotNode} from './formatters/snapshotFormatter.js';
20+
import {SnapshotFormatter} from './formatters/SnapshotFormatter.js';
2121
import type {McpContext} from './McpContext.js';
2222
import {DevTools} from './third_party/index.js';
2323
import type {
@@ -57,11 +57,16 @@ export class McpResponse implements Response {
5757
includePreservedMessages?: boolean;
5858
};
5959
#devToolsData?: DevToolsData;
60+
#tabId?: string;
6061

6162
attachDevToolsData(data: DevToolsData): void {
6263
this.#devToolsData = data;
6364
}
6465

66+
setTabId(tabId: string): void {
67+
this.#tabId = tabId;
68+
}
69+
6570
setIncludePages(value: boolean): void {
6671
this.#includePages = value;
6772
}
@@ -181,29 +186,31 @@ export class McpResponse implements Response {
181186
async handle(
182187
toolName: string,
183188
context: McpContext,
184-
): Promise<Array<TextContent | ImageContent>> {
189+
): Promise<{
190+
content: Array<TextContent | ImageContent>;
191+
structuredContent: object;
192+
}> {
185193
if (this.#includePages) {
186194
await context.createPagesSnapshot();
187195
}
188196

189-
let formattedSnapshot: string | undefined;
197+
let snapshot: SnapshotFormatter | string | undefined;
190198
if (this.#snapshotParams) {
191199
await context.createTextSnapshot(
192200
this.#snapshotParams.verbose,
193201
this.#devToolsData,
194202
);
195-
const snapshot = context.getTextSnapshot();
196-
if (snapshot) {
203+
const textSnapshot = context.getTextSnapshot();
204+
if (textSnapshot) {
205+
const formatter = new SnapshotFormatter(textSnapshot);
197206
if (this.#snapshotParams.filePath) {
198207
await context.saveFile(
199-
new TextEncoder().encode(
200-
formatSnapshotNode(snapshot.root, snapshot),
201-
),
208+
new TextEncoder().encode(formatter.toString()),
202209
this.#snapshotParams.filePath,
203210
);
204-
formattedSnapshot = `Saved snapshot to ${this.#snapshotParams.filePath}.`;
211+
snapshot = this.#snapshotParams.filePath;
205212
} else {
206-
formattedSnapshot = formatSnapshotNode(snapshot.root, snapshot);
213+
snapshot = formatter;
207214
}
208215
}
209216
}
@@ -335,7 +342,7 @@ export class McpResponse implements Response {
335342
bodies,
336343
consoleData,
337344
consoleListData,
338-
formattedSnapshot,
345+
snapshot,
339346
});
340347
}
341348

@@ -349,9 +356,9 @@ export class McpResponse implements Response {
349356
};
350357
consoleData: ConsoleMessageData | undefined;
351358
consoleListData: ConsoleMessageData[] | undefined;
352-
formattedSnapshot: string | undefined;
359+
snapshot: SnapshotFormatter | string | undefined;
353360
},
354-
): Array<TextContent | ImageContent> {
361+
): {content: Array<TextContent | ImageContent>; structuredContent: object} {
355362
const response = [`# ${toolName} response`];
356363
for (const line of this.#textResponseLines) {
357364
response.push(line);
@@ -393,9 +400,25 @@ Call ${handleDialog.name} to handle it before continuing.`);
393400
response.push(...parts);
394401
}
395402

396-
if (data.formattedSnapshot) {
397-
response.push('## Latest page snapshot');
398-
response.push(data.formattedSnapshot);
403+
const structuredContent: {
404+
snapshot?: object;
405+
snapshotFilePath?: string;
406+
tabId?: string;
407+
} = {};
408+
409+
if (this.#tabId) {
410+
structuredContent.tabId = this.#tabId;
411+
}
412+
413+
if (data.snapshot) {
414+
if (typeof data.snapshot === 'string') {
415+
response.push(`Saved snapshot to ${data.snapshot}.`);
416+
structuredContent.snapshotFilePath = data.snapshot;
417+
} else {
418+
response.push('## Latest page snapshot');
419+
response.push(data.snapshot.toString());
420+
structuredContent.snapshot = data.snapshot.toJSON();
421+
}
399422
}
400423

401424
response.push(...this.#formatNetworkRequestData(context, data.bodies));
@@ -468,7 +491,10 @@ Call ${handleDialog.name} to handle it before continuing.`);
468491
} as const;
469492
});
470493

471-
return [text, ...images];
494+
return {
495+
content: [text, ...images],
496+
structuredContent,
497+
};
472498
}
473499

474500
#dataWithPagination<T>(data: T[], pagination?: PaginationOptions) {

0 commit comments

Comments
 (0)