Skip to main content
Glama

get_commit_details

Retrieve detailed commit information including code changes to analyze impact and understand what was actually done in commits for CV/resume building.

Instructions

Get detailed commit information including code changes (diff) to analyze impact. Use this to understand what was actually done in commits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_nameNoName of the repository (use 'default' for single repo or first repo)
commit_hashYesCommit hash (short or full)
max_linesNoMaximum lines of diff to return (default: 500)

Implementation Reference

  • The main handler function that implements the 'get_commit_details' tool logic. It resolves the repository path, executes 'git show --stat --format=fuller' to retrieve commit details including stats and diff, limits the output lines if necessary, and returns the result as TextContent.
    async def get_commit_details(commit_hash: Optional[str], repo_name: str, max_lines: int) -> list[TextContent]:
        """Get detailed commit information including code changes (diff)."""
        if not commit_hash:
            return [TextContent(type="text", text="Error: commit_hash is required")]
        
        # Resolve repo
        if repo_name == "default" or not repo_name:
            repo_name = list(REPO_DICT.keys())[0] if REPO_DICT else "default"
        
        if repo_name not in REPO_DICT:
            available = ", ".join(REPO_DICT.keys())
            return [TextContent(
                type="text",
                text=f"Repository '{repo_name}' not found.\n\nAvailable repositories: {available}"
            )]
        
        repo_path = REPO_DICT[repo_name]
        
        try:
            # Get commit details
            cmd_show = [
                "git", "show",
                "--stat",
                "--format=fuller",
                commit_hash
            ]
            
            result = subprocess.run(
                cmd_show,
                cwd=repo_path,
                capture_output=True,
                text=True,
                check=True
            )
            
            output = result.stdout
            
            # Limit output if too long
            lines = output.split('\n')
            if len(lines) > max_lines:
                output = '\n'.join(lines[:max_lines])
                output += f"\n\n... (truncated, showing first {max_lines} lines)"
            
            return [TextContent(
                type="text",
                text=f"Commit Details from '{repo_name}':\n\n{output}"
            )]
        
        except subprocess.CalledProcessError as e:
            return [TextContent(type="text", text=f"Git error: {e.stderr}")]
  • The tool registration in list_tools(), defining the name, description, and input schema for 'get_commit_details'.
    Tool(
        name="get_commit_details",
        description="Get detailed commit information including code changes (diff) to analyze impact. Use this to understand what was actually done in commits.",
        inputSchema={
            "type": "object",
            "properties": {
                "repo_name": {
                    "type": "string",
                    "description": "Name of the repository (use 'default' for single repo or first repo)"
                },
                "commit_hash": {
                    "type": "string",
                    "description": "Commit hash (short or full)"
                },
                "max_lines": {
                    "type": "number",
                    "description": "Maximum lines of diff to return (default: 500)",
                    "default": 500
                }
            },
            "required": ["commit_hash"]
        }
    ),
  • The input schema defining parameters: repo_name (optional string), commit_hash (required string), max_lines (optional number, default 500).
    inputSchema={
        "type": "object",
        "properties": {
            "repo_name": {
                "type": "string",
                "description": "Name of the repository (use 'default' for single repo or first repo)"
            },
            "commit_hash": {
                "type": "string",
                "description": "Commit hash (short or full)"
            },
            "max_lines": {
                "type": "number",
                "description": "Maximum lines of diff to return (default: 500)",
                "default": 500
            }
        },
        "required": ["commit_hash"]
  • Dispatch handler in the main call_tool() function that routes calls to 'get_commit_details' and passes arguments.
    elif name == "get_commit_details":
        return await get_commit_details(
            arguments.get("commit_hash"),
            arguments.get("repo_name", "default"),
            arguments.get("max_lines", 500)
        )

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/eyaab/cv-resume-builder-mcp'

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