Skip to main content
Glama
jina-ai

Jina AI Remote MCP Server

Official
by jina-ai

capture_screenshot_url

Capture web page screenshots in JPEG format for visual inspection, analysis, or demonstration. Specify URL and choose between single-screen or full-page capture.

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

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe complete HTTP/HTTPS URL of the webpage to capture (e.g., 'https://example.com')
firstScreenOnlyNoSet to true for a single screen capture (faster), false for full page capture including content below the fold
return_urlNoSet to true to return screenshot URLs instead of downloading images as base64

Implementation Reference

  • Core handler function that fetches screenshot from r.jina.ai API using POST request, extracts image URL, optionally downloads and resizes it to base64 JPEG using downloadImages helper, returns image or 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)}`);
    	}
  • Zod input schema defining parameters for the tool: url (required URL), firstScreenOnly (boolean, default false for full page), return_url (boolean, default false for base64 image).
    {
    	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")
    },
  • Registers the capture_screenshot_url tool on the MCP server using server.tool() if enabled by tool filtering.
    if (isToolEnabled("capture_screenshot_url")) {
    	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)}`);
    			}
    		},
    	);
    }
  • Helper utility called by the handler to download screenshot URL, resize using Cloudflare Workers image API (max 800px, JPEG 85% quality), encode to base64, with concurrency and timeout support.
    export async function downloadImages(
        urls: string | string[],
        concurrencyLimit: number = 3,
        timeoutMs: number = 15000
    ): Promise<ProcessedImageResult[]> {
        // Normalize input to always be an array
        const urlArray = Array.isArray(urls) ? urls : [urls];
    
        if (urlArray.length === 0) {
            return [];
        }
    
        const results: ProcessedImageResult[] = [];
        const queue = [...urlArray];
    
        // Create a timeout promise
        const timeoutPromise = new Promise<ProcessedImageResult[]>((_, reject) => {
            setTimeout(() => reject(new Error('Download timeout')), timeoutMs);
        });
    
        // Create the download promise
        const downloadPromise = (async () => {
            // Process images in batches
            while (queue.length > 0) {
                const batch = queue.splice(0, concurrencyLimit);
                const batchPromises = batch.map(async (url) => {
                    try {
                        // Skip SVG images as they can't be processed by Cloudflare image transformation
                        if (url.toLowerCase().endsWith('.svg') || url.toLowerCase().includes('.svg?')) {
                            return {
                                url,
                                success: false,
                                mimeType: "image/jpeg",
                                error: "SVG images are not supported for transformation"
                            };
                        }
    
                        // Use Cloudflare Workers image transformation
                        // This automatically handles resizing and format conversion
                        const response = await fetch(url, {
                            cf: {
                                image: {
                                    fit: 'scale-down', // Never enlarge, only shrink
                                    width: 800,        // Max width
                                    height: 800,       // Max height
                                    format: 'jpeg',    // Convert to JPEG
                                    quality: 85,       // Good quality with reasonable file size
                                    compression: 'fast' // Faster processing
                                }
                            }
                        } as any);
    
                        if (!response.ok) {
                            return {
                                url,
                                success: false,
                                mimeType: "image/jpeg",
                                error: `HTTP ${response.status}: ${response.statusText}`
                            };
                        }
    
                        const arrayBuffer = await response.arrayBuffer();
                        const base64Image = Buffer.from(arrayBuffer).toString('base64');
    
                        return {
                            url,
                            success: true,
                            data: base64Image,
                            mimeType: "image/jpeg"
                        };
                    } catch (error) {
                        return {
                            url,
                            success: false,
                            mimeType: "image/jpeg",
                            error: error instanceof Error ? error.message : String(error)
                        };
                    }
                });
    
                const batchResults = await Promise.all(batchPromises);
                results.push(...batchResults);
            }
    
            return results;
        })();
    
        // Race between download completion and timeout
        try {
            return await Promise.race([downloadPromise, timeoutPromise]);
        } catch (error) {
            if (error instanceof Error && error.message === 'Download timeout') {
                // Return what we have so far
                return results;
            }
            throw error;
        }
    }
  • src/index.ts:100-102 (registration)
    Higher-level registration call to registerJinaTools which includes capture_screenshot_url among other tools, with tool filtering support.
    registerJinaTools(server, () => currentProps, enabledTools);
    
    return server;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the output format (base64 JPEG) and general use cases but lacks details on potential behavioral traits like rate limits, authentication needs, error conditions, or performance implications (e.g., timeouts for slow-loading pages). The description is functional but insufficient for a mutation-like tool (capturing external resources) without annotation support.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured with two sentences: the first states the core functionality and output format, and the second provides usage guidelines. Every sentence adds value without redundancy, making it easy to parse and front-loaded with essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a screenshot tool (involving external web interactions) and the absence of both annotations and an output schema, the description is moderately complete. It covers purpose and usage but lacks details on behavioral aspects like error handling or output specifics (e.g., what the base64 string or URL looks like). This leaves gaps that could hinder effective tool invocation by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all three parameters (url, firstScreenOnly, return_url) with clear descriptions. The description adds no additional parameter semantics beyond what's in the schema, but this is acceptable given the high coverage, resulting in a baseline score of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('capture high-quality screenshots') and resources ('web pages'), specifying the output format ('base64 encoded JPEG format'). It distinguishes itself from sibling tools like 'read_url' or 'search_web' by focusing on visual capture rather than text extraction or searching.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear usage contexts ('visually inspect a website', 'take a snapshot for analysis', 'show users what a webpage looks like'), giving practical scenarios for when to use this tool. However, it doesn't explicitly mention when NOT to use it or name specific alternatives among siblings, such as 'read_url' for text content instead of screenshots.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jina-ai/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server