Skip to main content
Glama

screenshot_git_diff

Capture visual representations of Git diff output to document code changes. Generate screenshots showing differences in working directory or staged files with syntax highlighting.

Instructions

Generate a screenshot of git diff output. Shows changes in your working directory or staged changes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathNoOptional: Specific file to diff. If not provided, shows diff for all changes.
stagedNoShow staged changes (git diff --staged) instead of unstaged changes
themeNoColor theme (dracula, nord, monokai, github-light, github-dark)

Implementation Reference

  • The core handler function that executes the `git diff` command (optionally --staged and for specific file), captures stdout as diff code, and generates a syntax-highlighted screenshot using `generateScreenshot` with language 'diff'.
    export async function screenshotGitDiff(
      options: ScreenshotGitDiffOptions
    ): Promise<GenerateScreenshotResult> {
      try {
        // Build git diff command
        let command = "git diff";
    
        if (options.staged) {
          command += " --staged";
        }
    
        if (options.filePath) {
          command += ` -- "${options.filePath}"`;
        }
    
        // Execute git diff
        const { stdout, stderr } = await execAsync(command);
    
        if (stderr && !stdout) {
          throw new Error(`Git diff error: ${stderr}`);
        }
    
        if (!stdout || stdout.trim().length === 0) {
          throw new Error("No changes to display");
        }
    
        // Generate screenshot with diff language
        return generateScreenshot({
          code: stdout,
          language: "diff",
          theme: options.theme,
        });
      } catch (error) {
        if (error instanceof Error) {
          throw new Error(`Failed to generate git diff screenshot: ${error.message}`);
        }
        throw error;
      }
    }
  • MCP tool registration schema defining the 'screenshot_git_diff' tool, its description, and input schema (filePath optional, staged boolean, theme enum).
      name: "screenshot_git_diff",
      description: "Generate a screenshot of git diff output. Shows changes in your working directory or staged changes.",
      inputSchema: {
        type: "object",
        properties: {
          filePath: {
            type: "string",
            description: "Optional: Specific file to diff. If not provided, shows diff for all changes.",
          },
          staged: {
            type: "boolean",
            description: "Show staged changes (git diff --staged) instead of unstaged changes",
          },
          theme: {
            type: "string",
            description: "Color theme (dracula, nord, monokai, github-light, github-dark)",
            enum: ["dracula", "nord", "monokai", "github-light", "github-dark"],
          },
        },
        required: [],
      },
    },
  • src/index.ts:241-282 (registration)
    MCP CallToolRequest handler dispatch for 'screenshot_git_diff' that parses arguments, calls the screenshotGitDiff function, and returns image content or error.
    if (name === "screenshot_git_diff") {
      try {
        const { filePath, staged, theme = "dracula" } = (args || {}) as {
          filePath?: string;
          staged?: boolean;
          theme?: string;
        };
    
        // Generate the screenshot from git diff
        const result = await screenshotGitDiff({
          filePath,
          staged,
          theme,
        });
    
        const diffType = staged ? "Staged changes" : "Unstaged changes";
        const fileInfo = filePath ? `\nFile: ${filePath}` : "\nAll files";
    
        return {
          content: [
            {
              type: "text",
              text: `✅ Git diff screenshot generated successfully!\n\n${diffType}${fileInfo}\nSaved to: ${result.path}\n\nTheme: ${theme}\n\nYou can view the image in your file browser.`,
            },
            {
              type: "image",
              data: result.base64,
              mimeType: "image/png",
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `❌ Error generating git diff screenshot: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
          isError: true,
        };
      }
  • TypeScript interface defining the input options for the screenshotGitDiff handler.
    export interface ScreenshotGitDiffOptions {
      filePath?: string;
      staged?: boolean;
      theme?: string;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool generates a screenshot, implying a read-only operation that produces an image, but does not disclose details such as output format (e.g., PNG, JPEG), size, permissions needed, rate limits, or whether it modifies any state. This leaves significant gaps for an AI agent to understand the tool's behavior fully.

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

Conciseness4/5

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

The description is concise and front-loaded, with two sentences that directly state the tool's purpose and scope. There is no unnecessary information, and each sentence contributes to understanding the tool's function. However, it could be slightly more structured by explicitly separating purpose from usage hints.

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 tool's moderate complexity (3 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and scope but lacks details on output (e.g., image format, handling of errors), behavioral traits, and explicit usage guidelines. This makes it minimally viable but with clear gaps for effective tool invocation.

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?

The input schema has 100% description coverage, providing clear details for all parameters (filePath, staged, theme). The description adds no additional parameter semantics beyond what the schema already explains, such as not elaborating on default behaviors or interactions between parameters. Since schema coverage is high, the baseline score of 3 is appropriate, as the description does not compensate with extra insights.

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 a screenshot of git diff output' with the specific resource being git diff output. It distinguishes from siblings like 'batch_screenshot' or 'screenshot_from_file' by specifying git diff content, though it doesn't explicitly contrast with 'generate_code_screenshot' which might handle different code-related screenshots.

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 context by mentioning 'Shows changes in your working directory or staged changes,' which suggests when to use it (for git diff visualization). However, it lacks explicit guidance on when to choose this over alternatives like 'generate_code_screenshot' or 'screenshot_from_file,' and does not mention any exclusions or prerequisites.

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