Skip to main content
Glama

git_diff_staged

Review staged changes before committing to ensure accuracy and prevent unintended modifications in Git repositories.

Instructions

Shows changes that are staged for commit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYes
context_linesNo

Implementation Reference

  • Core handler function for 'git_diff_staged' tool that executes git diff --cached with unified context lines using gitpython.
    def git_diff_staged(repo: git.Repo, context_lines: int = DEFAULT_CONTEXT_LINES) -> str: return repo.git.diff(f"--unified={context_lines}", "--cached")
  • Pydantic input schema defining repo_path (required) and context_lines (optional, defaults to 3) for the git_diff_staged tool.
    class GitDiffStaged(BaseModel): repo_path: str context_lines: int = DEFAULT_CONTEXT_LINES
  • Tool registration in MCP server's list_tools() method, associating 'git_diff_staged' name with its description and input schema.
    Tool( name=GitTools.DIFF_STAGED, description="Shows changes that are staged for commit", inputSchema=GitDiffStaged.model_json_schema(), ),

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