status
Retrieve the current status of a Git repository, including staged changes, untracked files, branch details, and stash information, using customizable parameters for detailed or concise output.
Instructions
Get the current git repository status.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| aheadBehind | No | Display detailed ahead/behind counts relative to upstream branch (--ahead-behind, --no-ahead-behind) | |
| branch | No | Show the branch and tracking info even in short-format (-b, --branch) | |
| column | No | Display untracked files in columns (--column[=<options>], --no-column) | |
| findRenames | No | Turn on rename detection, optionally set similarity threshold (--find-renames[=<n>]) | |
| ignoreSubmodules | No | Ignore changes to submodules (--ignore-submodules[=<when>]) | |
| ignored | No | Show ignored files as well (--ignored[=<mode>]) | |
| long | No | Give the output in the long-format (--long, default) | |
| pathspec | No | Limit the output to the given paths | |
| renames | No | Turn on/off rename detection (--renames, --no-renames) | |
| repoPath | Yes | Absolute path to the git repository | |
| short | No | Give the output in the short-format (-s, --short) | |
| showStash | No | Show the number of entries currently stashed away (--show-stash) | |
| untrackedFiles | No | Show untracked files (-u[<mode>], --untracked-files[=<mode>]) | |
| verbose | No | Show textual changes that are staged to be committed (-v, --verbose, can be specified twice) |
Implementation Reference
- The core handler function (#handle) that executes the git status command using simple-git, checks if it's a repo, and returns the status as JSON.
readonly #handle: ToolCallback<typeof GIT_STATUS_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 status = await sg.status(this.inputToOptions(input)); return { content: [ { type: 'text', text: 'Git status retrieved successfully', }, { type: 'text', text: JSON.stringify(status), }, ], }; }; - Zod input schema (GIT_STATUS_INPUT_SCHEMA) defining all parameters for the git status tool, mirroring git status options.
export const GIT_STATUS_INPUT_SCHEMA = { repoPath: z.string().describe('Absolute path to the git repository'), short: z.boolean().optional().describe('Give the output in the short-format (-s, --short)'), branch: z.boolean().optional().describe('Show the branch and tracking info even in short-format (-b, --branch)'), showStash: z.boolean().optional().describe('Show the number of entries currently stashed away (--show-stash)'), long: z.boolean().optional().describe('Give the output in the long-format (--long, default)'), verbose: z .union([z.boolean(), z.number().int().min(0).max(2)]) .optional() .describe('Show textual changes that are staged to be committed (-v, --verbose, can be specified twice)'), untrackedFiles: z .union([z.boolean(), z.enum(['no', 'normal', 'all'])]) .optional() .describe('Show untracked files (-u[<mode>], --untracked-files[=<mode>])'), ignoreSubmodules: z .enum(['none', 'untracked', 'dirty', 'all']) .optional() .describe('Ignore changes to submodules (--ignore-submodules[=<when>])'), ignored: z .union([z.boolean(), z.enum(['traditional', 'no', 'matching'])]) .optional() .describe('Show ignored files as well (--ignored[=<mode>])'), aheadBehind: z .boolean() .optional() .describe('Display detailed ahead/behind counts relative to upstream branch (--ahead-behind, --no-ahead-behind)'), renames: z.boolean().optional().describe('Turn on/off rename detection (--renames, --no-renames)'), findRenames: z .union([z.boolean(), z.number().int().min(0).max(100)]) .optional() .describe('Turn on rename detection, optionally set similarity threshold (--find-renames[=<n>])'), column: z .union([z.boolean(), z.string()]) .optional() .describe('Display untracked files in columns (--column[=<options>], --no-column)'), pathspec: z.array(z.string()).optional().describe('Limit the output to the given paths'), }; - packages/mcp-git/src/tools/status.ts:64-66 (registration)The register method of GitStatusTool that calls srv.registerTool with the tool name 'status', config, and handler.
register(srv: McpServer) { srv.registerTool(this.name, this.config, this.#handle); } - packages/mcp-git/src/index.ts:20-20 (registration)Instantiation and registration of the GitStatusTool on the MCP server.
new GitStatusTool().register(server); - Getter that returns the tool name as 'status'.
get name() { return 'status'; }