browser_screenshot
Capture screenshots from web browsers using Playwright sessions. Manage multiple concurrent instances with automatic cleanup for efficient browser automation.
Instructions
Take screenshot
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "browser_screenshot"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fullPage | No |
Implementation Reference
- index.js:352-358 (registration)Registration of the 'browser_screenshot' tool. It validates input via zod schema and then calls 'proxyToolCall' with the actual tool name 'browser_take_screenshot'.
server.tool('browser_screenshot', 'Take screenshot', { fullPage: z.boolean().optional() }, async (args) => { const check = requireActivePage(); if (check) return check; return proxyToolCall('browser_take_screenshot', args); }); - index.js:209-237 (handler)The 'proxyToolCall' function acts as a wrapper that forwards tool requests to an external client instance. This handles the actual execution logic for tools like 'browser_take_screenshot'.
async function proxyToolCall(toolName, args) { log(`[proxyToolCall] ${toolName} with args: ${JSON.stringify(args)}`); const { client } = await getOrCreateInstance(); log(`[proxyToolCall] got client for port ${assignedPort}`); // Update last used if (assignedPort && instances.has(assignedPort)) { instances.get(assignedPort).lastUsed = Date.now(); } try { log(`[proxyToolCall] Calling client.callTool...`); const result = await client.callTool({ name: toolName, arguments: args || {} }); log(`[proxyToolCall] Result type: ${typeof result}`); log(`[proxyToolCall] Result: ${JSON.stringify(result).slice(0, 500)}`); // The SDK returns { content: [...], isError?: boolean } // We need to return this same format if (result && result.content) { return result; } // Fallback: wrap in content array if needed return { content: [{ type: 'text', text: JSON.stringify(result) }] }; } catch (error) { log(`[proxyToolCall] ERROR: ${error.message}\n${error.stack}`); return {