Skip to main content
Glama
ceshine

Git Prompts MCP Server

by ceshine

git-diff

Compare Git changes between HEAD and an ancestor branch or commit to analyze code modifications for review or documentation.

Instructions

Get a diff between the HEAD and the ancestor branch or commit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ancestorYesThe ancestor commit hash or branch name

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler function for the 'git-diff' tool. It validates the ancestor input and delegates to GitMethodCollection.get_diff_data to retrieve and format the diff.
        ancestor: str = Field(..., description="The ancestor commit hash or branch name"),
    ) -> list[dict[str, str]]:
        return await GIT_METHOD_COLLETION.get_diff_data(ancestor)
  • Registers the 'git-diff' tool with FastMCP server, including name and description.
        name="git-diff",
        description="Get a diff between the HEAD and the ancestor branch or commit",
    )
    async def git_diff_tool(
  • Pydantic schema definition for the 'ancestor' input parameter of the git-diff tool.
    ) -> list[dict[str, str]]:
  • Helper method in GitMethodCollection that computes git diff between ancestor commit and HEAD, applies excludes, and returns formatted list of dicts.
    async def get_diff_data(self, ancestor: str) -> list[dict[str, str]]:
        if not ancestor:
            raise ValueError("Ancestor argument required")
        diff_results = _get_diff_results(self.repo.commit(ancestor), self.repo.head.commit, self.excludes)
        return _get_diff_results_as_list_of_dict(diff_results)
  • Core helper function that generates git diff results between two commits (or index), filters by exclude patterns.
    def _get_diff_results(
        source_commit: git.Commit, target_commit: git.Commit | None, excludes: list[str]
    ) -> list[git.Diff]:
        if target_commit is None:
            # Note: source_commit.diff() compares source with the index (staged changes)
            #       source_commit.diff(None) compares source with the working tree
            diff_results = source_commit.diff(create_patch=True)
        else:
            diff_results = source_commit.diff(target_commit, create_patch=True)
    
        for exclude_pattern in excludes:
            diff_results = [
                item
                for item in diff_results
                if not fnmatch(item.a_path or "", exclude_pattern) and not fnmatch(item.b_path or "", exclude_pattern)
            ]
        return diff_results
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool gets a diff, implying a read-only operation, but doesn't disclose behavioral traits like whether it requires Git repository access, error handling, output format details, or performance considerations. The description is minimal and lacks context beyond the basic action.

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, clear sentence that efficiently conveys the core functionality without unnecessary words. It's front-loaded and appropriately sized for the tool's purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (simple diff operation), high schema coverage, and presence of an output schema, the description is minimally adequate. However, with no annotations and lack of usage guidance, it leaves gaps in understanding the tool's full context and behavior.

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?

The input schema has 100% description coverage, with the 'ancestor' parameter well-documented. The description adds no additional meaning beyond the schema, such as examples or constraints, but since the schema is comprehensive, the baseline score of 3 is appropriate.

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 ('Get a diff') and the target ('between the HEAD and the ancestor branch or commit'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'git-cached-diff' or 'git-commit-messages', which might have overlapping or related functionality in a Git context.

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. It doesn't mention sibling tools, prerequisites, or specific contexts for usage, leaving the agent to infer based on tool names alone.

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/ceshine/git-prompts-mcp-server'

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