get_branch_diffs
Compare changes between branches or commits in a GitLab project to review code differences and track modifications.
Instructions
Get the changes/diffs between two branches or commits in a GitLab project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project ID or path | |
| from | Yes | The base branch or commit SHA to compare from | |
| to | Yes | The target branch or commit SHA to compare to | |
| straight | No | Comparison method: false for "..." (default), true for "--" |
Implementation Reference
- src/handlers/merge-requests.ts:196-217 (handler)The core handler function that implements the get_branch_diffs tool logic: constructs the GitLab repository/compare API URL and fetches/returns the diffs as JSON.async getBranchDiffs(args: GetBranchDiffsParams) { const params = new URLSearchParams(); params.append("from", args.from); params.append("to", args.to); if (args.straight !== undefined) params.append("straight", String(args.straight)); const url = `/projects/${encodeURIComponent( args.project_id )}/repository/compare?${params.toString()}`; const data = await this.client.get(url); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- src/tools/merge-requests.ts:147-172 (schema)Tool definition including the input schema (JSON Schema) for validating parameters: project_id, from, to, straight.{ name: 'get_branch_diffs', description: 'Get the changes/diffs between two branches or commits in a GitLab project', inputSchema: { type: 'object', properties: { project_id: { type: 'string', description: 'Project ID or path', }, from: { type: 'string', description: 'The base branch or commit SHA to compare from', }, to: { type: 'string', description: 'The target branch or commit SHA to compare to', }, straight: { type: 'boolean', description: 'Comparison method: false for "..." (default), true for "--"', }, }, required: ['project_id', 'from', 'to'], }, },
- src/server.ts:201-204 (registration)Server-side dispatch/registration in the CallToolRequestSchema handler switch statement that routes calls to the mergeRequestHandlers.getBranchDiffs method.case "get_branch_diffs": return await this.mergeRequestHandlers.getBranchDiffs( args as unknown as GetBranchDiffsParams );
- src/types.ts:276-281 (schema)TypeScript type definition/interface for the GetBranchDiffsParams used in handler signature and server dispatch.export interface GetBranchDiffsParams { project_id: string; from: string; to: string; straight?: boolean; }