git_show
Display commit contents to review changes and metadata in Git repositories. Use this tool to examine specific revisions and understand modifications made.
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)The handler function implementing git_show tool logic: displays commit details (hash, author, date, message) and the diff against parent or from empty tree.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, requiring repo_path and revision.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 handler, including 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/calling logic in call_tool handler that invokes the git_show function with repo and revision argument.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 value in GitTools defining the tool name 'git_show' used in registration and dispatch.SHOW = "git_show"