Skip to main content
Glama
ceshine

Git Prompts MCP Server

by ceshine

git-cached-diff

Compare staged changes against the last commit to review modifications before finalizing them in Git.

Instructions

Get a diff between the files in the staging area (the index) and the HEAD

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Registration of the 'git-cached-diff' tool using FastMCP's @APP.tool decorator, linking to the handler.
    @APP.tool(
        name="git-cached-diff",
        description="Get a diff between the files in the staging area (the index) and the HEAD",
    )
    async def git_cached_diff_tool() -> list[dict[str, str]]:
        return await GIT_METHOD_COLLETION.get_cached_diff_data()
  • Core handler method in GitMethodCollection that executes the git-cached-diff logic: computes staged changes diff (HEAD vs index).
    async def get_cached_diff_data(self) -> list[dict[str, str]]:
        diff_results = _get_diff_results(self.repo.head.commit, None, self.excludes)
        return _get_diff_results_as_list_of_dict(diff_results)
  • Helper function to retrieve and filter git diff results between commits or index.
    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
  • Helper to convert git diff results to structured list of dictionaries for output.
    def _get_diff_results_as_list_of_dict(diff_results: list[git.Diff]) -> list[dict[str, str]]:
        return [
            {
                "a_path": item.a_path or "New Addition",
                "b_path": item.b_path or "Deleted",
                "diff": cast(bytes, item.diff).decode("utf-8"),
            }
            for item in 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 of behavioral disclosure. It states what the tool does but does not describe behavioral traits such as output format, error handling, or side effects. This is a significant gap for a tool with no annotation coverage.

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 tool's purpose without unnecessary details. It is front-loaded and wastes no words, making it highly concise and well-structured.

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 has no parameters, an output schema exists, and no annotations, the description covers the basic purpose adequately. However, it lacks details on behavioral aspects like output format or usage context, which could be more complete despite the simplicity of the tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and schema description coverage is 100%, so no parameter information is needed. The description appropriately does not discuss parameters, which is sufficient for a parameterless tool, earning a baseline score of 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Get a diff') and the resources involved ('files in the staging area (the index) and the HEAD'), making the purpose explicit. It distinguishes from sibling tools like git-diff by specifying the staging area vs. HEAD comparison, which is a precise scope.

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

Usage Guidelines4/5

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

The description implies usage context by specifying 'staging area (the index) vs. HEAD', which helps differentiate it from general git-diff. However, it does not explicitly state when to use this tool versus alternatives like git-diff or git-commit-messages, nor does it provide exclusions or prerequisites.

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