Skip to main content
Glama

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";

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