Skip to main content
Glama

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
NameRequiredDescriptionDefault
repo_pathYes
revisionYes

Implementation Reference

  • 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)
  • 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
  • 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(), ),
  • 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 )]
  • Enum constant defining the tool name 'git_show' within GitTools.
    SHOW = "git_show"

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/martinsky999/mcp-git-py'

If you have feedback or need assistance with the MCP directory API, please join our Discord server