Skip to main content
Glama
MementoRC

MCP Git Server

by MementoRC

git_log

View commit logs for Git repositories to track changes, filter by count, and customize output format, enabling efficient version control management.

Instructions

Shows the commit logs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNo
graphNo
max_countNo
onelineNo
repo_pathYes

Implementation Reference

  • Core handler function that executes `git log` using GitPython Repo.git.log with parameters max_count, oneline, graph, format_str.
    def git_log(
        repo: Repo,
        max_count: int = 10,
        oneline: bool = False,
        graph: bool = False,
        format_str: str | None = None,  # Renamed from 'format'
    ) -> str:
        """Get commit history with formatting options"""
        try:
            args = []
    
            if max_count:
                args.extend(["-n", str(max_count)])
    
            if oneline:
                args.append("--oneline")
            elif format_str:  # Use format_str
                args.extend(["--pretty=format:" + format_str])
    
            if graph:
                args.append("--graph")
    
            # Get commit log
            log_output = repo.git.log(*args)
    
            if not log_output.strip():
                return "No commits found in repository"
    
            return log_output
    
        except GitCommandError as e:
            return f"❌ Log failed: {str(e)}"
        except Exception as e:
            return f"❌ Log error: {str(e)}"
  • Pydantic model defining input schema for git_log tool: repo_path (required), max_count (default 10), oneline, graph, format.
    class GitLog(BaseModel):
        repo_path: str
        max_count: int = 10
        oneline: bool = False
        graph: bool = False
        format: str | None = None
  • Registers the git_log tool in the ToolRegistry with name 'git_log', GitLog schema, placeholder handler (later overridden), requires repo.
        name=GitTools.LOG,
        category=ToolCategory.GIT,
        description="Show the commit logs",
        schema=GitLog,
        handler=placeholder_handler,
        requires_repo=True,
    ),
  • Maps 'git_log' tool name to wrapper handler created by _create_git_handler, which loads Repo from repo_path and calls git_log from operations.py with extra args.
            git_log,
            requires_repo=True,
            extra_args=["max_count", "oneline", "graph", "format"],
        ),
        "git_create_branch": self._create_git_handler(
            git_create_branch,
            requires_repo=True,
            extra_args=["branch_name", "base_branch"],
        ),
        "git_checkout": self._create_git_handler(
            git_checkout, requires_repo=True, extra_args=["branch_name"]
        ),
        "git_show": self._create_git_handler(
            git_show, requires_repo=True, extra_args=["revision"]
        ),
        "git_init": self._create_git_init_handler(git_init),
        "git_push": self._create_git_handler(
            git_push,
            requires_repo=True,
            extra_args=["remote", "branch", "set_upstream", "force"],
        ),
        "git_pull": self._create_git_handler(
            git_pull, requires_repo=True, extra_args=["remote", "branch"]
        ),
        "git_diff_branches": self._create_git_handler(
            git_diff_branches,
            requires_repo=True,
            extra_args=["base_branch", "compare_branch"],
        ),
        "git_rebase": self._create_git_handler(
            git_rebase,
            requires_repo=True,
            extra_args=["target_branch"],
        ),
        "git_merge": self._create_git_handler(
            git_merge,
            requires_repo=True,
            extra_args=["source_branch", "strategy", "message"],
        ),
        "git_cherry_pick": self._create_git_handler(
            git_cherry_pick,
            requires_repo=True,
            extra_args=["commit_hash", "no_commit"],
        ),
        "git_abort": self._create_git_handler(
            git_abort, requires_repo=True, extra_args=["operation"]
        ),
        "git_continue": self._create_git_handler(
            git_continue, requires_repo=True, extra_args=["operation"]
        ),
    }
  • Protected wrapper for git_log that validates repository binding and remote integrity before calling core git_log.
    async def protected_git_log(self, repo_path: str, max_count: int = 10) -> str:
        """Git log with repository binding protection."""
        validated_path = await self._validate_and_prepare_operation(repo_path)
        repo = Repo(validated_path)
        return git_log(repo, max_count)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Shows' implies a read-only operation, but it doesn't specify output format (e.g., text, structured data), pagination behavior (handled by max_count default), or potential side effects (e.g., if it requires network access for remote repos). This leaves gaps in understanding how the tool behaves beyond basic functionality.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence ('Shows the commit logs') that gets straight to the point with no wasted words. It's appropriately sized for a basic tool, though it could be more informative without sacrificing brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (5 parameters, no annotations, no output schema), the description is incomplete. It doesn't cover parameter meanings, output expectations, or behavioral nuances. While it states the core purpose, it lacks details needed for effective use, especially compared to sibling tools in a Git context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate but adds no parameter information. It doesn't explain what parameters like 'format', 'graph', or 'oneline' do, their expected values, or how 'repo_path' is used. With 5 parameters (1 required) and no schema descriptions, this is inadequate, though it slightly avoids a score of 1 by not being misleading.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Shows the commit logs' clearly states the verb ('shows') and resource ('commit logs'), making the purpose understandable. However, it lacks specificity about what 'commit logs' entail (e.g., history, metadata) and doesn't distinguish it from sibling tools like git_show or git_diff, which also display commit-related information.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't explain when git_log is preferable over git_show for viewing commit details or how it differs from git_status for repository state. The description offers no context about prerequisites, such as needing an initialized repository.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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/MementoRC/mcp-git'

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