get_commit_details
Retrieve detailed commit information including code changes to analyze impact and understand actual work 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
| Name | Required | Description | Default |
|---|---|---|---|
| repo_name | No | Name of the repository (use 'default' for single repo or first repo) | |
| commit_hash | Yes | Commit hash (short or full) | |
| max_lines | No | Maximum lines of diff to return (default: 500) |
Implementation Reference
- The core handler function that executes the tool logic: runs 'git show --stat --format=fuller' on the specified commit in the repo to retrieve details including changes, limits output lines, and formats response.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}")]
- src/cv_resume_builder_mcp/server.py:157-179 (registration)Tool registration in list_tools(), including name, description, and input schema definition.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"] } ),
- src/cv_resume_builder_mcp/server.py:324-329 (registration)Dispatcher in @app.call_tool() that matches the tool name and invokes the handler function with parsed 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) )
- Input schema defining parameters: repo_name (optional), commit_hash (required), max_lines (optional 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"] }
- Instructional text in analyze_commits_impact function referencing the tool.all_output += f"\nUse 'get_commit_details' with a specific commit hash to see full code changes."