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
| Name | Required | Description | Default |
|---|---|---|---|
| commit | No | Commit hash or reference to show | HEAD |
| cwd | No | Repository directory |
Implementation Reference
- src/tools/git.ts:454-456 (handler)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); }
- src/tools/git.ts:197-200 (schema)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') });
- src/tools/git.ts:749-758 (registration)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); }
- src/tools/git.ts:21-61 (helper)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 }; } }