git_commit
Create Git commits with custom messages for specified repositories, enabling version control and tracking changes efficiently within the Git Repo Browser MCP environment.
Instructions
Create a commit with the specified message.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message | Yes | The commit message | |
| repo_path | Yes | The path to the local Git repository |
Implementation Reference
- The handler function that executes the git_commit tool. It uses simpleGit to perform the commit on staged changes in the given repository path with the provided message, returning the commit hash and summary on success or an error message.export async function handleGitCommit({ repo_path, message }) { try { const git = simpleGit(repo_path); // Create the commit (only commit what's in the staging area) const commitResult = await git.commit(message); return { content: [ { type: "text", text: JSON.stringify( { success: true, commit_hash: commitResult.commit, commit_message: message, summary: commitResult.summary, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( { error: `Failed to create commit: ${error.message}` }, null, 2 ), }, ], isError: true, }; } }
- src/server.js:331-348 (schema)The input schema definition for the git_commit tool, specifying repo_path and message as required string parameters.{ name: "git_commit", description: "Create a commit with the specified message.", inputSchema: { type: "object", properties: { repo_path: { type: "string", description: "The path to the local Git repository", }, message: { type: "string", description: "The commit message", }, }, required: ["repo_path", "message"], }, },
- src/server.js:907-907 (registration)Registers the handleGitCommit function to the 'git_commit' tool name in the handlersMap used by the MCP server to dispatch tool calls.git_commit: handleGitCommit,
- src/server.js:18-18 (registration)Imports the handleGitCommit handler from './handlers/index.js' for use in the server.handleGitCommit,