Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

git_commit

Create Git commits with staged changes using custom messages, amend previous commits, and optionally skip pre-commit hooks for version control management.

Instructions

Create a commit with staged changes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYesCommit message
cwdNoRepository directory
amendNoAmend previous commit
noVerifyNoSkip pre-commit hooks

Implementation Reference

  • The main handler function for the git_commit tool. It constructs and executes the git commit command with options for amending and skipping hooks, using the shared executeGitCommand helper.
    export async function gitCommit(args: z.infer<typeof gitCommitSchema>): Promise<ToolResponse> {
      const amendFlag = args.amend ? '--amend' : '';
      const noVerifyFlag = args.noVerify ? '--no-verify' : '';
      // Escape message for shell
      const escapedMessage = args.message.replace(/'/g, "'\\''");
      return executeGitCommand(`git commit ${amendFlag} ${noVerifyFlag} -m '${escapedMessage}'`, args.cwd);
    }
  • Zod schema used for input validation of the git_commit tool parameters.
    export const gitCommitSchema = z.object({
      message: z.string().describe('Commit message'),
      cwd: z.string().optional().describe('Repository directory'),
      amend: z.boolean().optional().default(false).describe('Amend previous commit'),
      noVerify: z.boolean().optional().default(false).describe('Skip pre-commit hooks')
    });
  • src/index.ts:365-368 (registration)
    MCP server dispatch logic that handles calls to 'git_commit' by validating inputs with gitCommitSchema and invoking the gitCommit handler.
    if (name === 'git_commit') {
      const validated = gitCommitSchema.parse(args);
      return await gitCommit(validated);
    }
  • Tool metadata registration in the gitTools array, used by MCP server for listing available tools including name, description, and JSON schema.
    {
      name: 'git_commit',
      description: 'Create a commit with staged changes',
      inputSchema: {
        type: 'object',
        properties: {
          message: { type: 'string', description: 'Commit message' },
          cwd: { type: 'string', description: 'Repository directory' },
          amend: { type: 'boolean', default: false, description: 'Amend previous commit' },
          noVerify: { type: 'boolean', default: false, description: 'Skip pre-commit hooks' }
        },
        required: ['message']
      }
    },
  • Shared utility function used by all git tools, including gitCommit, to execute git commands asynchronously with proper error handling and JSON-formatted responses.
    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
        };
      }
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ConnorBoetig-dev/mcp2'

If you have feedback or need assistance with the MCP directory API, please join our Discord server