Skip to main content
Glama
ffpy

GitLab MCP Code Review

by ffpy

compare_versions

Compare two GitLab commits, branches, or tags to identify differences between versions for code review and change analysis.

Instructions

Compare two commits/branches/tags to see the differences between them.

Args:
    project_id: The GitLab project ID or URL-encoded path
    from_sha: The source commit/branch/tag
    to_sha: The target commit/branch/tag
Returns:
    Dict containing the comparison information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
from_shaYes
to_shaYes

Implementation Reference

  • The handler function for the 'compare_versions' tool. It is registered via the @mcp.tool() decorator. Fetches the GitLab project and uses repository_compare to get differences between two SHAs.
    def compare_versions(ctx: Context, project_id: str, from_sha: str, to_sha: str) -> Dict[str, Any]:
        """
        Compare two commits/branches/tags to see the differences between them.
        
        Args:
            project_id: The GitLab project ID or URL-encoded path
            from_sha: The source commit/branch/tag
            to_sha: The target commit/branch/tag
        Returns:
            Dict containing the comparison information
        """
        gl = ctx.request_context.lifespan_context
        project = gl.projects.get(project_id)
        
        try:
            result = project.repository_compare(from_sha, to_sha)
        except Exception as e:
            logger.error(f"Failed to compare {from_sha} and {to_sha}: {e}")
            result = {}
        
        return result

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/ffpy/gitlab-mcp-code-review'

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