Skip to main content
Glama
Alosies

GitLab MCP Server

by Alosies

get_merge_request

Retrieve details of a GitLab merge request using project ID and either merge request internal ID or source branch name.

Instructions

Get details of a merge request. Either merge_request_iid or source_branch must be provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesProject ID or path
merge_request_iidNoMerge request internal ID
source_branchNoSource branch name (alternative to merge_request_iid)

Implementation Reference

  • The main handler function that executes the get_merge_request tool logic: resolves MR IID if needed, fetches MR details from GitLab API, and returns JSON.
    async getMergeRequest(args: GetMergeRequestParams) {
      const mergeRequestIid = await this.resolveMergeRequestIid(
        args.project_id,
        args.merge_request_iid,
        args.source_branch
      );
    
      const data = await this.client.get(
        `/projects/${encodeURIComponent(
          args.project_id
        )}/merge_requests/${mergeRequestIid}`
      );
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(data, null, 2),
          },
        ],
      };
    }
  • MCP Tool registration defining the name, description, and input schema for get_merge_request.
    {
      name: 'get_merge_request',
      description: 'Get details of a merge request. Either merge_request_iid or source_branch must be provided.',
      inputSchema: {
        type: 'object',
        properties: {
          project_id: {
            type: 'string',
            description: 'Project ID or path',
          },
          merge_request_iid: {
            type: 'number',
            description: 'Merge request internal ID',
          },
          source_branch: {
            type: 'string',
            description: 'Source branch name (alternative to merge_request_iid)',
          },
        },
        required: ['project_id'],
      },
    },
  • TypeScript interface defining the input parameters for the get_merge_request handler.
    export interface GetMergeRequestParams {
      project_id: string;
      merge_request_iid?: number;
      source_branch?: string;
    }

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