Skip to main content
Glama

merge_merge_request

Merge a GitLab merge request to integrate code changes into the target branch. Specify project, merge request ID, and optional settings like commit message or branch cleanup.

Instructions

Merge a merge request in a GitLab project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesProject ID or URL-encoded path
merge_request_iidYesMerge request internal ID
merge_commit_messageNoCustom merge commit message
should_remove_source_branchNoRemove source branch after merge
merge_when_pipeline_succeedsNoMerge when pipeline succeeds
shaNoSHA that must match the source branch HEAD

Implementation Reference

  • The implementation of the mergeMergeRequest function which performs the API call to merge a merge request.
    export async function mergeMergeRequest(
      projectId: string,
      mergeRequestIid: number,
      options: {
        merge_commit_message?: string;
        should_remove_source_branch?: boolean;
        merge_when_pipeline_succeeds?: boolean;
        sha?: string;
      } = {}
    ): Promise<GitLabMergeRequest> {
      if (!projectId?.trim()) {
        throw new Error("Project ID is required");
      }
      if (!mergeRequestIid || mergeRequestIid < 1) {
        throw new Error("Valid merge request IID is required");
      }
    
      const endpoint = `/projects/${encodeProjectId(projectId)}/merge_requests/${mergeRequestIid}/merge`;
    
      const mergeRequest = await gitlabPut<GitLabMergeRequest>(endpoint, options);
      return GitLabMergeRequestSchema.parse(mergeRequest);
    }
  • The Zod schema definition for the input arguments of the merge_merge_request tool.
    export const MergeMergeRequestSchema = z.object({
      project_id: z.string().describe("Project ID or URL-encoded path"),
      merge_request_iid: z.number().describe("Merge request internal ID"),
      merge_commit_message: z.string().optional().describe("Custom merge commit message"),
      should_remove_source_branch: z.boolean().optional().describe("Remove source branch after merge"),
      merge_when_pipeline_succeeds: z.boolean().optional().describe("Merge when pipeline succeeds"),
      sha: z.string().optional().describe("SHA that must match the source branch HEAD")
    });
  • src/server.ts:200-204 (registration)
    Registration of the merge_merge_request tool in the server definition.
    {
      name: "merge_merge_request",
      description: "Merge a merge request in a GitLab project",
      inputSchema: zodToJsonSchema(MergeMergeRequestSchema)
    },

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

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