git_diff
Compare changes between Git branches or commits to review modifications before merging or deploying code.
Instructions
Shows differences between branches or commits
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | ||
| target | Yes |
Implementation Reference
- src/mcp_server_git/server.py:86-88 (handler)Core handler function that computes the git diff against the specified target using repo.git.diff(target). Called by the MCP tool dispatcher.def git_diff(repo: git.Repo, target: str) -> str: return repo.git.diff(target)
- src/mcp_server_git/server.py:28-30 (schema)Pydantic input schema for the git_diff tool, defining repo_path and target parameters.class GitDiff(BaseModel): repo_path: str target: str
- src/mcp_server_git/server.py:186-190 (registration)Registration of the 'git_diff' tool (GitTools.DIFF) in the list_tools() method, including name, description, and input schema.Tool( name=GitTools.DIFF, description="Shows differences between branches or commits", inputSchema=GitDiff.schema(), ),
- src/mcp_server_git/server.py:299-304 (handler)MCP call_tool dispatcher case for git_diff: extracts target, calls git_diff helper, formats and returns TextContent response.case GitTools.DIFF: diff = git_diff(repo, arguments["target"]) return [TextContent( type="text", text=f"Diff with {arguments['target']}:\n{diff}" )]
- src/mcp_server_git/server.py:63-75 (helper)Enum definition providing the tool name constant GitTools.DIFF = "git_diff" used in registration and dispatch.class GitTools(str, Enum): STATUS = "git_status" DIFF_UNSTAGED = "git_diff_unstaged" DIFF_STAGED = "git_diff_staged" DIFF = "git_diff" COMMIT = "git_commit" ADD = "git_add" RESET = "git_reset" LOG = "git_log" CREATE_BRANCH = "git_create_branch" CHECKOUT = "git_checkout" SHOW = "git_show" INIT = "git_init"