chore: allow configuring screenshot tool (#286)

Fixes: https://github.com/microsoft/playwright-mcp/issues/277
This commit is contained in:
Pavel Feldman
2025-04-28 17:21:23 -07:00
committed by GitHub
parent 697a69a8c2
commit 12e72a96c4
3 changed files with 56 additions and 2 deletions

View File

@@ -244,14 +244,15 @@ const screenshot = defineTool({
else
code.push(`await page.screenshot(${javascript.formatObject(options)});`);
const includeBase64 = !context.config.tools?.browser_take_screenshot?.omitBase64;
const action = async () => {
const screenshot = locator ? await locator.screenshot(options) : await tab.page.screenshot(options);
return {
content: [{
content: includeBase64 ? [{
type: 'image' as 'image',
data: screenshot.toString('base64'),
mimeType: fileType === 'png' ? 'image/png' : 'image/jpeg',
}]
}] : []
};
};