get_commit
Retrieve detailed information about a specific GitLab commit, including project ID, commit hash, and optional statistics for tracking changes.
Instructions
Get details 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 | |
| stats | No | Include commit stats (additions, deletions) |
Implementation Reference
- src/handlers/repository.ts:69-90 (handler)The core handler function that implements the 'get_commit' tool logic. It constructs the GitLab API URL for the commit endpoint, fetches the data using the GitLabClient, and returns the JSON response as text content.async getCommit(args: GetCommitParams) { const params = new URLSearchParams(); if (args.stats !== undefined) params.append("stats", String(args.stats)); const queryString = params.toString(); const url = `/projects/${encodeURIComponent( args.project_id )}/repository/commits/${encodeURIComponent(args.sha)}${ queryString ? `?${queryString}` : "" }`; const data = await this.client.get(url); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- src/server.ts:277-280 (registration)Registers the 'get_commit' tool in the MCP server's request handler switch statement, dispatching calls to the repositoryHandlers.getCommit method.case "get_commit": return await this.repositoryHandlers.getCommit( args as unknown as GetCommitParams );
- src/types.ts:336-340 (schema)TypeScript interface defining the input parameters for the 'get_commit' tool.export interface GetCommitParams { project_id: string; sha: string; stats?: boolean; }
- src/tools/repository.ts:97-117 (registration)Defines the MCP tool metadata including name, description, and input schema for 'get_commit', used for tool listing and validation.name: "get_commit", description: "Get details 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", }, stats: { type: "boolean", description: "Include commit stats (additions, deletions)", }, }, required: ["project_id", "sha"], }, },