Skip to main content
Glama
bsreeram08

Git Repo Browser MCP

git_commit_history

Retrieve and filter commit history from Git repositories by branch, author, date range, or message content to track changes and analyze development activity.

Instructions

Get commit history for a branch with optional filtering.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_urlYesThe URL of the Git repository
branchNoThe branch to get history frommain
max_countNoMaximum number of commits to retrieve
authorNoFilter by author (optional)
sinceNoGet commits after this date (e.g., "1 week ago", "2023-01-01")
untilNoGet commits before this date (e.g., "yesterday", "2023-12-31")
grepNoFilter commits by message content (optional)

Implementation Reference

  • The core handler function that implements the git_commit_history tool. It clones the repository if needed, applies filters to git log, formats commit data, and returns JSON response or error.
    export async function handleGitCommitHistory({
      repo_url,
      branch = "main",
      max_count = 10,
      author,
      since,
      until,
      grep,
    }) {
      try {
        const repoPath = await cloneRepo(repo_url);
        const git = simpleGit(repoPath);
    
        // Prepare log options
        const logOptions = {
          maxCount: max_count,
        };
    
        if (author) {
          logOptions["--author"] = author;
        }
    
        if (since) {
          logOptions["--since"] = since;
        }
    
        if (until) {
          logOptions["--until"] = until;
        }
    
        if (grep) {
          logOptions["--grep"] = grep;
        }
    
        // Make sure branch exists locally
        const branches = await git.branch();
        if (!branches.all.includes(branch)) {
          await git.fetch("origin", branch);
        }
    
        // Get commit history
        const log = await git.log(logOptions, branch);
    
        // Format the commits
        const commits = log.all.map((commit) => ({
          hash: commit.hash,
          author: commit.author_name,
          email: commit.author_email,
          date: commit.date,
          message: commit.message,
          body: commit.body || "",
        }));
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({ commits }, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                { error: `Failed to get commit history: ${error.message}` },
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
    }
  • Tool schema registration in the server's toolsList array, defining the name, description, and inputSchema with parameters matching the handler.
      name: "git_commit_history",
      description: "Get commit history for a branch with optional filtering.",
      inputSchema: {
        type: "object",
        properties: {
          repo_url: {
            type: "string",
            description: "The URL of the Git repository",
          },
          branch: {
            type: "string",
            description: "The branch to get history from",
            default: "main",
          },
          max_count: {
            type: "integer",
            description: "Maximum number of commits to retrieve",
            default: 10,
          },
          author: {
            type: "string",
            description: "Filter by author (optional)",
          },
          since: {
            type: "string",
            description:
              'Get commits after this date (e.g., "1 week ago", "2023-01-01")',
          },
          until: {
            type: "string",
            description:
              'Get commits before this date (e.g., "yesterday", "2023-12-31")',
          },
          grep: {
            type: "string",
            description: "Filter commits by message content (optional)",
          },
        },
        required: ["repo_url"],
      },
    },
  • src/server.js:903-903 (registration)
    Registration of the git_commit_history tool name mapping to the handleGitCommitHistory handler function in the server's handlersMap object.
    git_commit_history: handleGitCommitHistory,
  • Re-export of the handleGitCommitHistory function from commit-operations.js in the handlers index module, used by server.js.
    import {
      handleGitCommitHistory,
      handleGitCommitsDetails,
      handleGitCommit,
      handleGitTrack,
    } from "./commit-operations.js";
  • src/server.js:11-38 (registration)
    Import of handleGitCommitHistory from handlers/index.js into the main server file for use in handlersMap.
      handleGitDirectoryStructure,
      handleGitReadFiles,
      handleGitBranchDiff,
      handleGitCommitHistory,
      handleGitCommitsDetails,
      handleGitLocalChanges,
      handleGitSearchCode,
      handleGitCommit,
      handleGitTrack,
      handleGitCheckoutBranch,
      handleGitDeleteBranch,
      handleGitMergeBranch,
      handleGitPush,
      handleGitPull,
      handleGitStash,
      handleGitCreateTag,
      handleGitRebase,
      handleGitConfig,
      handleGitReset,
      handleGitArchive,
      handleGitAttributes,
      handleGitBlame,
      handleGitClean,
      handleGitHooks,
      handleGitLFS,
      handleGitLFSFetch,
      handleGitRevert,
    } from "./handlers/index.js";
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It states the tool 'gets' commit history, implying a read-only operation, but doesn't clarify whether this requires authentication, has rate limits, returns paginated results, or what format the output takes. For a tool with 7 parameters and no annotations, this leaves significant behavioral gaps unaddressed.

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 purpose ('Get commit history for a branch') and adds essential context ('with optional filtering'). There's no wasted verbiage, and every word earns its place, making it highly concise and well-structured for quick comprehension.

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 tool's complexity (7 parameters, no output schema, and no annotations), the description is incomplete. It doesn't explain return values, error conditions, authentication needs, or how filtering parameters interact. For a read operation with multiple optional filters, more context is needed to guide effective use, especially without annotations to cover 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 all parameters are documented in the schema. The description adds minimal value beyond the schema by mentioning 'optional filtering,' which hints at parameters like 'author,' 'since,' 'until,' and 'grep,' but doesn't provide additional semantic context. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't significantly enhance parameter understanding.

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 ('Get') and resource ('commit history') with scope ('for a branch'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'git_commits_details' or 'git_commit', which might have overlapping functionality. The description is specific about what it retrieves but lacks sibling distinction.

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

Usage Guidelines3/5

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

The description mentions 'optional filtering' which implies usage when filtering is needed, but it doesn't provide explicit guidance on when to use this tool versus alternatives like 'git_commits_details' or 'git_commit'. There's no mention of prerequisites, exclusions, or specific scenarios where this tool is preferred over siblings, leaving usage context implied rather than clearly defined.

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