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
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | ||
| context_lines | No |
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
- src/git/src/mcp_server_git/server.py:297-301 (registration)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(), ),