git_track
Stage specific files or all changes in a Git repository to prepare them for committing, enabling controlled version management of code modifications.
Instructions
Track (stage) specific files or all files.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | The path to the local Git repository | |
| files | No | Array of file paths to track/stage (use ["."] for all files) |
Implementation Reference
- The main handler function for the git_track tool. It uses simpleGit to add (stage) the specified files to the index and returns the updated git status.export async function handleGitTrack({ repo_path, files = ["."] }) { try { const git = simpleGit(repo_path); // Add the specified files to the staging area await git.add(files); // Get status to show what files were tracked const status = await git.status(); return { content: [ { type: "text", text: JSON.stringify( { success: true, message: `Tracked ${ files.length === 1 && files[0] === "." ? "all files" : files.length + " files" }`, staged: status.staged, not_staged: status.not_added, modified: status.modified, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( { error: `Failed to track files: ${error.message}` }, null, 2 ), }, ], isError: true, }; } }
- src/server.js:349-369 (schema)The tool schema definition including name, description, and inputSchema for git_track, used in ListTools response.{ name: "git_track", description: "Track (stage) specific files or all files.", inputSchema: { type: "object", properties: { repo_path: { type: "string", description: "The path to the local Git repository", }, files: { type: "array", items: { type: "string" }, description: 'Array of file paths to track/stage (use ["."] for all files)', default: ["."], }, }, required: ["repo_path"], }, },
- src/server.js:908-908 (registration)Registration of the git_track handler in the this.handlersMap object, mapping the tool name to its handler function.git_track: handleGitTrack,
- src/handlers/index.js:52-52 (registration)Re-export of handleGitTrack from commit-operations.js in handlers index for centralized imports.handleGitTrack,
- src/handlers/index.js:12-12 (registration)Import of handleGitTrack from ./commit-operations.js in handlers index.handleGitTrack,