capture_screenshot_url
Capture base64-encoded JPEG screenshots of web pages for visual inspection, analysis, or user presentation. Customize captures to include single screens or full-page content based on your needs.
Instructions
Capture high-quality screenshots of web pages in base64 encoded JPEG format. Use this tool when you need to visually inspect a website, take a snapshot for analysis, or show users what a webpage looks like.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| firstScreenOnly | No | Set to true for a single screen capture (faster), false for full page capture including content below the fold | |
| return_url | No | Set to true to return screenshot URLs instead of downloading images as base64 | |
| url | Yes | The complete HTTP/HTTPS URL of the webpage to capture (e.g., 'https://example.com') |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"firstScreenOnly": {
"default": false,
"description": "Set to true for a single screen capture (faster), false for full page capture including content below the fold",
"type": "boolean"
},
"return_url": {
"default": false,
"description": "Set to true to return screenshot URLs instead of downloading images as base64",
"type": "boolean"
},
"url": {
"description": "The complete HTTP/HTTPS URL of the webpage to capture (e.g., 'https://example.com')",
"format": "uri",
"type": "string"
}
},
"required": [
"url"
],
"type": "object"
}
Implementation Reference
- src/tools/jina-tools.ts:100-163 (handler)Handler function that captures screenshot by posting to Jina's r.jina.ai API, retrieves image URL, optionally downloads/processes image (resize, JPEG base64) using downloadImages utility or returns URL.async ({ url, firstScreenOnly, return_url }: { url: string; firstScreenOnly: boolean; return_url: boolean }) => { try { const props = getProps(); const headers: Record<string, string> = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-Return-Format': firstScreenOnly === true ? 'screenshot' : 'pageshot', }; // Add Authorization header if bearer token is available if (props.bearerToken) { headers['Authorization'] = `Bearer ${props.bearerToken}`; } const response = await fetch('https://r.jina.ai/', { method: 'POST', headers, body: JSON.stringify({ url }), }); if (!response.ok) { return handleApiError(response, "Screenshot capture"); } const data = await response.json() as any; // Get the screenshot URL from the response const imageUrl = data.data.screenshotUrl || data.data.pageshotUrl; if (!imageUrl) { throw new Error("No screenshot URL received from API"); } // Prepare response content - always return as list structure for consistency const contentItems: Array<{ type: 'text'; text: string } | { type: 'image'; data: string; mimeType: string }> = []; if (return_url) { // Return the URL as text contentItems.push({ type: "text" as const, text: imageUrl, }); } else { // Download and process the image (resize to max 800px, convert to JPEG) const processedResults = await downloadImages(imageUrl, 1, 10000); const processedResult = processedResults[0]; if (!processedResult.success) { throw new Error(`Failed to process screenshot: ${processedResult.error}`); } contentItems.push({ type: "image" as const, data: processedResult.data!, mimeType: "image/jpeg", }); } return { content: contentItems, }; } catch (error) { return createErrorResponse(`Error: ${error instanceof Error ? error.message : String(error)}`); } },
- src/tools/jina-tools.ts:95-99 (schema)Zod input schema defining parameters: url (required string URL), firstScreenOnly (boolean, default false), return_url (boolean, default false).{ url: z.string().url().describe("The complete HTTP/HTTPS URL of the webpage to capture (e.g., 'https://example.com')"), firstScreenOnly: z.boolean().default(false).describe("Set to true for a single screen capture (faster), false for full page capture including content below the fold"), return_url: z.boolean().default(false).describe("Set to true to return screenshot URLs instead of downloading images as base64") },
- src/tools/jina-tools.ts:92-164 (registration)server.tool() call registering the 'capture_screenshot_url' tool with name, description, input schema, and handler function.server.tool( "capture_screenshot_url", "Capture high-quality screenshots of web pages in base64 encoded JPEG format. Use this tool when you need to visually inspect a website, take a snapshot for analysis, or show users what a webpage looks like.", { url: z.string().url().describe("The complete HTTP/HTTPS URL of the webpage to capture (e.g., 'https://example.com')"), firstScreenOnly: z.boolean().default(false).describe("Set to true for a single screen capture (faster), false for full page capture including content below the fold"), return_url: z.boolean().default(false).describe("Set to true to return screenshot URLs instead of downloading images as base64") }, async ({ url, firstScreenOnly, return_url }: { url: string; firstScreenOnly: boolean; return_url: boolean }) => { try { const props = getProps(); const headers: Record<string, string> = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-Return-Format': firstScreenOnly === true ? 'screenshot' : 'pageshot', }; // Add Authorization header if bearer token is available if (props.bearerToken) { headers['Authorization'] = `Bearer ${props.bearerToken}`; } const response = await fetch('https://r.jina.ai/', { method: 'POST', headers, body: JSON.stringify({ url }), }); if (!response.ok) { return handleApiError(response, "Screenshot capture"); } const data = await response.json() as any; // Get the screenshot URL from the response const imageUrl = data.data.screenshotUrl || data.data.pageshotUrl; if (!imageUrl) { throw new Error("No screenshot URL received from API"); } // Prepare response content - always return as list structure for consistency const contentItems: Array<{ type: 'text'; text: string } | { type: 'image'; data: string; mimeType: string }> = []; if (return_url) { // Return the URL as text contentItems.push({ type: "text" as const, text: imageUrl, }); } else { // Download and process the image (resize to max 800px, convert to JPEG) const processedResults = await downloadImages(imageUrl, 1, 10000); const processedResult = processedResults[0]; if (!processedResult.success) { throw new Error(`Failed to process screenshot: ${processedResult.error}`); } contentItems.push({ type: "image" as const, data: processedResult.data!, mimeType: "image/jpeg", }); } return { content: contentItems, }; } catch (error) { return createErrorResponse(`Error: ${error instanceof Error ? error.message : String(error)}`); } }, );
- src/index.ts:21-21 (registration)Invocation of registerJinaTools function which registers all Jina tools including 'capture_screenshot_url' on the MCP server.registerJinaTools(this.server, () => this.props);