git_status
Check Git repository status to view staged, unstaged, and untracked files. Use this tool to monitor file changes and track development progress in your working directory.
Instructions
Get repository status showing staged, unstaged, and untracked files
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Repository directory (defaults to current directory) | |
| short | No | Show short format status |
Implementation Reference
- src/tools/git.ts:212-215 (handler)The main handler function for 'git_status' tool. Executes the git status command with optional short format and cwd, using the executeGitCommand helper.export async function gitStatus(args: z.infer<typeof gitStatusSchema>): Promise<ToolResponse> { const shortFlag = args.short ? '--short' : ''; return executeGitCommand(`git status ${shortFlag}`, args.cwd); }
- src/tools/git.ts:65-68 (schema)Zod schema for input validation of git_status tool parameters.export const gitStatusSchema = z.object({ cwd: z.string().optional().describe('Repository directory (defaults to current directory)'), short: z.boolean().optional().default(false).describe('Show short format status') });
- src/tools/git.ts:491-501 (registration)Tool registration definition in gitTools array, including name, description, and JSON input schema for MCP tool listing.{ name: 'git_status', description: 'Get repository status showing staged, unstaged, and untracked files', inputSchema: { type: 'object', properties: { cwd: { type: 'string', description: 'Repository directory (defaults to current directory)' }, short: { type: 'boolean', default: false, description: 'Show short format status' } } } },
- src/tools/git.ts:21-60 (helper)Helper function that executes git commands via child_process.execAsync and formats the response as ToolResponse.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 }; }
- src/index.ts:357-359 (registration)Dispatcher in main CallToolRequest handler that validates input with gitStatusSchema and calls the gitStatus handler.if (name === 'git_status') { const validated = gitStatusSchema.parse(args); return await gitStatus(validated);