Skip to main content
Glama
bsreeram08

Git Repo Browser MCP

git_revert

Undo changes by reverting a Git branch to a specific commit or state, allowing you to stage changes without committing if needed.

Instructions

Revert the current branch to a commit or state.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYesThe path to the local Git repository
commitNoCommit hash or reference to revert
no_commitNoWhether to stage changes without committing

Implementation Reference

  • Main handler function that performs Git revert operation using simpleGit, handling options like no-commit and error cases including conflicts.
    export async function handleGitRevert({
      repo_path,
      commit,
      no_commit = false,
    }) {
      try {
        const git = simpleGit(repo_path);
    
        if (!commit) {
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  { error: "Commit reference is required" },
                  null,
                  2
                ),
              },
            ],
            isError: true,
          };
        }
    
        // Build the revert command
        const revertOptions = [];
        if (no_commit) {
          revertOptions.push("--no-commit");
        }
    
        // Perform the revert
        const result = await git.raw(["revert", ...revertOptions, commit]);
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  success: true,
                  message: `Reverted commit ${commit}`,
                  commit: commit,
                  result: result,
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  error: `Failed to revert commit: ${error.message}`,
                  conflicts: error.git ? error.git.conflicts : null,
                },
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
    }
  • Tool schema definition for git_revert including input parameters validation: repo_path (required), commit, no_commit (default false).
    {
      name: "git_revert",
      description: "Revert the current branch to a commit or state.",
      inputSchema: {
        type: "object",
        properties: {
          repo_path: {
            type: "string",
            description: "The path to the local Git repository",
          },
          commit: {
            type: "string",
            description: "Commit hash or reference to revert",
          },
          no_commit: {
            type: "boolean",
            description: "Whether to stage changes without committing",
            default: false,
          },
        },
        required: ["repo_path"],
      },
    },
  • src/server.js:926-926 (registration)
    Registration of the git_revert tool name to its handler function handleGitRevert in the handlersMap.
    git_revert: handleGitRevert,
  • Re-export of handleGitRevert from other-operations.js for centralized handler imports.
    handleGitRevert,
  • Import of handleGitRevert from other-operations.js.
    handleGitRevert,
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It mentions reverting but doesn't disclose whether this is destructive, requires specific permissions, affects remote branches, or handles conflicts. Key traits like safety and side effects are omitted.

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 directly states the tool's purpose without redundancy. It is front-loaded and wastes no words, making it easy to parse quickly.

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?

For a Git revert tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral outcomes (e.g., whether it creates a new commit, handles merges), error conditions, or return values, leaving significant gaps for agent understanding.

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 parameters are well-documented in the schema. The description adds no additional meaning beyond implying a 'commit or state' relates to the 'commit' parameter, but doesn't clarify semantics like format examples or the effect of 'no_commit'. Baseline 3 is appropriate given schema coverage.

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 verb ('revert') and resource ('current branch'), specifying the action of returning to a previous commit or state. It distinguishes from siblings like git_reset (which has different semantics) by focusing on revert operations, though it doesn't explicitly contrast with alternatives.

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 like git_reset or git_checkout_branch. The description lacks context about prerequisites (e.g., clean working directory) or typical scenarios for reverting versus other Git operations, leaving usage unclear.

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/bsreeram08/git-commands-mcp'

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