Skip to main content
Glama
martinsky999

MCP Git Server

by martinsky999

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

Implementation Reference

  • 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)
  • Pydantic BaseModel defining the input schema for the git_show tool, requiring repo_path and revision.
    class GitShow(BaseModel):
        repo_path: str
        revision: str
  • 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(),
    ),
  • 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
        )]
  • Enum value in GitTools defining the tool name 'git_show' used in registration and dispatch.
    SHOW = "git_show"

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