git_diff
Compare differences between branches or commits in a Git repository to analyze changes and identify updates efficiently using the MCP Git Server.
Instructions
Shows differences between branches or commits
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | ||
| target | Yes |
Input Schema (JSON Schema)
{
"properties": {
"repo_path": {
"title": "Repo Path",
"type": "string"
},
"target": {
"title": "Target",
"type": "string"
}
},
"required": [
"repo_path",
"target"
],
"title": "GitDiff",
"type": "object"
}
Implementation Reference
- src/mcp_server_git/server.py:299-304 (handler)Execution handler for the 'git_diff' tool within the call_tool method, invoking the git_diff helper and formatting the 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: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)Tool registration for 'git_diff' in the list_tools handler, specifying 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:86-87 (helper)Helper function implementing the core git diff logic using dulwich repo.git.diff(target).def git_diff(repo: git.Repo, target: str) -> str: return repo.git.diff(target)