From 16f35233171f377204383cd37b42e03e4ff7f8d9 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Fri, 8 Aug 2025 09:36:51 -0700 Subject: [PATCH] chore: do not return fullPage screenshots to the LLM (#849) --- src/tools/screenshot.ts | 13 +++++++++---- tests/screenshot.spec.ts | 7 +------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tools/screenshot.ts b/src/tools/screenshot.ts index d508f21..0e4b4ce 100644 --- a/src/tools/screenshot.ts +++ b/src/tools/screenshot.ts @@ -75,10 +75,15 @@ const screenshot = defineTabTool({ const buffer = locator ? await locator.screenshot(options) : await tab.page.screenshot(options); response.addResult(`Took the ${screenshotTarget} screenshot and saved it as ${fileName}`); - response.addImage({ - contentType: fileType === 'png' ? 'image/png' : 'image/jpeg', - data: buffer - }); + + // https://github.com/microsoft/playwright-mcp/issues/817 + // Never return large images to LLM, saving them to the file system is enough. + if (!params.fullPage) { + response.addImage({ + contentType: fileType === 'png' ? 'image/png' : 'image/jpeg', + data: buffer + }); + } } }); diff --git a/tests/screenshot.spec.ts b/tests/screenshot.spec.ts index cce0c3b..76083f2 100644 --- a/tests/screenshot.spec.ts +++ b/tests/screenshot.spec.ts @@ -264,12 +264,7 @@ test('browser_take_screenshot (fullPage: true)', async ({ startClient, server }, { text: expect.stringContaining('fullPage: true'), type: 'text', - }, - { - data: expect.any(String), - mimeType: 'image/png', - type: 'image', - }, + } ], }); });