Skip to main content
Glama
ceshine

Git Prompts MCP Server

by ceshine

git-commit-messages

Retrieve commit messages between a specified ancestor commit and the current HEAD to review changes and understand code evolution.

Instructions

Get commit messages between the ancestor and HEAD

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ancestorYesThe ancestor commit hash or branch name

Implementation Reference

  • Handler function for the 'git-commit-messages' tool, registered with @APP.tool. Delegates to GitMethodCollection for data retrieval.
    @APP.tool( name="git-commit-messages", description="Get commit messages between the ancestor and HEAD", ) async def git_commit_messages_tool( ancestor: str = Field(..., description="The ancestor commit hash or branch name"), ) -> list[dict]: return await GIT_METHOD_COLLETION.get_commit_messages_data(ancestor)
  • Core helper method in GitMethodCollection that fetches commit history using _get_commit_history and formats it as a list of dictionaries.
    async def get_commit_messages_data(self, ancestor: str) -> list[dict]: if not ancestor: raise ValueError("Ancestor argument required") try: commits = _get_commit_history(self.repo, ancestor) return _format_commit_history_as_json_obj(commits) except git.GitCommandError as e: raise ValueError(f"Error executing Git command: {str(e)}")
  • Utility function to retrieve the list of git commits between the given ancestor and HEAD.
    def _get_commit_history(repo: git.Repo, ancestor: str) -> list[git.Commit]: return list(repo.iter_commits(rev=f"{ancestor}..HEAD"))
  • Utility function to format commit objects into a JSON-friendly list of dictionaries with key details.
    def _format_commit_history_as_json_obj(commits: list[git.Commit]) -> list[dict]: return [ { "hexsha": commit.hexsha, "author": str(commit.author), "create_time": commit.authored_datetime.astimezone(timezone.utc).isoformat(), "message": str(commit.message).strip(), } for commit in commits ]
  • Explicit registration of the tool via FastMCP's @APP.tool decorator with the name 'git-commit-messages'.
    @APP.tool( name="git-commit-messages", description="Get commit messages between the ancestor and HEAD", ) async def git_commit_messages_tool( ancestor: str = Field(..., description="The ancestor commit hash or branch name"), ) -> list[dict]: return await GIT_METHOD_COLLETION.get_commit_messages_data(ancestor)

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/ceshine/git-prompts-mcp-server'

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