gitlab_compare_branches
Analyze differences between branches, tags, or commits in GitLab projects by specifying the project ID and comparison references to identify changes efficiently.
Instructions
Compare branches, tags or commits
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from | Yes | The commit SHA or branch name to compare from | |
| project_id | Yes | The ID or URL-encoded path of the project | |
| to | Yes | The commit SHA or branch name to compare to |
Input Schema (JSON Schema)
{
"properties": {
"from": {
"description": "The commit SHA or branch name to compare from",
"type": "string"
},
"project_id": {
"description": "The ID or URL-encoded path of the project",
"type": "string"
},
"to": {
"description": "The commit SHA or branch name to compare to",
"type": "string"
}
},
"required": [
"project_id",
"from",
"to"
],
"type": "object"
}
Implementation Reference
- The core handler function for gitlab_compare_branches that validates parameters and calls the GitLab API to compare two branches/tags/commits in a project.export const compareBranches: ToolHandler = async (params, context) => { const { project_id, from, to } = params.arguments || {}; if (!project_id || !from || !to) { throw new McpError(ErrorCode.InvalidParams, 'project_id, from, and to are required'); } const response = await context.axiosInstance.get( `/projects/${encodeURIComponent(String(project_id))}/repository/compare`, { params: { from, to } } ); return formatResponse(response.data); };
- src/utils/tools-data.ts:243-264 (schema)JSON schema defining the input parameters for the gitlab_compare_branches tool.{ name: 'gitlab_compare_branches', description: 'Compare branches, tags or commits', inputSchema: { type: 'object', properties: { project_id: { type: 'string', description: 'The ID or URL-encoded path of the project' }, from: { type: 'string', description: 'The commit SHA or branch name to compare from' }, to: { type: 'string', description: 'The commit SHA or branch name to compare to' } }, required: ['project_id', 'from', 'to'] } },
- src/utils/tool-registry.ts:35-35 (registration)Maps the tool name 'gitlab_compare_branches' to its handler function repoHandlers.compareBranches in the central tool registry.gitlab_compare_branches: repoHandlers.compareBranches,