Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

git_revert

Revert a Git commit by creating a new commit that undoes the changes. Apply changes without committing when needed to manage repository history effectively.

Instructions

Revert a commit by creating a new commit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commitYesCommit hash to revert
cwdNoRepository directory
noCommitNoApply changes without committing

Implementation Reference

  • The git_revert tool handler function that executes the git revert command using the shared executeGitCommand helper.
    export async function gitRevert(args: z.infer<typeof gitRevertSchema>): Promise<ToolResponse> {
      const noCommitFlag = args.noCommit ? '--no-commit' : '';
      return executeGitCommand(`git revert ${noCommitFlag} ${args.commit}`.trim(), args.cwd);
    }
  • Zod schema used for input validation in the git_revert handler.
    export const gitRevertSchema = z.object({
      commit: z.string().describe('Commit hash to revert'),
      cwd: z.string().optional().describe('Repository directory'),
      noCommit: z.boolean().optional().default(false).describe('Apply changes without committing')
    });
  • MCP tool registration definition in the gitTools array, including name, description, and JSON input schema.
    {
      name: 'git_revert',
      description: 'Revert a commit by creating a new commit',
      inputSchema: {
        type: 'object',
        properties: {
          commit: { type: 'string', description: 'Commit hash to revert' },
          cwd: { type: 'string', description: 'Repository directory' },
          noCommit: { type: 'boolean', default: false, description: 'Apply changes without committing' }
        },
        required: ['commit']
      }
    },
  • src/index.ts:425-428 (registration)
    Dispatch handler in the main MCP server that routes git_revert calls to the handler function after validation.
    if (name === 'git_revert') {
      const validated = gitRevertSchema.parse(args);
      return await gitRevert(validated);
    }
  • Shared helper function used by all git tools, including git_revert, to execute git commands and format 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
        };
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that a new commit is created, implying a non-destructive revert, but fails to detail critical aspects like error handling (e.g., merge conflicts), permission requirements, or the effect on the working directory. This leaves significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core action ('revert a commit') and mechanism ('creating a new commit'). There is zero waste, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a git revert operation (a mutation with potential side effects), no annotations, and no output schema, the description is incomplete. It lacks information on error conditions, output format, or behavioral nuances, making it inadequate for safe and effective use by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all parameters. The description adds no additional meaning beyond what's in the schema, such as explaining the interaction between 'commit' and 'noCommit' or typical use cases. Baseline score of 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('revert a commit') and the mechanism ('by creating a new commit'), which distinguishes it from destructive alternatives like 'git_reset'. However, it doesn't explicitly differentiate from all sibling tools like 'git_reset' or 'git_checkout' in the description text itself, though the purpose is inherently clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives such as 'git_reset' or 'git_checkout', nor does it mention prerequisites like being in a git repository or having uncommitted changes. The description lacks context for decision-making.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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