Skip to main content
Glama

batch_screenshot

Generate screenshots for multiple code files simultaneously to create documentation quickly. Apply consistent color themes across all screenshots for professional presentation.

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

  • Core handler function that executes the batch screenshot logic: loops over file paths, generates individual screenshots, handles errors, and aggregates results with 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, }; }
  • Type definitions for input options and output result of 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)
    Tool registration in MCP server's listTools handler: defines name, description, and input schema matching BatchScreenshotOptions.
    { 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 CallToolRequestSchema handler for batch_screenshot: argument validation, invokes core batchScreenshot, constructs multi-part response with summary text and embedded images.
    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