Skip to main content
Glama

batch_screenshot

Generate syntax-highlighted screenshots for multiple code files simultaneously to accelerate documentation workflows. Apply consistent color themes across all files.

Instructions

Generate screenshots for multiple files at once. Useful for documenting multiple code files quickly.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathsYesArray of file paths to screenshot
themeNoColor theme to apply to all screenshots (dracula, nord, monokai, github-light, github-dark)

Implementation Reference

  • The core batchScreenshot function that iterates over filePaths, calls screenshotFromFile for each, handles errors, and returns a result with screenshots, success/failure counts.
    export async function batchScreenshot( options: BatchScreenshotOptions ): Promise<BatchScreenshotResult> { const results: BatchScreenshotResult["results"] = []; let successCount = 0; let failureCount = 0; for (const filePath of options.filePaths) { try { const screenshot = await screenshotFromFile({ filePath, theme: options.theme, }); results.push({ filePath, screenshot, }); successCount++; } catch (error) { results.push({ filePath, screenshot: { path: "", base64: "" }, error: error instanceof Error ? error.message : String(error), }); failureCount++; } } return { results, successCount, failureCount, }; }
  • Input (BatchScreenshotOptions) and output (BatchScreenshotResult) type definitions for the batchScreenshot function.
    export interface BatchScreenshotOptions { filePaths: string[]; theme?: string; } export interface BatchScreenshotResult { results: Array<{ filePath: string; screenshot: GenerateScreenshotResult; error?: string; }>; successCount: number; failureCount: number; }
  • src/index.ts:107-128 (registration)
    Registration of the 'batch_screenshot' tool in the ListTools response, defining name, description, and input schema.
    { name: "batch_screenshot", description: "Generate screenshots for multiple files at once. Useful for documenting multiple code files quickly.", inputSchema: { type: "object", properties: { filePaths: { type: "array", items: { type: "string", }, description: "Array of file paths to screenshot", }, theme: { type: "string", description: "Color theme to apply to all screenshots (dracula, nord, monokai, github-light, github-dark)", enum: ["dracula", "nord", "monokai", "github-light", "github-dark"], }, }, required: ["filePaths"], }, },
  • MCP server CallToolRequest handler for 'batch_screenshot' tool: validates input, invokes batchScreenshot, constructs response with text summary and embedded images for each successful screenshot.
    if (name === "batch_screenshot") { if (!args) { throw new Error("Arguments are required"); } try { const { filePaths, theme = "dracula" } = args as { filePaths: string[]; theme?: string; }; if (!filePaths || !Array.isArray(filePaths) || filePaths.length === 0) { throw new Error("filePaths array is required and must not be empty"); } // Generate batch screenshots const batchResult = await batchScreenshot({ filePaths, theme, }); // Build response content const content: Array<{ type: string; text?: string; data?: string; mimeType?: string }> = [ { type: "text", text: `✅ Batch screenshot completed!\n\nTotal files: ${filePaths.length}\nSuccessful: ${batchResult.successCount}\nFailed: ${batchResult.failureCount}\n\nTheme: ${theme}\n\n`, }, ]; // Add each screenshot or error message for (const result of batchResult.results) { if (result.error) { content[0].text += `\n❌ ${result.filePath}: ${result.error}`; } else { content[0].text += `\n✅ ${result.filePath}: ${result.screenshot.path}`; content.push({ type: "image", data: result.screenshot.base64, mimeType: "image/png", }); } } return { content }; } catch (error) { return { content: [ { type: "text", text: `❌ Error in batch screenshot: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; }

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/MoussaabBadla/code-screenshot-mcp'

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