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,
        };
      }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions generating screenshots and a use case, but lacks critical behavioral details: it doesn't specify output format (e.g., image files, base64), file type support, error handling, performance characteristics, or whether it modifies files. For a tool with no annotation coverage, this is a significant gap in transparency.

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 perfectly concise and front-loaded: two sentences with zero waste. The first sentence states the core purpose, and the second adds practical context. Every word earns its place without redundancy or fluff.

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

Completeness2/5

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

Given no annotations, no output schema, and a tool that performs batch operations (implying complexity), the description is incomplete. It lacks information on what the tool returns (e.g., file paths, images), error conditions, or limitations (e.g., max files). For a tool with these contextual gaps, the description should provide more completeness.

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 already fully documents both parameters (filePaths array, theme with enum). The description adds no additional parameter semantics beyond what's in the schema—it doesn't explain file path requirements, theme implications, or default behaviors. Baseline 3 is appropriate when the schema does all the work.

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

Purpose4/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: 'Generate screenshots for multiple files at once' specifies the verb (generate) and resource (screenshots for files). It distinguishes from siblings by emphasizing batch processing ('multiple files at once'), but doesn't explicitly differentiate from each sibling tool by name or specific use case.

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

Usage Guidelines3/5

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

The description provides implied usage guidance: 'Useful for documenting multiple code files quickly' suggests a context of code documentation with efficiency needs. However, it doesn't explicitly state when to use this tool versus the sibling tools (generate_code_screenshot, screenshot_from_file, screenshot_git_diff) or provide any exclusion criteria.

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

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