Skip to main content
Glama

git_log

Retrieve commit logs from a specified Git repository to track changes, view history, and monitor activity. Utilize the max_count parameter to limit displayed results for focused insights.

Instructions

Shows the commit logs

Input Schema

NameRequiredDescriptionDefault
max_countNo
repo_pathYes

Input Schema (JSON Schema)

{ "properties": { "max_count": { "default": 10, "title": "Max Count", "type": "integer" }, "repo_path": { "title": "Repo Path", "type": "string" } }, "required": [ "repo_path" ], "title": "GitLog", "type": "object" }

Implementation Reference

  • The git_log handler function that retrieves the most recent commits from the repository, formats them into log entries, and returns them as a list of strings.
    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 model defining the input schema for the git_log tool, including repository path and optional max_count.
    class GitLog(BaseModel): repo_path: str max_count: int = 10
  • Registration of the git_log tool in the server's list_tools method, specifying name, description, and input schema.
    Tool( name=GitTools.LOG, description="Shows the commit logs", inputSchema=GitLog.schema(), ),
  • Enum value defining the tool name 'git_log' within GitTools.
    LOG = "git_log"
  • Dispatcher in call_tool that invokes the git_log handler and formats the response as TextContent.
    case GitTools.LOG: log = git_log(repo, arguments.get("max_count", 10)) return [TextContent( type="text", text="Commit history:\n" + "\n".join(log) )]

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