show
View detailed commit information and changes in a Git repository. Specify format, paths, or file status to customize output.
Instructions
Display commit details and changes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| commit | No | Commit hash, branch, or tag to show (defaults to HEAD) | |
| format | No | Pretty-print format for commit | |
| nameOnly | No | Show only names of changed files (--name-only) | |
| nameStatus | No | Show names and status of changed files (--name-status) | |
| pathspec | No | Limit show to specific paths | |
| repoPath | Yes | Absolute path to the git repository | |
| stat | No | Show diffstat (--stat) |
Implementation Reference
- packages/mcp-git/src/tools/show.ts:42-93 (handler)The private #handle method implements the core logic of the 'show' tool. It validates the repo, constructs git show arguments based on input, executes using simple-git, and returns the result as text content.readonly #handle: ToolCallback<typeof GIT_SHOW_INPUT_SCHEMA> = async (input) => { const sg = simpleGit(input.repoPath); const isRepo = await sg.checkIsRepo(); if (!isRepo) { return { isError: true, content: [ { type: 'text', text: 'Not a git repository', }, ], }; } const args: string[] = []; if (input.format) { args.push(`--pretty=${input.format}`); } if (input.nameOnly) { args.push('--name-only'); } if (input.nameStatus) { args.push('--name-status'); } if (input.stat) { args.push('--stat'); } const commit = input.commit ?? 'HEAD'; args.push(commit); if (input.pathspec && input.pathspec.length > 0) { args.push('--', ...input.pathspec); } const result = await sg.show(args); return { content: [ { type: 'text', text: result || `No information found for ${commit}`, }, ], }; };
- GIT_SHOW_INPUT_SCHEMA defines the Zod input schema for the 'show' tool, including repoPath, commit, format, and various flags.export const GIT_SHOW_INPUT_SCHEMA = { repoPath: z.string().describe('Absolute path to the git repository'), commit: z.string().optional().describe('Commit hash, branch, or tag to show (defaults to HEAD)'), format: z .enum(['oneline', 'short', 'medium', 'full', 'fuller', 'email', 'raw']) .optional() .describe('Pretty-print format for commit'), nameOnly: z.boolean().optional().describe('Show only names of changed files (--name-only)'), nameStatus: z.boolean().optional().describe('Show names and status of changed files (--name-status)'), stat: z.boolean().optional().describe('Show diffstat (--stat)'), pathspec: z.array(z.string()).optional().describe('Limit show to specific paths'), };
- packages/mcp-git/src/index.ts:28-28 (registration)new GitShowTool().register(server); registers the 'show' tool with the MCP server.new GitShowTool().register(server);
- packages/mcp-git/src/tools/show.ts:38-40 (registration)The register method on GitShowTool calls srv.registerTool(this.name, this.config, this.#handle) to register the tool.register(srv: McpServer) { srv.registerTool(this.name, this.config, this.#handle); }
- The name getter returns 'show', defining the tool's name.get name() { return 'show'; }