Skip to main content
Glama
modelcontextprotocol

git MCP server

Official

git_diff_unstaged

Read-onlyIdempotent

View uncommitted changes in your working directory that are not yet staged for Git. Specify a repository path and optional context lines to see diff output.

Instructions

Shows changes in the working directory that are not yet staged

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYes
context_linesNo

Implementation Reference

  • The core handler function for git_diff_unstaged - runs 'git diff --unified=<context_lines>' to show unstaged changes in the working directory.
    def git_diff_unstaged(repo: git.Repo, context_lines: int = DEFAULT_CONTEXT_LINES) -> str:
        return repo.git.diff(f"--unified={context_lines}")
  • Pydantic model (schema) defining the input parameters for git_diff_unstaged: repo_path (str) and optional context_lines (int, default=3).
    class GitDiffUnstaged(BaseModel):
        repo_path: str
        context_lines: int = DEFAULT_CONTEXT_LINES
  • Tool registration in the list_tools() function, declaring the tool name (git_diff_unstaged), description, input schema from GitDiffUnstaged, and annotations marking it as read-only/idempotent.
    Tool(
        name=GitTools.DIFF_UNSTAGED,
        description="Shows changes in the working directory that are not yet staged",
        inputSchema=GitDiffUnstaged.model_json_schema(),
        annotations=ToolAnnotations(
            readOnlyHint=True,
            destructiveHint=False,
            idempotentHint=True,
            openWorldHint=False,
        ),
    ),
  • Tool invocation handler in call_tool() - dispatches 'git_diff_unstaged' name to call git_diff_unstaged() with the repo and context_lines argument.
    case GitTools.DIFF_UNSTAGED:
        diff = git_diff_unstaged(repo, arguments.get("context_lines", DEFAULT_CONTEXT_LINES))
        return [TextContent(
            type="text",
            text=f"Unstaged changes:\n{diff}"
        )]
  • Enum definition mapping the tool name string 'git_diff_unstaged' to the GitTools.DIFF_UNSTAGED member.
    class GitTools(str, Enum):
        STATUS = "git_status"
        DIFF_UNSTAGED = "git_diff_unstaged"
Behavior3/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true, so the safety profile is clear. The description adds no further behavioral context, but is consistent with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence that communicates the primary purpose. It is front-loaded but could incorporate more information without becoming verbose.

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 simplicity of the tool and existing annotations, the description is minimally adequate. However, it lacks parameter explanations and usage guidance, which would improve completeness for an agent.

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

Parameters2/5

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

With 0% schema description coverage, the description should explain the parameters. It does not mention repo_path or context_lines, relying solely on parameter names and titles. This is insufficient for correct invocation.

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 'Shows changes in the working directory that are not yet staged' uses a specific verb ('Shows') and resource ('changes') and clearly distinguishes from siblings like git_diff_staged.

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 does not explicitly state when to use this tool vs alternatives like git_diff or git_diff_staged. The purpose is implied by the tool name, but no explicit guidance is provided.

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/modelcontextprotocol/git'

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