git_show
Review commit details and contents on the MCP Git Server by specifying the repository path and revision for better insight into changes.
Instructions
Shows the contents of a commit
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | ||
| revision | Yes |
Implementation Reference
- src/mcp_server_git/server.py:136-152 (handler)Core handler function for the 'git_show' tool that retrieves commit details (hash, author, date, message) and generates a unified diff patch against the parent commit or an empty tree for the initial commit.def git_show(repo: git.Repo, revision: str) -> str: commit = repo.commit(revision) output = [ f"Commit: {commit.hexsha}\n" f"Author: {commit.author}\n" f"Date: {commit.authored_datetime}\n" f"Message: {commit.message}\n" ] if commit.parents: parent = commit.parents[0] diff = parent.diff(commit, create_patch=True) else: diff = commit.diff(git.NULL_TREE, create_patch=True) for d in diff: output.append(f"\n--- {d.a_path}\n+++ {d.b_path}\n") output.append(d.diff.decode('utf-8')) return "".join(output)
- src/mcp_server_git/server.py:56-58 (schema)Pydantic BaseModel defining the input schema for the git_show tool, with fields repo_path (str) and revision (str).class GitShow(BaseModel): repo_path: str revision: str
- src/mcp_server_git/server.py:221-225 (registration)Registration of the 'git_show' tool (via GitTools.SHOW = 'git_show') in the list_tools() coroutine, providing name, description, and input schema.Tool( name=GitTools.SHOW, description="Shows the contents of a commit", inputSchema=GitShow.schema(), ),
- src/mcp_server_git/server.py:352-357 (registration)Dispatch handler in the call_tool() coroutine that invokes the git_show function with repo and revision from arguments, returning the result as TextContent.case GitTools.SHOW: result = git_show(repo, arguments["revision"]) return [TextContent( type="text", text=result )]
- src/mcp_server_git/server.py:74-74 (helper)Enum constant defining the tool name 'git_show' within GitTools.SHOW = "git_show"