Skip to main content
Glama
bsreeram08

Git Repo Browser MCP

git_commits_details

Retrieve detailed commit information including full messages and diffs from Git repositories, with filtering by branch, date, author, or content.

Instructions

Get detailed information about commits including full messages and diffs.

Input Schema

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

Implementation Reference

  • Main handler function for git_commits_details tool. Clones repository, fetches detailed commit logs using simpleGit, optionally retrieves diffs and changed files for each commit, applies filters (author, date, grep), and returns formatted JSON response.
    export async function handleGitCommitsDetails({
      repo_url,
      branch = "main",
      max_count = 10,
      include_diff = false,
      author,
      since,
      until,
      grep,
    }) {
      try {
        const repoPath = await cloneRepo(repo_url);
        const git = simpleGit(repoPath);
    
        // Ensure branch exists locally
        const branches = await git.branch();
        if (!branches.all.includes(branch)) {
          await git.fetch("origin", branch);
        }
    
        // Prepare log options with full details
        const logOptions = {
          maxCount: max_count,
          "--format": "fuller", // Get more detailed commit info
        };
    
        if (author) {
          logOptions["--author"] = author;
        }
    
        if (since) {
          logOptions["--since"] = since;
        }
    
        if (until) {
          logOptions["--until"] = until;
        }
    
        if (grep) {
          logOptions["--grep"] = grep;
        }
    
        // Get commit history with full details
        const log = await git.log(logOptions, branch);
    
        // Enhance with additional details
        const commitsDetails = [];
    
        for (const commit of log.all) {
          const commitDetails = {
            hash: commit.hash,
            author: commit.author_name,
            author_email: commit.author_email,
            committer: commit.committer_name,
            committer_email: commit.committer_email,
            date: commit.date,
            message: commit.message,
            body: commit.body || "",
            refs: commit.refs,
          };
    
          // Get the commit diff if requested
          if (include_diff) {
            if (commit.parents && commit.parents.length > 0) {
              // For normal commits with parents
              const diff = await git.diff([`${commit.hash}^..${commit.hash}`]);
              commitDetails.diff = diff;
            } else {
              // For initial commits with no parents
              const diff = await git.diff([
                "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
                commit.hash,
              ]);
              commitDetails.diff = diff;
            }
    
            // Get list of changed files
            const showResult = await git.show([
              "--name-status",
              "--oneline",
              commit.hash,
            ]);
    
            // Parse the changed files from the result
            const fileLines = showResult
              .split("\n")
              .slice(1) // Skip the first line (commit summary)
              .filter(Boolean); // Remove empty lines
    
            commitDetails.changed_files = fileLines
              .map((line) => {
                const match = line.match(/^([AMDTRC])\s+(.+)$/);
                if (match) {
                  return {
                    status: match[1],
                    file: match[2],
                  };
                }
                return null;
              })
              .filter(Boolean);
          }
    
          commitsDetails.push(commitDetails);
        }
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  commits: commitsDetails,
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                { error: `Failed to get commit details: ${error.message}` },
                null,
                2
              ),
            },
          ],
          isError: true,
        };
      }
    }
  • MCP tool schema definition for 'git_commits_details', including name, description, and detailed inputSchema with parameters, types, defaults, and required fields.
    {
      name: "git_commits_details",
      description:
        "Get detailed information about commits including full messages and diffs.",
      inputSchema: {
        type: "object",
        properties: {
          repo_url: {
            type: "string",
            description: "The URL of the Git repository",
          },
          branch: {
            type: "string",
            description: "The branch to get commits from",
            default: "main",
          },
          max_count: {
            type: "integer",
            description: "Maximum number of commits to retrieve",
            default: 10,
          },
          include_diff: {
            type: "boolean",
            description: "Whether to include the commit diffs",
            default: false,
          },
          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")',
          },
          author: {
            type: "string",
            description: "Filter by author (optional)",
          },
          grep: {
            type: "string",
            description: "Filter commits by message content (optional)",
          },
        },
        required: ["repo_url"],
      },
    },
  • src/server.js:898-927 (registration)
    Registration of tool handlers in the handlersMap object, mapping 'git_commits_details' to the handleGitCommitsDetails function for dynamic tool execution.
    this.handlersMap = {
      // Primary handlers
      git_directory_structure: handleGitDirectoryStructure,
      git_read_files: handleGitReadFiles,
      git_branch_diff: handleGitBranchDiff,
      git_commit_history: handleGitCommitHistory,
      git_commits_details: handleGitCommitsDetails,
      git_local_changes: handleGitLocalChanges,
      git_search_code: handleGitSearchCode,
      git_commit: handleGitCommit,
      git_track: handleGitTrack,
      git_checkout_branch: handleGitCheckoutBranch,
      git_delete_branch: handleGitDeleteBranch,
      git_merge_branch: handleGitMergeBranch,
      git_push: handleGitPush,
      git_pull: handleGitPull,
      git_stash: handleGitStash,
      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,
    };
  • Import of handleGitCommitsDetails from commit-operations.js into the handlers index for re-export to server.js.
      handleGitCommitHistory,
      handleGitCommitsDetails,
      handleGitCommit,
      handleGitTrack,
    } from "./commit-operations.js";
  • Re-export of handleGitCommitsDetails from handlers/index.js, making it available for import in server.js.
    handleGitCommitHistory,
    handleGitCommitsDetails,
    handleGitCommit,
    handleGitTrack,
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 retrieving 'detailed information' but fails to specify critical behaviors like whether this is a read-only operation, if it requires authentication, rate limits, pagination handling, or error conditions. For a tool with 8 parameters and no annotation coverage, this is a significant gap.

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 with zero waste. It's appropriately sized and front-loaded with the core purpose, 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?

Given the tool's complexity (8 parameters, no output schema, no annotations), the description is incomplete. It doesn't address behavioral aspects like safety, performance, or error handling, and provides minimal guidance on usage context. For a data retrieval tool with filtering options, more context about limitations or typical use cases would be helpful.

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 already documents all 8 parameters thoroughly. The description adds minimal value beyond the schema by mentioning 'full messages and diffs' (hinting at include_diff parameter), but doesn't provide additional syntax, format details, or usage examples. Baseline 3 is appropriate when 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 tool's purpose with a specific verb ('Get') and resource ('detailed information about commits'), including what information is retrieved ('full messages and diffs'). It distinguishes from siblings like git_commit_history by specifying 'detailed' information, though it doesn't explicitly contrast with all similar tools.

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_commit_history or git_branch_diff. It lacks explicit when/when-not instructions or named alternatives, leaving usage context implied at best.

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