Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/tool-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ so returned values have to JSON-serializable.

- **format** (enum: "png", "jpeg") _(optional)_: Type of format to save the screenshot as. Default is "png"
- **fullPage** (boolean) _(optional)_: If set to true takes a screenshot of the full page instead of the currently visible viewport. Incompatible with uid.
- **quality** (number) _(optional)_: Compression quality for JPEG format (0-100). Higher values mean better quality but larger file sizes. Ignored for PNG format.
- **uid** (string) _(optional)_: The uid of an element on the page from the page content snapshot. If omitted takes a pages screenshot.

---
Expand Down
10 changes: 10 additions & 0 deletions src/tools/screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ export const screenshot = defineTool({
.enum(['png', 'jpeg'])
.default('png')
.describe('Type of format to save the screenshot as. Default is "png"'),
quality: z
.number()
.min(0)
.max(100)
.optional()
.describe(
'Compression quality for JPEG format (0-100). Higher values mean better quality but larger file sizes. Ignored for PNG format.',
),
uid: z
.string()
.optional()
Expand Down Expand Up @@ -50,6 +58,8 @@ export const screenshot = defineTool({
const screenshot = await pageOrHandle.screenshot({
type: request.params.format,
fullPage: request.params.fullPage,
quality: request.params.quality,
optimizeForSpeed: true, // Bonus: optimize encoding for speed
});

if (request.params.uid) {
Expand Down
Loading