Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

git_show

Display detailed commit information including changes, author, and metadata to review code modifications and understand project history in your development environment.

Instructions

Show details of a commit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commitNoCommit hash or reference to showHEAD
cwdNoRepository directory

Implementation Reference

  • The core handler function for the 'git_show' tool. It validates input using Zod schema and executes the 'git show' command via the executeGitCommand helper, returning formatted output or error.
    export async function gitShow(args: z.infer<typeof gitShowSchema>): Promise<ToolResponse> {
      return executeGitCommand(`git show ${args.commit}`, args.cwd);
    }
  • Zod schema for input validation of the git_show tool parameters (commit and cwd). Used in the dispatch handler to parse arguments before calling the main function.
    export const gitShowSchema = z.object({
      commit: z.string().optional().default('HEAD').describe('Commit hash or reference to show'),
      cwd: z.string().optional().describe('Repository directory')
    });
  • MCP tool registration definition in gitTools array, including name, description, and JSON inputSchema advertised to MCP clients.
    {
      name: 'git_show',
      description: 'Show details of a commit',
      inputSchema: {
        type: 'object',
        properties: {
          commit: { type: 'string', default: 'HEAD', description: 'Commit hash or reference to show' },
          cwd: { type: 'string', description: 'Repository directory' }
        }
      }
  • src/index.ts:433-436 (registration)
    Dispatch handler in main MCP server that routes 'git_show' tool calls, validates args with schema, and invokes the gitShow implementation.
    if (name === 'git_show') {
      const validated = gitShowSchema.parse(args);
      return await gitShow(validated);
    }
  • Shared helper function that executes git commands via child_process.exec, formats output as ToolResponse, and handles errors uniformly across all git tools.
    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
        };
      }
    }

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