From b77398a62ec5efc60efb471b5a63b3fa46c5cb57 Mon Sep 17 00:00:00 2001 From: makseem77 Date: Wed, 30 Apr 2025 01:17:48 +0200 Subject: [PATCH] Add a fullPage param to the playwright_screen_capture tool Co-Authored-By: demostanis --- README.md | 3 ++- src/tools/vision.ts | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3860ab8a..f7f460da 100644 --- a/README.md +++ b/README.md @@ -702,7 +702,8 @@ X Y coordinate space, based on the provided screenshot. - **browser_screen_capture** - Title: Take a screenshot - Description: Take a screenshot of the current page - - Parameters: None + - Parameters: + - `fullPage` (boolean, optional): Whether the whole page should be screenshotted, or only the current viewport - Read-only: **true** diff --git a/src/tools/vision.ts b/src/tools/vision.ts index a3803116..a08b8647 100644 --- a/src/tools/vision.ts +++ b/src/tools/vision.ts @@ -29,13 +29,23 @@ const screenshot = defineTool({ name: 'browser_screen_capture', title: 'Take a screenshot', description: 'Take a screenshot of the current page', - inputSchema: z.object({}), + inputSchema: z.object({ + fullPage: z.boolean().optional().describe('Whether the whole page should be screenshotted, or only the current viewport'), + }), type: 'readOnly', }, - handle: async context => { + handle: async (context, params) => { const tab = await context.ensureTab(); - const options = { type: 'jpeg' as 'jpeg', quality: 50, scale: 'css' as 'css' }; + const options = { + type: 'jpeg' as 'jpeg', + quality: 50, + scale: 'css' as 'css', + }; + + if (params.fullPage) { + Object.assign(options, { fullPage: true }); + } const code = [ `// Take a screenshot of the current page`,