Skip to main content
Glama
bsreeram08

Git Repo Browser MCP

git_rebase

Rebase a Git branch onto another branch or commit to integrate changes while maintaining a linear project history.

Instructions

Rebase the current branch onto another branch or commit.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYesThe path to the local Git repository
ontoYesBranch or commit to rebase onto
interactiveNoWhether to perform an interactive rebase

Implementation Reference

  • Main handler function that executes the git rebase logic using simpleGit library. Handles non-interactive rebases and returns formatted results or errors.
    /**
     * Handles git rebase operations
     * @param {string} repoPath - Path to the local repository
     * @param {string} onto - Branch or commit to rebase onto
     * @param {boolean} interactive - Whether to perform an interactive rebase
     * @returns {Object} - Rebase result
     */
    export async function handleGitRebase({
      repo_path,
      onto,
      interactive = false,
    }) {
      try {
        // For interactive rebase, we need to use exec as simple-git doesn't support it well
        if (interactive) {
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  { error: "Interactive rebase not supported through API" },
                  null,
                  2
                ),
              },
            ],
            isError: true,
          };
        }
    
        const git = simpleGit(repo_path);
        const rebaseResult = await git.rebase([onto]);
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  success: true,
                  message: `Rebased onto ${onto}`,
                  result: rebaseResult,
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  error: `Failed to rebase: ${error.message}`,
                  conflicts: error.git ? error.git.conflicts : null,
                },
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema and description for the git_rebase tool, defining parameters repo_path (required), onto (required), and interactive (optional boolean).
      name: "git_rebase",
      description: "Rebase the current branch onto another branch or commit.",
      inputSchema: {
        type: "object",
        properties: {
          repo_path: {
            type: "string",
            description: "The path to the local Git repository",
          },
          onto: {
            type: "string",
            description: "Branch or commit to rebase onto",
          },
          interactive: {
            type: "boolean",
            description: "Whether to perform an interactive rebase",
            default: false,
          },
        },
        required: ["repo_path", "onto"],
      },
    },
  • src/server.js:915-927 (registration)
    Registration of git_rebase handler in the central handlersMap object used for tool dispatching.
      git_create_tag: handleGitCreateTag,
      git_rebase: handleGitRebase,
      git_config: handleGitConfig,
      git_reset: handleGitReset,
      git_archive: handleGitArchive,
      git_attributes: handleGitAttributes,
      git_blame: handleGitBlame,
      git_clean: handleGitClean,
      git_hooks: handleGitHooks,
      git_lfs: handleGitLFS,
      git_lfs_fetch: handleGitLFSFetch,
      git_revert: handleGitRevert,
    };
  • Re-export of handleGitRebase from advanced-operations.js for centralized import in server.js.
    handleGitRebase,
    handleGitReset,
  • src/server.js:27-27 (registration)
    Import of handleGitRebase handler into server.js from handlers/index.js.
    handleGitRebase,
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 states the action but fails to mention critical traits: this is a destructive operation that rewrites commit history, requires careful handling to avoid data loss, and may involve conflict resolution. These omissions are significant 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 directly states the tool's purpose without any fluff. It is appropriately sized and front-loaded, making it easy for an agent 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 complex, destructive Git operation with no annotations and no output schema, the description is inadequate. It doesn't explain the rebase process, potential outcomes (e.g., conflicts, rewritten commits), or safety considerations, leaving the agent under-informed about critical behavioral aspects.

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 (repo_path, onto, interactive). The description adds no additional meaning beyond implying the 'onto' parameter's purpose, which is already clear from the schema. This meets the baseline for high 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 action ('rebase') and target ('current branch onto another branch or commit'), which is specific and unambiguous. However, it doesn't differentiate from sibling tools like git_merge_branch or git_reset, which also modify branch history, so it falls short of a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives like git_merge_branch or git_reset. It lacks context about prerequisites (e.g., clean working directory) or typical use cases (e.g., linearizing history before a pull request), leaving the agent with no usage direction.

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