Skip to content

Chrome DevTools for coding agents

refactor: clean up McpResponse.handle (#2392)

Alex Rudenko348975d808aa
diff --git a/src/McpPage.ts b/src/McpPage.ts
index eb68b397..278e4a40 100644
--- a/src/McpPage.ts
+++ b/src/McpPage.ts
@@ -318,6 +318,9 @@ export class McpPage implements ContextPage {
replaceHtmlElementsWithUids(tool.inputSchema);
}
}
+
+ this.thirdPartyDeveloperTools = toolGroups;
+
return toolGroups;
}
diff --git a/src/McpResponse.ts b/src/McpResponse.ts
index b403ea46..27e1c846 100644
--- a/src/McpResponse.ts
+++ b/src/McpResponse.ts
@@ -437,232 +437,261 @@ export class McpResponse implements Response {
return this.#listWebMcpTools;
}
- async handle(
- toolName: string,
+ async #handleSnapshot(
context: McpContext,
- dataFormat: DataFormat = 'default',
- ): Promise<{
- content: Array<TextContent | ImageContent>;
- structuredContent: object;
- }> {
+ ): Promise<SnapshotFormatter | string | undefined> {
if (this.#includePages) {
await context.createPagesSnapshot();
}
-
- if (this.#includeExtensionServiceWorkers) {
- await context.createExtensionServiceWorkersSnapshot();
+ if (!this.#snapshotParams) {
+ return undefined;
}
-
- let snapshot: SnapshotFormatter | string | undefined;
- if (this.#snapshotParams) {
- if (!this.#page) {
- throw new Error('Response must have a page');
- }
- this.#page.textSnapshot = await TextSnapshot.create(this.#page, {
- verbose: this.#snapshotParams.verbose,
- devtoolsData: this.#devToolsData,
- });
- const textSnapshot = this.#page.textSnapshot;
- if (textSnapshot) {
- const formatter = new SnapshotFormatter(textSnapshot);
- if (this.#snapshotParams.filePath) {
- const result = await context.saveFile(
- new TextEncoder().encode(formatter.toString()),
- this.#snapshotParams.filePath,
- '.txt',
- );
- snapshot = result.filename;
- } else {
- snapshot = formatter;
- }
- }
+ if (!this.#page) {
+ throw new Error('Response must have a page');
}
-
- let detailedNetworkRequest: NetworkFormatter | undefined;
- if (this.#attachedNetworkRequestId) {
- if (!this.#page) {
- throw new Error(`Response must have an McpPage`);
- }
- const request = this.#page.getNetworkRequestById(
- this.#attachedNetworkRequestId,
+ this.#page.textSnapshot = await TextSnapshot.create(this.#page, {
+ verbose: this.#snapshotParams.verbose,
+ devtoolsData: this.#devToolsData,
+ });
+ const formatter = new SnapshotFormatter(this.#page.textSnapshot);
+ if (this.#snapshotParams.filePath) {
+ const result = await context.saveFile(
+ new TextEncoder().encode(formatter.toString()),
+ this.#snapshotParams.filePath,
+ '.txt',
);
- const formatter = await NetworkFormatter.from(request, {
- requestId: this.#attachedNetworkRequestId,
- requestIdResolver: req => this.getNetworkRequestStableId(req),
- fetchData: true,
- requestFilePath: this.#attachedNetworkRequestOptions?.requestFilePath,
- responseFilePath: this.#attachedNetworkRequestOptions?.responseFilePath,
- saveFile: (data, filename, extension) =>
- context.saveFile(data, filename, extension),
- redactNetworkHeaders: this.#redactNetworkHeaders,
- });
- detailedNetworkRequest = formatter;
+ return result.filename;
+ } else {
+ return formatter;
}
+ }
- let detailedConsoleMessage: ConsoleFormatter | IssueFormatter | undefined;
-
- if (this.#attachedConsoleMessageId) {
- if (!this.#page) {
- throw new Error(`Response must have an McpPage`);
- }
-
- const message = this.#page.getConsoleMessageById(
- this.#attachedConsoleMessageId,
- );
- const consoleMessageStableId = this.#attachedConsoleMessageId;
- if ('args' in message || message instanceof UncaughtError) {
- const consoleMessage = message as ConsoleMessage | UncaughtError;
- const devTools = this.#page.devtoolsUniverse;
- detailedConsoleMessage = await ConsoleFormatter.from(consoleMessage, {
- id: consoleMessageStableId,
- fetchDetailedData: true,
- devTools: devTools ?? undefined,
- });
- } else if (message instanceof DevTools.AggregatedIssue) {
- const formatter = new IssueFormatter(message, {
- id: consoleMessageStableId,
- requestIdResolver: this.#page.resolveCdpRequestId.bind(this.#page),
- elementIdResolver: this.#page.textSnapshot?.resolveCdpElementId.bind(
- this.#page.textSnapshot,
- ),
- });
- if (!formatter.isValid()) {
- throw new Error(
- "Can't provide details for the msgid " + consoleMessageStableId,
- );
- }
- detailedConsoleMessage = formatter;
- }
+ async #handleAttachedNetworkRequest(
+ context: McpContext,
+ ): Promise<NetworkFormatter | undefined> {
+ if (!this.#attachedNetworkRequestId) {
+ return undefined;
+ }
+ if (!this.#page) {
+ throw new Error(`Response must have an McpPage`);
}
+ const request = this.#page.getNetworkRequestById(
+ this.#attachedNetworkRequestId,
+ );
+ return await NetworkFormatter.from(request, {
+ requestId: this.#attachedNetworkRequestId,
+ requestIdResolver: req => this.getNetworkRequestStableId(req),
+ fetchData: true,
+ requestFilePath: this.#attachedNetworkRequestOptions?.requestFilePath,
+ responseFilePath: this.#attachedNetworkRequestOptions?.responseFilePath,
+ saveFile: (data, filename, extension) =>
+ context.saveFile(data, filename, extension),
+ redactNetworkHeaders: this.#redactNetworkHeaders,
+ });
+ }
- let extensions: Map<string, Extension> | undefined;
- if (this.#listExtensions) {
- extensions = await context.listExtensions();
+ async #handleAttachedConsoleMessage(): Promise<
+ ConsoleFormatter | IssueFormatter | undefined
+ > {
+ if (!this.#attachedConsoleMessageId) {
+ return undefined;
+ }
+ if (!this.#page) {
+ throw new Error(`Response must have an McpPage`);
}
+ const message = this.#page.getConsoleMessageById(
+ this.#attachedConsoleMessageId,
+ );
+ const consoleMessageStableId = this.#attachedConsoleMessageId;
+ if ('args' in message || message instanceof UncaughtError) {
+ const consoleMessage = message as ConsoleMessage | UncaughtError;
+ return await ConsoleFormatter.from(consoleMessage, {
+ id: consoleMessageStableId,
+ fetchDetailedData: true,
+ devTools: this.#page.devtoolsUniverse,
+ });
+ } else if (message instanceof DevTools.AggregatedIssue) {
+ const formatter = new IssueFormatter(message, {
+ id: consoleMessageStableId,
+ requestIdResolver: this.#page.resolveCdpRequestId.bind(this.#page),
+ elementIdResolver: this.#page.textSnapshot?.resolveCdpElementId.bind(
+ this.#page.textSnapshot,
+ ),
+ });
+ if (!formatter.isValid()) {
+ throw new Error(
+ "Can't provide details for the msgid " + consoleMessageStableId,
+ );
+ }
+ return formatter;
+ } else {
+ return undefined;
+ }
+ }
- let thirdPartyDeveloperTools: ToolGroups = [];
+ async #handleThirdPartyDevelopeTools(): Promise<ToolGroups | undefined> {
if (
this.#args.categoryExperimentalThirdParty &&
this.#listThirdPartyDeveloperTools &&
this.#page
) {
- thirdPartyDeveloperTools = await this.#page.getToolGroups();
- if (thirdPartyDeveloperTools) {
- this.#page.thirdPartyDeveloperTools = thirdPartyDeveloperTools;
- }
+ return await this.#page.getToolGroups();
}
+ return undefined;
+ }
- let webmcpTools: WebMCPTool[] | undefined;
+ async #handleWebMCP(): Promise<WebMCPTool[] | undefined> {
if (
this.#args.categoryExperimentalWebmcp &&
this.#listWebMcpTools &&
this.#page
) {
- webmcpTools = this.#page.getWebMcpTools();
+ return this.#page.getWebMcpTools();
}
+ return undefined;
+ }
- let consoleMessages: Array<ConsoleFormatter | IssueFormatter> | undefined;
- if (this.#consoleDataOptions?.include) {
- let messages;
- let page: McpPage | undefined;
+ async #handleConsoleList(
+ context: McpContext,
+ ): Promise<Array<ConsoleFormatter | IssueFormatter> | undefined> {
+ if (!this.#consoleDataOptions?.include) {
+ return undefined;
+ }
- if (this.#consoleDataOptions.serviceWorkerId) {
- messages = context.getServiceWorkerConsoleData(
- this.#consoleDataOptions.serviceWorkerId,
- );
- } else {
- page = this.#page;
- if (!page) {
- throw new Error(`Response must have an McpPage`);
- }
- messages = page.getConsoleData(
- this.#consoleDataOptions.includePreservedMessages,
- );
- }
+ let messages;
+ let page: McpPage | undefined;
- if (this.#consoleDataOptions.types?.length) {
- const normalizedTypes = new Set(this.#consoleDataOptions.types);
- messages = messages.filter(message => {
- if ('type' in message) {
- return normalizedTypes.has(message.type());
- }
- if (message instanceof DevTools.AggregatedIssue) {
- return normalizedTypes.has('issue');
- }
- return normalizedTypes.has('error');
- });
+ if (this.#consoleDataOptions.serviceWorkerId) {
+ messages = context.getServiceWorkerConsoleData(
+ this.#consoleDataOptions.serviceWorkerId,
+ );
+ } else {
+ page = this.#page;
+ if (!page) {
+ throw new Error(`Response must have an McpPage`);
}
+ messages = page.getConsoleData(
+ this.#consoleDataOptions.includePreservedMessages,
+ );
+ }
- consoleMessages = (
- await Promise.all(
- messages.map(
- async (item): Promise<ConsoleFormatter | IssueFormatter | null> => {
- const consoleMessageStableId =
- this.getConsoleMessageStableId(item);
- if ('args' in item || item instanceof UncaughtError) {
- const consoleMessage = item as ConsoleMessage | UncaughtError;
- return await ConsoleFormatter.from(consoleMessage, {
- id: consoleMessageStableId,
- fetchDetailedData: false,
- devTools: page ? page.devtoolsUniverse : undefined,
- });
- }
- if (item instanceof DevTools.AggregatedIssue) {
- const formatter = new IssueFormatter(item, {
- id: consoleMessageStableId,
- });
- if (!formatter.isValid()) {
- return null;
- }
- return formatter;
+ if (this.#consoleDataOptions.types?.length) {
+ const normalizedTypes = new Set(this.#consoleDataOptions.types);
+ messages = messages.filter(message => {
+ if ('type' in message) {
+ return normalizedTypes.has(message.type());
+ }
+ if (message instanceof DevTools.AggregatedIssue) {
+ return normalizedTypes.has('issue');
+ }
+ return normalizedTypes.has('error');
+ });
+ }
+
+ return (
+ await Promise.all(
+ messages.map(
+ async (item): Promise<ConsoleFormatter | IssueFormatter | null> => {
+ const consoleMessageStableId = this.getConsoleMessageStableId(item);
+ if ('args' in item || item instanceof UncaughtError) {
+ const consoleMessage = item as ConsoleMessage | UncaughtError;
+ return await ConsoleFormatter.from(consoleMessage, {
+ id: consoleMessageStableId,
+ fetchDetailedData: false,
+ devTools: page ? page.devtoolsUniverse : undefined,
+ });
+ }
+ if (item instanceof DevTools.AggregatedIssue) {
+ const formatter = new IssueFormatter(item, {
+ id: consoleMessageStableId,
+ });
+ if (!formatter.isValid()) {
+ return null;
}
- return null;
- },
- ),
- )
- ).filter(item => item !== null);
+ return formatter;
+ }
+ return null;
+ },
+ ),
+ )
+ ).filter(item => item !== null);
+ }
+
+ async #handleNetworkRequestList(
+ context: McpContext,
+ ): Promise<NetworkFormatter[] | undefined> {
+ if (!this.#networkRequestsOptions?.include) {
+ return undefined;
}
+ if (!this.#page) {
+ throw new Error(`Response must have an McpPage`);
+ }
+ let requests = this.#page.getNetworkRequests(
+ this.#networkRequestsOptions?.includePreservedRequests,
+ );
- let networkRequests: NetworkFormatter[] | undefined;
- if (this.#networkRequestsOptions?.include) {
- if (!this.#page) {
- throw new Error(`Response must have an McpPage`);
- }
- let requests = this.#page.getNetworkRequests(
- this.#networkRequestsOptions?.includePreservedRequests,
+ // Apply resource type filtering if specified
+ if (this.#networkRequestsOptions.resourceTypes?.length) {
+ const normalizedTypes = new Set(
+ this.#networkRequestsOptions.resourceTypes,
);
+ requests = requests.filter(request => {
+ const type = request.resourceType();
+ return normalizedTypes.has(type);
+ });
+ }
- // Apply resource type filtering if specified
- if (this.#networkRequestsOptions.resourceTypes?.length) {
- const normalizedTypes = new Set(
- this.#networkRequestsOptions.resourceTypes,
- );
- requests = requests.filter(request => {
- const type = request.resourceType();
- return normalizedTypes.has(type);
- });
- }
+ return await Promise.all(
+ requests.map(request =>
+ NetworkFormatter.from(request, {
+ requestId: this.getNetworkRequestStableId(request),
+ selectedInDevToolsUI:
+ this.getNetworkRequestStableId(request) ===
+ this.#networkRequestsOptions?.networkRequestIdInDevToolsUI,
+ fetchData: false,
+ saveFile: (data, filename, extension) =>
+ context.saveFile(data, filename, extension),
+ redactNetworkHeaders: this.#redactNetworkHeaders,
+ }),
+ ),
+ );
+ }
- if (requests.length) {
- networkRequests = await Promise.all(
- requests.map(request =>
- NetworkFormatter.from(request, {
- requestId: this.getNetworkRequestStableId(request),
- selectedInDevToolsUI:
- this.getNetworkRequestStableId(request) ===
- this.#networkRequestsOptions?.networkRequestIdInDevToolsUI,
- fetchData: false,
- saveFile: (data, filename, extension) =>
- context.saveFile(data, filename, extension),
- redactNetworkHeaders: this.#redactNetworkHeaders,
- }),
- ),
- );
- }
+ async handle(
+ context: McpContext,
+ dataFormat: DataFormat = 'default',
+ ): Promise<{
+ content: Array<TextContent | ImageContent>;
+ structuredContent: object;
+ }> {
+ const [
+ snapshot,
+ detailedNetworkRequest,
+ detailedConsoleMessage,
+ thirdPartyDeveloperTools,
+ webmcpTools,
+ consoleMessages,
+ networkRequests,
+ ] = await Promise.all([
+ this.#handleSnapshot(context),
+ this.#handleAttachedNetworkRequest(context),
+ this.#handleAttachedConsoleMessage(),
+ this.#handleThirdPartyDevelopeTools(),
+ this.#handleWebMCP(),
+ this.#handleConsoleList(context),
+ this.#handleNetworkRequestList(context),
+ ]);
+
+ if (this.#includeExtensionServiceWorkers) {
+ await context.createExtensionServiceWorkersSnapshot();
+ }
+
+ let extensions: Map<string, Extension> | undefined;
+ if (this.#listExtensions) {
+ extensions = await context.listExtensions();
}
return this.format(
- toolName,
context,
{
detailedConsoleMessage,
@@ -693,7 +722,6 @@ export class McpResponse implements Response {
}
async format(
- toolName: string,
context: McpContext,
data: {
detailedConsoleMessage: ConsoleFormatter | IssueFormatter | undefined;
@@ -705,7 +733,7 @@ export class McpResponse implements Response {
traceInsight?: TraceInsightData;
extensions?: Map<string, Extension>;
lighthouseResult?: LighthouseData;
- thirdPartyDeveloperTools: ToolGroups;
+ thirdPartyDeveloperTools?: ToolGroups;
webmcpTools?: WebMCPTool[];
errorMessage?: string;
},
@@ -1229,11 +1257,11 @@ Call ${handleDialog.name} to handle it before continuing.`);
}
}
- if (data.thirdPartyDeveloperTools.length) {
- structuredContent.thirdPartyDeveloperTools =
- data.thirdPartyDeveloperTools;
+ const thirdPartyDeveloperTools = data.thirdPartyDeveloperTools;
+ if (thirdPartyDeveloperTools?.length) {
+ structuredContent.thirdPartyDeveloperTools = thirdPartyDeveloperTools;
response.push('## Third-party developer tools');
- for (const toolGroup of data.thirdPartyDeveloperTools) {
+ for (const toolGroup of thirdPartyDeveloperTools) {
response.push(`${toolGroup.name}: ${toolGroup.description}`);
response.push('Available tools:');
const toolDefinitionsMessage = toolGroup.tools
diff --git a/src/SlimMcpResponse.ts b/src/SlimMcpResponse.ts
index 57198dd3..3f954fb3 100644
--- a/src/SlimMcpResponse.ts
+++ b/src/SlimMcpResponse.ts
@@ -13,10 +13,7 @@ import type {McpContext} from './McpContext.js';
import {McpResponse} from './McpResponse.js';
export class SlimMcpResponse extends McpResponse {
- override async handle(
- _toolName: string,
- _context: McpContext,
- ): Promise<{
+ override async handle(_context: McpContext): Promise<{
content: Array<TextContent | ImageContent>;
structuredContent: object;
}> {
diff --git a/src/ToolHandler.ts b/src/ToolHandler.ts
index efa5882e..bf4cffa6 100644
--- a/src/ToolHandler.ts
+++ b/src/ToolHandler.ts
@@ -271,7 +271,6 @@ export class ToolHandler {
}
const {content, structuredContent} = await response.handle(
- this.tool.name,
context,
dataFormat,
);
diff --git a/tests/McpContext.test.ts b/tests/McpContext.test.ts
index 283b09e5..009076a1 100644
--- a/tests/McpContext.test.ts
+++ b/tests/McpContext.test.ts
@@ -297,7 +297,7 @@ describe('McpContext', () => {
.returns([mockRequest]);
response.setIncludeNetworkRequests(true);
- const result = await response.handle('test', context);
+ const result = await response.handle(context);
t.assert.snapshot(JSON.stringify(result.structuredContent, null, 2));
});
});
@@ -314,7 +314,7 @@ describe('McpContext', () => {
.returns(mockRequest);
response.attachNetworkRequest(456);
- const result = await response.handle('test', context);
+ const result = await response.handle(context);
t.assert.snapshot(JSON.stringify(result.structuredContent, null, 2));
});
@@ -365,7 +365,7 @@ describe('McpContext', () => {
requestFilePath: reqFilePath,
responseFilePath: resFilePath,
});
- const result = await response.handle('test', context);
+ const result = await response.handle(context);
t.assert.snapshot(JSON.stringify(result.structuredContent, null, 2));
diff --git a/tests/McpResponse.test.js.snapshot b/tests/McpResponse.test.js.snapshot
index 69a7ec9d..71b69648 100644
--- a/tests/McpResponse.test.js.snapshot
+++ b/tests/McpResponse.test.js.snapshot
@@ -1173,7 +1173,8 @@ exports[`McpResponse network request filtering > shows all requests when no filt
`;
exports[`McpResponse network request filtering > shows no requests when filter matches nothing 1`] = `
-
+## Network requests
+No requests found.
`;
exports[`McpResponse network request filtering > shows no requests when filter matches nothing 2`] = `
diff --git a/tests/McpResponse.test.ts b/tests/McpResponse.test.ts
index af28e18f..ee010874 100644
--- a/tests/McpResponse.test.ts
+++ b/tests/McpResponse.test.ts
@@ -47,10 +47,7 @@ describe('McpResponse', () => {
it('list pages', async t => {
await withMcpContext(async (response, context) => {
response.setIncludePages(true);
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
assert.equal(content[0].type, 'text');
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -61,7 +58,7 @@ describe('McpResponse', () => {
it('includes a reconnect notice only when set', async () => {
await withMcpContext(async (response, context) => {
- const before = await response.handle('test', context);
+ const before = await response.handle(context);
assert.ok(
!JSON.stringify(before.content).includes('Page ids have changed'),
'no reconnect notice by default',
@@ -72,7 +69,7 @@ describe('McpResponse', () => {
);
response.setReconnectNotice();
- const after = await response.handle('test', context);
+ const after = await response.handle(context);
assert.ok(
JSON.stringify(after.content).includes('Page ids have changed'),
'reconnect notice is included once set',
@@ -89,10 +86,7 @@ describe('McpResponse', () => {
await withMcpContext(async (response, context) => {
response.appendResponseLine('Testing 1');
response.appendResponseLine('Testing 2');
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
assert.equal(content[0].type, 'text');
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -105,10 +99,7 @@ describe('McpResponse', () => {
await withMcpContext(async (response, context) => {
const page = context.getSelectedMcpPage().pptrPage;
page.accessibility.snapshot = async () => null;
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
@@ -128,10 +119,7 @@ describe('McpResponse', () => {
);
await page.focus('button');
response.includeSnapshot();
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
@@ -151,10 +139,7 @@ describe('McpResponse', () => {
);
await page.focus('input');
response.includeSnapshot();
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
assert.equal(content[0].type, 'text');
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -170,10 +155,7 @@ describe('McpResponse', () => {
response.includeSnapshot({
verbose: true,
});
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
assert.equal(content[0].type, 'text');
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(JSON.stringify(structuredContent, null, 2));
@@ -190,10 +172,7 @@ describe('McpResponse', () => {
verbose: true,
filePath,
});
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
assert.equal(content[0].type, 'text');
t.assert.snapshot(stabilizeResponseOutput(getTextContent(content[0])));
t.assert.snapshot(
@@ -222,7 +201,7 @@ describe('McpResponse', () => {
`);
response.includeSnapshot();
// First snapshot
- const res1 = await response.handle('test', context);
+ const res1 = await response.handle(context);
const text1 = getTextContent(res1.content[0]);
const btn1IdMatch = text1.match(/uid=(\S+) .*Button 1/);
const span1IdMatch = text1.match(/uid=(\S+) .*Span 1/);
@@ -241,7 +220,7 @@ describe('McpResponse', () => {
});
// Second snapshot
- const res2 = await response.handle('test', context);
+ const res2 = await response.handle(context);
const text2 = getTextContent(res2.content[0]);
const btn1IdMatch2 = text2.match(/uid=(\S+) .*Button 1/);
@@ -292,7 +271,7 @@ describe('McpResponse', () => {
await page.goto(server.getRoute('/page.html'));
response.includeSnapshot();
- const res1 = await response.handle('test', context);
+ const res1 = await response.handle(context);
const text1 = getTextContent(res1.content[0]);
const btn1IdMatch = text1.match(/uid=(\S+) .*Button 1/);
assert.ok(btn1IdMatch, 'Button 1 ID not found in first snapshot');
@@ -301,7 +280,7 @@ describe('McpResponse', () => {
// Navigate to the same page again (or meaningful navigation)
await page.goto(server.getRoute('/page.html'));
- const res2 = await response.handle('test', context);
+ const res2 = await response.handle(context);
const text2 = getTextContent(res2.content[0]);
const btn1IdMatch2 = text2.match(/uid=(\S+) .*Button 1/);
assert.ok(btn1IdMatch2, 'Button 1 ID not found in second snapshot');
@@ -321,10 +300,7 @@ describe('McpResponse', () => {
await context
.getSelectedMcpPage()
.emulate({networkConditions: 'Slow 3G'});
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
assert.equal(content[0].type, 'text');
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -335,10 +311,7 @@ describe('McpResponse', () => {
it('does not include throttling setting when it is null', async t => {
await withMcpContext(async (response, context) => {
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
await context.getSelectedMcpPage().emulate({});
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -349,10 +322,7 @@ describe('McpResponse', () => {
it('adds image when image is attached', async t => {
await withMcpContext(async (response, context) => {
response.attachImage({data: 'imageBase64', mimeType: 'image/png'});
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
assert.equal(content[1].type, 'image');
assert.strictEqual(getImageContent(content[1]).data, 'imageBase64');
@@ -366,10 +336,7 @@ describe('McpResponse', () => {
it('adds cpu throttling setting when it is over 1', async t => {
await withMcpContext(async (response, context) => {
await context.getSelectedMcpPage().emulate({cpuThrottlingRate: 4});
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
@@ -380,10 +347,7 @@ describe('McpResponse', () => {
it('does not include cpu throttling setting when it is 1', async t => {
await withMcpContext(async (response, context) => {
await context.getSelectedMcpPage().emulate({cpuThrottlingRate: 1});
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
@@ -396,10 +360,7 @@ describe('McpResponse', () => {
await context.getSelectedMcpPage().emulate({
viewport: {width: 400, height: 400, deviceScaleFactor: 1},
});
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
@@ -410,10 +371,7 @@ describe('McpResponse', () => {
it('adds userAgent emulation setting when it is set', async t => {
await withMcpContext(async (response, context) => {
await context.getSelectedMcpPage().emulate({userAgent: 'MyUA'});
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
@@ -424,10 +382,7 @@ describe('McpResponse', () => {
it('adds color scheme emulation setting when it is set', async t => {
await withMcpContext(async (response, context) => {
await context.getSelectedMcpPage().emulate({colorScheme: 'dark'});
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
@@ -447,10 +402,7 @@ describe('McpResponse', () => {
prompt('message', 'default');
});
await dialogPromise;
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
await page.getDialog()?.dismiss();
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -471,10 +423,7 @@ describe('McpResponse', () => {
alert('message');
});
await dialogPromise;
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
await page.getDialog()?.dismiss();
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -489,10 +438,7 @@ describe('McpResponse', () => {
context.getSelectedMcpPage().getNetworkRequests = () => {
return [getMockRequest({stableId: 1}), getMockRequest({stableId: 2})];
};
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
@@ -506,10 +452,7 @@ describe('McpResponse', () => {
context.getSelectedMcpPage().getNetworkRequests = () => {
return [getMockRequest()];
};
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
@@ -543,10 +486,7 @@ describe('McpResponse', () => {
};
response.attachNetworkRequest(1);
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -566,10 +506,7 @@ describe('McpResponse', () => {
return request;
};
response.attachNetworkRequest(1);
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
@@ -590,10 +527,7 @@ describe('McpResponse', () => {
console.log('Hello from the test');
});
await consoleMessagePromise;
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
assert.ok(getTextContent(content[0]));
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -605,10 +539,7 @@ describe('McpResponse', () => {
it('adds a message when no console messages exist', async t => {
await withMcpContext(async (response, context) => {
response.setIncludeConsoleData(true);
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
assert.ok(getTextContent(content[0]));
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -630,10 +561,7 @@ describe('McpResponse', () => {
return [mockAggregatedIssue];
};
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
const text = getTextContent(content[0]);
assert.ok(text.includes('<no console messages found>'));
t.assert.snapshot(
@@ -656,7 +584,7 @@ describe('McpResponse', () => {
};
try {
- await response.handle('test', context);
+ await response.handle(context);
} catch (e) {
assert.ok(e.message.includes("Can't provide details for the msgid 1"));
}
@@ -678,10 +606,7 @@ describe('McpResponse network request filtering', () => {
getMockRequest({resourceType: 'document'}),
];
};
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
@@ -701,10 +626,7 @@ describe('McpResponse network request filtering', () => {
getMockRequest({resourceType: 'stylesheet'}),
];
};
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
@@ -724,10 +646,7 @@ describe('McpResponse network request filtering', () => {
getMockRequest({resourceType: 'stylesheet'}),
];
};
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
@@ -747,10 +666,7 @@ describe('McpResponse network request filtering', () => {
getMockRequest({resourceType: 'font'}),
];
};
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -773,10 +689,7 @@ describe('McpResponse network request filtering', () => {
getMockRequest({resourceType: 'font'}),
];
};
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
@@ -791,10 +704,7 @@ describe('McpResponse network pagination', () => {
const requests = Array.from({length: 5}, () => getMockRequest());
context.getSelectedMcpPage().getNetworkRequests = () => requests;
response.setIncludeNetworkRequests(true);
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
const text = getTextContent(content[0]);
assert.ok(text.includes('Showing 1-5 of 5 (Page 1 of 1).'));
assert.ok(!text.includes('Next page:'));
@@ -814,10 +724,7 @@ describe('McpResponse network pagination', () => {
return requests;
};
response.setIncludeNetworkRequests(true, {pageSize: 10});
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
const text = getTextContent(content[0]);
assert.ok(text.includes('Showing 1-10 of 30 (Page 1 of 3).'));
assert.ok(text.includes('Next page: 1'));
@@ -838,10 +745,7 @@ describe('McpResponse network pagination', () => {
pageSize: 10,
pageIdx: 1,
});
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
const text = getTextContent(content[0]);
assert.ok(text.includes('Showing 11-20 of 25 (Page 2 of 3).'));
assert.ok(text.includes('Next page: 2'));
@@ -861,7 +765,7 @@ describe('McpResponse network pagination', () => {
// pageIdx 0 is a valid page, not "no pagination" — it must apply the
// default page size like any other page.
response.setIncludeNetworkRequests(true, {pageIdx: 0});
- const {content} = await response.handle('test', context);
+ const {content} = await response.handle(context);
const text = getTextContent(content[0]);
assert.ok(text.includes('Showing 1-20 of 30 (Page 1 of 2).'));
assert.ok(text.includes('Next page: 1'));
@@ -877,10 +781,7 @@ describe('McpResponse network pagination', () => {
pageSize: 2,
pageIdx: 10, // Invalid page number
});
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
const text = getTextContent(content[0]);
assert.ok(
text.includes('Invalid page number provided. Showing first page.'),
@@ -902,10 +803,7 @@ describe('McpResponse network pagination', () => {
await withMcpContext(async (response, context) => {
response.attachTraceSummary(result);
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
const typedStructuredContent = structuredContent as {
@@ -936,10 +834,7 @@ describe('McpResponse network pagination', () => {
'NAVIGATION_0',
'LCPBreakdown' as InsightName,
);
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -965,10 +860,7 @@ describe('McpResponse network pagination', () => {
'BAD_ID',
'LCPBreakdown' as InsightName,
);
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -988,7 +880,7 @@ describe('extensions', () => {
await withMcpContext(async (response, context) => {
response.setListExtensions();
// Empty state testing
- const emptyResult = await response.handle('test', context);
+ const emptyResult = await response.handle(context);
const emptyText = getTextContent(emptyResult.content[0]);
assert.ok(
emptyText.includes('No extensions installed.'),
@@ -1023,10 +915,7 @@ describe('extensions', () => {
]),
);
response.setListExtensions();
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(JSON.stringify(structuredContent, null, 2));
@@ -1061,10 +950,7 @@ describe('lighthouse', () => {
};
response.attachLighthouseResult(lighthouseResult);
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
const text = getTextContent(content[0]);
assert.ok(text.includes('### Reports'));
@@ -1130,10 +1016,7 @@ describe('third-party developer tools', () => {
},
]);
response.setListThirdPartyDeveloperTools();
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
const responseText = getTextContent(content[0]);
t.assert.snapshot(responseText);
assert.ok(
@@ -1186,7 +1069,7 @@ describe('third-party developer tools', () => {
await handlerAction(response, context);
- const {content} = await response.handle(toolName, context);
+ const {content} = await response.handle(context);
const responseText = getTextContent(content[0]);
assert.ok(
responseText.includes('3pDeveloperTool'),
@@ -1258,7 +1141,6 @@ describe('webmcp', () => {
response: McpResponse,
context: McpContext,
) => Promise<void>,
- toolName: string,
) {
await withMcpContext(
async (response, context) => {
@@ -1279,10 +1161,7 @@ describe('webmcp', () => {
);
await promise;
- const {content, structuredContent} = await response.handle(
- toolName,
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
assert.ok(getTextContent(content[0]));
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -1305,7 +1184,6 @@ describe('webmcp', () => {
async (response, context) => {
await listPages().handler({params: {}}, response, context);
},
- 'list_pages',
);
});
@@ -1317,7 +1195,6 @@ describe('webmcp', () => {
const pageId = context.getSelectedMcpPage().id;
await selectPage.handler({params: {pageId}}, response, context);
},
- 'select_page',
);
});
@@ -1335,7 +1212,6 @@ describe('webmcp', () => {
context,
);
},
- 'navigate_page',
);
});
@@ -1343,10 +1219,7 @@ describe('webmcp', () => {
await withMcpContext(
async (response, context) => {
response.setListWebMcpTools();
- const {content, structuredContent} = await response.handle(
- 'test',
- context,
- );
+ const {content, structuredContent} = await response.handle(context);
assert.ok(getTextContent(content[0]));
t.assert.snapshot(getTextContent(content[0]));
t.assert.snapshot(
@@ -1376,7 +1249,6 @@ describe('webmcp', () => {
context,
);
},
- 'navigate_page',
);
});
});
diff --git a/tests/shutdown.test.ts b/tests/shutdown.test.ts
index f492f994..23a22fbc 100644
--- a/tests/shutdown.test.ts
+++ b/tests/shutdown.test.ts
@@ -17,7 +17,7 @@ type Server = ChildProcessByStdio<Writable, Readable, Readable>;
// Once shutdown is signalled, the server should be fully gone within this
// budget. The actual fast path is well under 500ms; the budget is set to be
// generous against CI noise without being so loose that it would hide a hang.
-const SHUTDOWN_BUDGET_MS = 3000;
+const SHUTDOWN_BUDGET_MS = 10000;
// Outer test timeout. If exit doesn't happen within this, treat as a hang
// (the bug we're guarding against) and SIGKILL the subprocess.
const EXIT_TIMEOUT_MS = 15000;
diff --git a/tests/tools/console.test.ts b/tests/tools/console.test.ts
index 3a3ee964..f8ed73a5 100644
--- a/tests/tools/console.test.ts
+++ b/tests/tools/console.test.ts
@@ -108,7 +108,7 @@ describe('console', () => {
context,
);
- const formattedResponse = await response2.handle('test', context);
+ const formattedResponse = await response2.handle(context);
const textContent = getTextContent(formattedResponse.content[0]);
const sanitizedText = textContent.replaceAll(
@@ -165,7 +165,7 @@ describe('console', () => {
response,
context,
);
- const formattedResponse = await response.handle('test', context);
+ const formattedResponse = await response.handle(context);
const textContent = getTextContent(formattedResponse.content[0]);
assert.ok(textContent.includes('msgid=1 [error] This is an error'));
});
@@ -182,7 +182,7 @@ describe('console', () => {
response,
context,
);
- const formattedResponse = await response.handle('test', context);
+ const formattedResponse = await response.handle(context);
const textContent = getTextContent(formattedResponse.content[0]);
t.assert.snapshot(textContent);
});
@@ -197,7 +197,7 @@ describe('console', () => {
response,
context,
);
- const formattedResponse = await response.handle('test', context);
+ const formattedResponse = await response.handle(context);
const textContent = getTextContent(formattedResponse.content[0]);
assert.ok(textContent.includes('msgid=1 [error] Uncaught (0 args)'));
});
@@ -221,7 +221,7 @@ describe('console', () => {
response,
context,
);
- const formattedResponse = await response.handle('test', context);
+ const formattedResponse = await response.handle(context);
const textContent = getTextContent(formattedResponse.content[0]);
assert.ok(
textContent.includes(
@@ -251,7 +251,7 @@ describe('console', () => {
context,
);
{
- const formattedResponse = await response.handle('test', context);
+ const formattedResponse = await response.handle(context);
const textContent = getTextContent(formattedResponse.content[0]);
assert.ok(
textContent.includes(
@@ -271,7 +271,7 @@ describe('console', () => {
);
await anotherIssuePromise;
{
- const formattedResponse = await response.handle('test', context);
+ const formattedResponse = await response.handle(context);
const textContent = getTextContent(formattedResponse.content[0]);
assert.ok(
textContent.includes(
@@ -304,10 +304,7 @@ describe('console', () => {
context,
);
- const result = await response.handle(
- 'list_console_messages',
- context,
- );
+ const result = await response.handle(context);
t.assert.snapshot(JSON.stringify(result));
await dialog.dismiss();
});
@@ -335,7 +332,7 @@ describe('console', () => {
response,
context,
);
- const formattedResponse = await response.handle('test', context);
+ const formattedResponse = await response.handle(context);
const textContent = getTextContent(formattedResponse.content[0]);
assert.ok(
textContent.includes('msgid=1 [error] This is an error'),
@@ -370,7 +367,7 @@ describe('console', () => {
response2,
context,
);
- const formattedResponse = await response2.handle('test', context);
+ const formattedResponse = await response2.handle(context);
t.assert.snapshot(getTextContent(formattedResponse.content[0]));
});
});
@@ -426,7 +423,7 @@ describe('console', () => {
response2,
context,
);
- const formattedResponse = await response2.handle('test', context);
+ const formattedResponse = await response2.handle(context);
const rawText = getTextContent(formattedResponse.content[0]);
const sanitizedText = rawText
.replaceAll(/ID: \d+/g, 'ID: <ID>')
@@ -459,7 +456,7 @@ describe('console', () => {
response,
context,
);
- const formattedResponse = await response.handle('test', context);
+ const formattedResponse = await response.handle(context);
const rawText = getTextContent(formattedResponse.content[0]);
t.assert.snapshot(rawText);
@@ -488,7 +485,7 @@ describe('console', () => {
response,
context,
);
- const formattedResponse = await response.handle('test', context);
+ const formattedResponse = await response.handle(context);
const rawText = getTextContent(formattedResponse.content[0]);
t.assert.snapshot(rawText);
@@ -517,7 +514,7 @@ describe('console', () => {
response,
context,
);
- const formattedResponse = await response.handle('test', context);
+ const formattedResponse = await response.handle(context);
const rawText = getTextContent(formattedResponse.content[0]);
t.assert.snapshot(rawText);
@@ -546,7 +543,7 @@ describe('console', () => {
response,
context,
);
- const formattedResponse = await response.handle('test', context);
+ const formattedResponse = await response.handle(context);
const rawText = getTextContent(formattedResponse.content[0]);
t.assert.snapshot(rawText);
@@ -575,7 +572,7 @@ describe('console', () => {
response,
context,
);
- const formattedResponse = await response.handle('test', context);
+ const formattedResponse = await response.handle(context);
const rawText = getTextContent(formattedResponse.content[0]);
t.assert.snapshot(rawText);
@@ -618,7 +615,7 @@ describe('console', () => {
response,
context,
);
- const formattedResponse = await response.handle('test', context);
+ const formattedResponse = await response.handle(context);
const rawText = getTextContent(formattedResponse.content[0]);
t.assert.snapshot(rawText);
@@ -652,7 +649,7 @@ describe('console', () => {
context,
);
- const result = await response.handle('get_console_message', context);
+ const result = await response.handle(context);
t.assert.snapshot(
JSON.stringify(
stabilizeStructuredContent(result.structuredContent),
diff --git a/tests/tools/extensions.test.ts b/tests/tools/extensions.test.ts
index 11583751..e98ea494 100644
--- a/tests/tools/extensions.test.ts
+++ b/tests/tools/extensions.test.ts
@@ -206,7 +206,7 @@ describe('extension', () => {
context,
);
- const result = await response.handle('list_console_messages', context);
+ const result = await response.handle(context);
const consoleOutput = getTextContent(result.content[0]);
assert.ok(
consoleOutput.includes('from content script!'),
diff --git a/tests/tools/input.test.ts b/tests/tools/input.test.ts
index bac71ccc..eaa8445b 100644
--- a/tests/tools/input.test.ts
+++ b/tests/tools/input.test.ts
@@ -155,7 +155,7 @@ describe('input', () => {
response,
context,
);
- const result = await response.handle('click', context);
+ const result = await response.handle(context);
const textContent = getTextContent(result.content[0]);
const expectedUrl = server.getRoute('/after-click');
assert.ok(
@@ -184,7 +184,7 @@ describe('input', () => {
response,
context,
);
- const result = await response.handle('click', context);
+ const result = await response.handle(context);
const textContent = getTextContent(result.content[0]);
assert.ok(
!textContent.includes('Page navigated to '),
diff --git a/tests/tools/memory.test.ts b/tests/tools/memory.test.ts
index 23ac1da5..4da915ad 100644
--- a/tests/tools/memory.test.ts
+++ b/tests/tools/memory.test.ts
@@ -68,10 +68,7 @@ describe('memory', () => {
);
// Call handle to trigger formatting (similar to network tests)
- const responseData = await response.handle(
- getHeapSnapshotSummary.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -95,10 +92,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- getHeapSnapshotDetails.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -120,10 +114,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- getHeapSnapshotDetails.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -145,10 +136,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- getHeapSnapshotDetails.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -177,10 +165,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- getHeapSnapshotDetails.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -206,10 +191,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- getHeapSnapshotClassNodes.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
@@ -243,10 +225,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- getHeapSnapshotClassNodes.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
@@ -291,10 +270,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- getHeapSnapshotRetainers.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -318,10 +294,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- getHeapSnapshotObjectDetails.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -391,10 +364,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- getHeapSnapshotRetainingPaths.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -416,10 +386,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- getHeapSnapshotRetainingPaths.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -447,10 +414,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- getHeapSnapshotEdges.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -472,10 +436,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- getHeapSnapshotEdges.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -499,10 +460,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- getHeapSnapshotDominators.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -530,10 +488,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- compareHeapSnapshots.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -559,10 +514,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- compareHeapSnapshots.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -594,10 +546,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- compareHeapSnapshots.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -690,10 +639,7 @@ describe('memory', () => {
context,
);
- const responseData = await response.handle(
- getHeapSnapshotDuplicateStrings.name,
- context,
- );
+ const responseData = await response.handle(context);
const output = responseData.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
diff --git a/tests/tools/network.test.ts b/tests/tools/network.test.ts
index 0e6096f6..5d98791f 100644
--- a/tests/tools/network.test.ts
+++ b/tests/tools/network.test.ts
@@ -54,7 +54,7 @@ describe('network', () => {
response,
context,
);
- const responseData = await response.handle('list_request', context);
+ const responseData = await response.handle(context);
t.assert.snapshot(
stabilizeResponseOutput(getTextContent(responseData.content[0])),
);
@@ -82,7 +82,7 @@ describe('network', () => {
response,
context,
);
- const responseData = await response.handle('list_request', context);
+ const responseData = await response.handle(context);
t.assert.snapshot(
stabilizeResponseOutput(getTextContent(responseData.content[0])),
);
@@ -125,7 +125,7 @@ describe('network', () => {
response,
context,
);
- const responseData = await response.handle('list_request', context);
+ const responseData = await response.handle(context);
t.assert.snapshot(
stabilizeResponseOutput(getTextContent(responseData.content[0])),
);
@@ -179,7 +179,7 @@ describe('network', () => {
response,
context,
);
- const responseData = await response.handle('get_request', context);
+ const responseData = await response.handle(context);
t.assert.snapshot(
stabilizeResponseOutput(getTextContent(responseData.content[0])),
diff --git a/tests/tools/pages.test.ts b/tests/tools/pages.test.ts
index cde1a724..2dc01125 100644
--- a/tests/tools/pages.test.ts
+++ b/tests/tools/pages.test.ts
@@ -82,7 +82,7 @@ describe('pages', () => {
} as ParsedArguments);
await listPageDef.handler({params: {}}, response, context);
- const result = await response.handle(listPageDef.name, context);
+ const result = await response.handle(context);
const textContent = result.content.find(c => c.type === 'text') as {
type: 'text';
text: string;
@@ -123,7 +123,7 @@ describe('pages', () => {
} as ParsedArguments);
await listPageDef.handler({params: {}}, response, context);
- const result = await response.handle(listPageDef.name, context);
+ const result = await response.handle(context);
const textContent = result.content.find(c => c.type === 'text') as {
type: 'text';
text: string;
@@ -183,7 +183,7 @@ describe('pages', () => {
} as ParsedArguments);
await listPageDef.handler({params: {}}, response, context);
- const result = await response.handle(listPageDef.name, context);
+ const result = await response.handle(context);
const textContent = result.content.find(c => c.type === 'text') as {
type: 'text';
text: string;
@@ -223,7 +223,7 @@ describe('pages', () => {
await listPages().handler({params: {}}, response, context);
- const result = await response.handle('list_pages', context);
+ const result = await response.handle(context);
t.assert.snapshot(JSON.stringify(result));
await dialog.dismiss();
await evalPromise;
@@ -343,7 +343,7 @@ describe('pages', () => {
response,
context,
);
- const result = await response.handle('new_page', context);
+ const result = await response.handle(context);
const pages = (
result.structuredContent as {pages: Array<{isolatedContext?: string}>}
).pages;
@@ -404,7 +404,7 @@ describe('pages', () => {
context,
);
- const result = await response.handle('new_page', context);
+ const result = await response.handle(context);
t.assert.snapshot(JSON.stringify(result));
await dialog.dismiss();
await evalPromise;
@@ -507,7 +507,7 @@ describe('pages', () => {
await closePage.handler({params: {pageId: 2}}, response, context);
- const result = await response.handle('close_page', context);
+ const result = await response.handle(context);
t.assert.snapshot(JSON.stringify(result));
});
});
@@ -617,7 +617,7 @@ describe('pages', () => {
await selectPage.handler({params: {pageId: 1}}, response, context);
- const result = await response.handle('select_page', context);
+ const result = await response.handle(context);
t.assert.snapshot(JSON.stringify(result));
await dialog.dismiss();
await evalPromise;
@@ -897,7 +897,7 @@ describe('pages', () => {
context,
);
- const result = await response.handle('navigate_page', context);
+ const result = await response.handle(context);
t.assert.snapshot(JSON.stringify(result));
});
});
@@ -1089,7 +1089,7 @@ describe('pages', () => {
context,
);
- const result = await response.handle('resize_page', context);
+ const result = await response.handle(context);
t.assert.snapshot(JSON.stringify(result));
await dialog.dismiss();
await evalPromise;
@@ -1290,7 +1290,7 @@ describe('pages', () => {
response,
context,
);
- const result = await response.handle('get_tab_id', context);
+ const result = await response.handle(context);
// @ts-expect-error _tabId is internal.
assert.strictEqual(result.structuredContent.tabId, 'test-tab-id');
assert.deepStrictEqual(response.responseLines, ['Tab ID: test-tab-id']);
diff --git a/tests/tools/performance.test.ts b/tests/tools/performance.test.ts
index 2de85a50..4bcddb57 100644
--- a/tests/tools/performance.test.ts
+++ b/tests/tools/performance.test.ts
@@ -416,7 +416,7 @@ describe('performance', () => {
context,
);
- const result = await response.handle('performance_stop_trace', context);
+ const result = await response.handle(context);
const fullOutput = result.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
@@ -480,7 +480,7 @@ describe('performance', () => {
context,
);
- const result = await response.handle('performance_stop_trace', context);
+ const result = await response.handle(context);
const fullOutput = result.content
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
diff --git a/tests/tools/thirdPartyDeveloper.test.ts b/tests/tools/thirdPartyDeveloper.test.ts
index bdacacdd..3268d31c 100644
--- a/tests/tools/thirdPartyDeveloper.test.ts
+++ b/tests/tools/thirdPartyDeveloper.test.ts
@@ -57,10 +57,7 @@ describe('thirdPartyDeveloperTools', () => {
context,
);
- const result = await response.handle(
- 'list_3p_developer_tools',
- context,
- );
+ const result = await response.handle(context);
// @ts-expect-error `structuredContent` has `thirdPartyDeveloperTools`
const groups = result.structuredContent.thirdPartyDeveloperTools;
assert.strictEqual(groups.length, 1);
@@ -103,10 +100,7 @@ describe('thirdPartyDeveloperTools', () => {
context,
);
- const result = await response.handle(
- 'list_3p_developer_tools',
- context,
- );
+ const result = await response.handle(context);
assert.ok(result.structuredContent);
assert.deepStrictEqual(
(
@@ -139,10 +133,7 @@ describe('thirdPartyDeveloperTools', () => {
context,
);
- const result = await response.handle(
- 'list_3p_developer_tools',
- context,
- );
+ const result = await response.handle(context);
assert.ok(result.structuredContent);
assert.deepStrictEqual(
(
@@ -169,10 +160,7 @@ describe('thirdPartyDeveloperTools', () => {
context,
);
- const result = await response.handle(
- 'list_3p_developer_tools',
- context,
- );
+ const result = await response.handle(context);
assert.ok(result.structuredContent);
assert.deepStrictEqual(
(
@@ -233,10 +221,7 @@ describe('thirdPartyDeveloperTools', () => {
context,
);
- const result = await response.handle(
- 'list_3p_developer_tools',
- context,
- );
+ const result = await response.handle(context);
const actualGroups =
// @ts-expect-error structuredContent has `thirdPartyDeveloperTools`
result.structuredContent.thirdPartyDeveloperTools;
@@ -280,7 +265,7 @@ describe('thirdPartyDeveloperTools', () => {
response,
context,
);
- await response.handle('list_3p_developer_tools', context);
+ await response.handle(context);
let groupsLength = await page.pptrPage.evaluate(
() => window.__dtmcp?.toolGroups?.length,
@@ -292,7 +277,7 @@ describe('thirdPartyDeveloperTools', () => {
response,
context,
);
- await response.handle('list_3p_developer_tools', context);
+ await response.handle(context);
groupsLength = await page.pptrPage.evaluate(
() => window.__dtmcp?.toolGroups?.length,
@@ -319,7 +304,7 @@ describe('thirdPartyDeveloperTools', () => {
response,
context,
);
- await response.handle('list_3p_developer_tools', context);
+ await response.handle(context);
}
it('executes a tool', async () => {