MCPcopy
hub / github.com/ChromeDevTools/chrome-devtools-mcp / definePageTool

Function definePageTool

src/tools/ToolDefinition.ts:362–384  ·  view source on GitHub ↗
(
  definition:
    | PageToolDefinition<Schema>
    | ((args?: Args) => PageToolDefinition<Schema>),
)

Source from the content-addressed store, hash-verified

360): (args?: Args) => DefinedPageTool<Schema>;
361
362export function definePageTool<
363 Schema extends zod.ZodRawShape,
364 Args extends ParsedArguments = ParsedArguments,
365>(
366 definition:
367 | PageToolDefinition<Schema>
368 | ((args?: Args) => PageToolDefinition<Schema>),
369): DefinedPageTool<Schema> | ((args?: Args) => DefinedPageTool<Schema>) {
370 if (typeof definition === 'function') {
371 return (args?: Args): DefinedPageTool<Schema> => {
372 const tool = definition(args);
373 return {
374 ...tool,
375 pageScoped: true,
376 };
377 };
378 }
379
380 return {
381 ...definition,
382 pageScoped: true,
383 } as DefinedPageTool<Schema>;
384}
385
386export const CLOSE_PAGE_ERROR =
387 'The last open page cannot be closed. It is fine to keep it open.';

Callers 14

input.tsFile · 0.85
console.tsFile · 0.85
lighthouse.tsFile · 0.85
network.tsFile · 0.85
performance.tsFile · 0.85
screenshot.tsFile · 0.85
emulation.tsFile · 0.85
webmcp.tsFile · 0.85
pages.tsFile · 0.85
memory.tsFile · 0.85
screencast.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected