git_diff_staged
View staged changes in a Git repository to review modifications before committing. Simplifies tracking and verifying updates for better version control management.
Instructions
Shows changes that are staged for commit
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes |
Implementation Reference
- src/mcp_server_git/server.py:83-84 (handler)The handler function that executes the core logic of the git_diff_staged tool, returning the diff of staged changes using gitpython's Repo.git.diff with --cached option.def git_diff_staged(repo: git.Repo) -> str: return repo.git.diff("--cached")
- src/mcp_server_git/server.py:25-26 (schema)Pydantic BaseModel defining the input schema for the git_diff_staged tool, requiring a repo_path.class GitDiffStaged(BaseModel): repo_path: str
- src/mcp_server_git/server.py:181-185 (registration)Registration of the 'git_diff_staged' tool within the list_tools() function, specifying name, description, and input schema.Tool( name=GitTools.DIFF_STAGED, description="Shows changes that are staged for commit", inputSchema=GitDiffStaged.schema(), ),
- src/mcp_server_git/server.py:66-66 (registration)Enum constant defining the tool name 'git_diff_staged' within GitTools.DIFF_STAGED = "git_diff_staged"
- src/mcp_server_git/server.py:292-297 (helper)Usage of the git_diff_staged handler within the main @server.call_tool() dispatcher, formatting and returning the result as TextContent.case GitTools.DIFF_STAGED: diff = git_diff_staged(repo) return [TextContent( type="text", text=f"Staged changes:\n{diff}" )]