Skip to main content
Glama
Alosies

GitLab MCP Server

by Alosies

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
NameRequiredDescriptionDefault
project_idYesProject ID or path
shaYesThe commit hash or name of a repository branch or tag
statsNoInclude commit stats (additions, deletions)

Implementation Reference

  • 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
      );
  • TypeScript interface defining the input parameters for the 'get_commit' tool.
    export interface GetCommitParams {
      project_id: string;
      sha: string;
      stats?: boolean;
    }
  • 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"],
      },
    },

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/Alosies/gitlab-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server