Skip to main content
Glama

GitLab MCP Code Review

by ffpy

compare_versions

Compare commits, branches, or tags to identify differences between code versions in GitLab projects 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

NameRequiredDescriptionDefault
project_idYes
from_shaYes
to_shaYes

Input Schema (JSON Schema)

{ "properties": { "from_sha": { "title": "From Sha", "type": "string" }, "project_id": { "title": "Project Id", "type": "string" }, "to_sha": { "title": "To Sha", "type": "string" } }, "required": [ "project_id", "from_sha", "to_sha" ], "type": "object" }

Implementation Reference

  • The main handler function for the 'compare_versions' tool. It is decorated with @mcp.tool(), which handles both registration and schema inference from the function signature and docstring. The function fetches the GitLab project and performs a repository compare between the given SHAs using the GitLab API.
    @mcp.tool() 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