browser_snapshot
Capture accessibility snapshots of web pages to analyze content structure and elements for testing or documentation purposes.
Instructions
Capture accessibility snapshot of the current page, this is better than screenshot
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | No | Save snapshot to markdown file instead of returning it in the response. |
Implementation Reference
- src/tools/snapshot.ts:33-41 (handler)Handler function for the browser_snapshot tool. Ensures a tab is active and instructs the system to capture an accessibility snapshot of the page.handle: async context => { await context.ensureTab(); return { code: [`// <internal code to capture accessibility snapshot>`], captureSnapshot: true, waitForNetwork: false, }; },
- src/tools/snapshot.ts:25-31 (schema)Schema definition for the browser_snapshot tool, including name, title, description, empty input schema (no parameters), and readOnly type.schema: { name: 'browser_snapshot', title: 'Page snapshot', description: 'Capture accessibility snapshot of the current page, this is better than screenshot', inputSchema: z.object({}), type: 'readOnly', },
- src/tools.ts:36-52 (registration)Registration of browser_snapshot within the snapshotTools array by including exports from the snapshot module.export const snapshotTools: Tool<any>[] = [ ...common(true), ...console, ...dialogs(true), ...files(true), ...install, ...keyboard(true), ...navigate(true), ...network, ...pdf, ...screenshot, ...snapshot, ...tabs(true), ...testing, ...video, ...wait(true), ];
- src/connection.ts:22-33 (registration)Final registration where snapshotTools (including browser_snapshot) are selected based on config and passed to the MCP server context and tool handlers.import { snapshotTools, visionTools } from './tools.js'; import { packageJSON } from './package.js'; import { FullConfig, validateConfig } from './config.js'; import type { BrowserContextFactory } from './browserContextFactory.js'; export function createConnection(config: FullConfig, browserContextFactory: BrowserContextFactory): Connection { const allTools = config.vision ? visionTools : snapshotTools; const tools = allTools.filter(tool => !config.capabilities || tool.capability === 'core' || config.capabilities.includes(tool.capability)); validateConfig(config); const context = new Context(tools, config, browserContextFactory);