screenshot
Capture web page screenshots with customizable viewport dimensions, image formats, and capture settings for documentation or analysis.
Instructions
Capture screenshots of web pages with customizable settings.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to capture | |
| width | No | Viewport width | |
| height | No | Viewport height | |
| deviceScaleFactor | No | Device scale factor | |
| fullPage | No | Capture full page | |
| format | No | Image format | |
| quality | No | Image quality (1-100) | |
| renderJs | No | Render JavaScript | |
| wait | No | Wait time in ms before capture | |
| clipRectangle | No | Area to clip | |
| blockCookieBanners | No | Block cookie banners | |
| autoScroll | No | Auto-scroll page |
Implementation Reference
- src/index.ts:476-517 (handler)The handler function executes the screenshot tool by sending a POST request to the DumplingAI API endpoint `/api/v1/screenshot` with the provided parameters and returns the JSON response.
async ({ url, width, height, deviceScaleFactor, fullPage, format, quality, renderJs, wait, clipRectangle, blockCookieBanners, autoScroll, }) => { const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch(`${NWS_API_BASE}/api/v1/screenshot`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ url, width, height, deviceScaleFactor, fullPage, format, quality, renderJs, waitFor: wait, clipRectangle, blockCookieBanners, autoScroll, }), }); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } - src/index.ts:445-475 (schema)Zod schema defining the input parameters for the screenshot tool, including URL, dimensions, format options, and other screenshot settings.
{ url: z.string().url().describe("URL to capture"), width: z.number().optional().describe("Viewport width"), height: z.number().optional().describe("Viewport height"), deviceScaleFactor: z.number().optional().describe("Device scale factor"), fullPage: z.boolean().optional().describe("Capture full page"), format: z.enum(["png", "jpeg"]).optional().describe("Image format"), quality: z.number().optional().describe("Image quality (1-100)"), renderJs: z.boolean().optional().describe("Render JavaScript"), wait: z .number() .min(0) .max(5000) .default(0) .describe("Wait time in ms before capture"), clipRectangle: z .object({ top: z.number(), left: z.number(), width: z.number(), height: z.number(), }) .optional() .describe("Area to clip"), blockCookieBanners: z .boolean() .optional() .default(true) .describe("Block cookie banners"), autoScroll: z.boolean().optional().describe("Auto-scroll page"), }, - src/index.ts:441-518 (registration)The server.tool call that registers the "screenshot" tool with its description, input schema, and handler function.
// Tool to capture screenshots server.tool( "screenshot", "Capture screenshots of web pages with customizable settings.", { url: z.string().url().describe("URL to capture"), width: z.number().optional().describe("Viewport width"), height: z.number().optional().describe("Viewport height"), deviceScaleFactor: z.number().optional().describe("Device scale factor"), fullPage: z.boolean().optional().describe("Capture full page"), format: z.enum(["png", "jpeg"]).optional().describe("Image format"), quality: z.number().optional().describe("Image quality (1-100)"), renderJs: z.boolean().optional().describe("Render JavaScript"), wait: z .number() .min(0) .max(5000) .default(0) .describe("Wait time in ms before capture"), clipRectangle: z .object({ top: z.number(), left: z.number(), width: z.number(), height: z.number(), }) .optional() .describe("Area to clip"), blockCookieBanners: z .boolean() .optional() .default(true) .describe("Block cookie banners"), autoScroll: z.boolean().optional().describe("Auto-scroll page"), }, async ({ url, width, height, deviceScaleFactor, fullPage, format, quality, renderJs, wait, clipRectangle, blockCookieBanners, autoScroll, }) => { const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch(`${NWS_API_BASE}/api/v1/screenshot`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ url, width, height, deviceScaleFactor, fullPage, format, quality, renderJs, waitFor: wait, clipRectangle, blockCookieBanners, autoScroll, }), }); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );