Skip to main content
Glama

git_log

View commit history in Git repositories to track changes and review project evolution. Specify repository path and optional limit for log entries.

Instructions

Shows the commit logs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYes
max_countNo

Implementation Reference

  • The handler function that retrieves the git commit history using gitpython, formats log entries with commit hash, author, date, and message, or returns an error message.
    def git_log(repo: git.Repo, max_count: int = 10) -> list[str]: try: commits = list(repo.iter_commits('HEAD', max_count=max_count)) log_entries = [] for commit in commits: log_entries.append( f"commit {commit.hexsha}\n" f"Author: {commit.author.name} <{commit.author.email}>\n" f"Date: {commit.committed_datetime}\n\n" f" {commit.message.strip()}\n" ) return log_entries except Exception as e: return [f"Error running git log: {str(e)}"]
  • Pydantic BaseModel defining the input parameters for the git_log tool: repo_path (required string) and max_count (optional int default 10).
    class GitLog(BaseModel): repo_path: str max_count: int = 10
  • Registers the git_log tool in the MCP server with name from GitTools.LOG ("git_log"), description, and input schema from GitLog model.
    Tool( name=GitTools.LOG, description="Shows the commit logs", inputSchema=GitLog.schema(), ),
  • Enum value in GitTools defining the tool name "git_log".
    LOG = "git_log"
  • Tool dispatcher in call_tool() that invokes the git_log handler and formats the response as TextContent for MCP protocol.
    case GitTools.LOG: log = git_log(repo, arguments.get("max_count", 10)) return [TextContent( type="text", text="Commit history:\n" + "\n".join(log) )]

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