Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

git_diff

Compare code changes between commits, working directory, and staging area to track modifications and review differences in your development workflow.

Instructions

Show changes between commits, working tree, and staging area

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdNoRepository directory
cachedNoShow staged changes
filesNoSpecific file(s) to diff
commitNoCompare against specific commit/branch

Implementation Reference

  • The main handler function that constructs and executes the 'git diff' command based on provided arguments, returning the ToolResponse.
    export async function gitDiff(args: z.infer<typeof gitDiffSchema>): Promise<ToolResponse> {
      const cachedFlag = args.cached ? '--cached' : '';
      const files = args.files || '';
      const commit = args.commit || '';
      return executeGitCommand(`git diff ${cachedFlag} ${commit} ${files}`.trim(), args.cwd);
    }
  • Zod schema defining the input parameters for the git_diff tool, used for validation.
    export const gitDiffSchema = z.object({
      cwd: z.string().optional().describe('Repository directory'),
      cached: z.boolean().optional().default(false).describe('Show staged changes'),
      files: z.string().optional().describe('Specific file(s) to diff'),
      commit: z.string().optional().describe('Compare against specific commit/branch')
    });
  • src/index.ts:369-371 (registration)
    Dispatch logic in the main MCP server handler that matches the tool name, validates arguments, and invokes the gitDiff handler.
    if (name === 'git_diff') {
      const validated = gitDiffSchema.parse(args);
      return await gitDiff(validated);
  • MCP tool registration definition including name, description, and JSON input schema, part of the gitTools array used for listing available tools.
      name: 'git_diff',
      description: 'Show changes between commits, working tree, and staging area',
      inputSchema: {
        type: 'object',
        properties: {
          cwd: { type: 'string', description: 'Repository directory' },
          cached: { type: 'boolean', default: false, description: 'Show staged changes' },
          files: { type: 'string', description: 'Specific file(s) to diff' },
          commit: { type: 'string', description: 'Compare against specific commit/branch' }
        }
      }
    },
  • Helper function that executes git commands via child_process.exec, formats output as ToolResponse, and handles errors.
    async function executeGitCommand(command: string, cwd?: string): Promise<ToolResponse> {
      try {
        const { stdout, stderr } = await execAsync(command, {
          cwd: cwd || process.cwd(),
          shell: '/bin/bash',
          maxBuffer: 10 * 1024 * 1024 // 10MB buffer
        });
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                success: true,
                command: command,
                stdout: stdout.trim(),
                stderr: stderr.trim(),
                cwd: cwd || process.cwd()
              }, null, 2)
            }
          ]
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                success: false,
                command: command,
                stdout: error.stdout?.trim() || '',
                stderr: error.stderr?.trim() || error.message,
                exitCode: error.code || 1,
                cwd: cwd || process.cwd()
              }, null, 2)
            }
          ],
          isError: true
        };
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral information. It mentions what the tool does but doesn't describe output format (unified diff format), error conditions, or performance characteristics. It doesn't specify that this is a read-only operation (though implied by 'show'), nor does it mention any side effects or authentication requirements.

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 a single, efficient sentence with zero wasted words. It's front-loaded with the core purpose and appropriately sized for a tool with good schema documentation. Every word earns its place by conveying essential information about what the tool does.

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?

For a Git diff tool with 4 parameters, 100% schema coverage, and no output schema, the description is minimally adequate. It states the core purpose but lacks important context about output format, common usage patterns, and how it differs from similar Git tools. The absence of annotations means the description should do more to explain behavioral aspects.

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 documents all 4 parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema. It doesn't explain parameter interactions or provide examples of how parameters combine (e.g., using 'cached' with 'files'). Baseline 3 is appropriate when schema does the heavy lifting.

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 verb 'show changes' and specifies the resources involved: 'between commits, working tree, and staging area'. It distinguishes from sibling tools like git_status (which shows status) or git_log (which shows history). However, it doesn't explicitly differentiate from git_show (which shows commit details) or mention that this shows differences rather than just listing changes.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to use git_diff vs git_status (for working directory status) or git_log (for commit history). There's no context about typical use cases like reviewing changes before committing or comparing branches.

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/ConnorBoetig-dev/mcp2'

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