get_commit_diff
Retrieve detailed changes and differences for a specific GitLab commit by providing project ID and commit hash to analyze code modifications.
Instructions
Get changes/diffs of a specific commit
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project ID or path | |
| sha | Yes | The commit hash or name of a repository branch or tag |
Implementation Reference
- src/handlers/repository.ts:92-107 (handler)The main handler function that executes the get_commit_diff tool by calling the GitLab API to retrieve the diff for a specific commit and returns it as JSON.async getCommitDiff(args: GetCommitDiffParams) { const data = await this.client.get( `/projects/${encodeURIComponent( args.project_id )}/repository/commits/${encodeURIComponent(args.sha)}/diff` ); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- src/tools/repository.ts:118-135 (schema)MCP tool definition including the input schema for get_commit_diff, used for tool listing and validation.{ name: "get_commit_diff", description: "Get changes/diffs of a specific commit", inputSchema: { type: "object", properties: { project_id: { type: "string", description: "Project ID or path", }, sha: { type: "string", description: "The commit hash or name of a repository branch or tag", }, }, required: ["project_id", "sha"], }, },
- src/types.ts:342-345 (schema)TypeScript interface defining the parameters for the getCommitDiff handler.export interface GetCommitDiffParams { project_id: string; sha: string; }
- src/server.ts:281-284 (registration)Registration of the tool call handler in the main server switch statement, dispatching to the repository handler.case "get_commit_diff": return await this.repositoryHandlers.getCommitDiff( args as unknown as GetCommitDiffParams );