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
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project ID or URL-encoded path | |
| merge_request_iid | Yes | Merge request internal ID | |
| merge_commit_message | No | Custom merge commit message | |
| should_remove_source_branch | No | Remove source branch after merge | |
| merge_when_pipeline_succeeds | No | Merge when pipeline succeeds | |
| sha | No | SHA that must match the source branch HEAD |
Implementation Reference
- src/api/merge-requests.ts:97-118 (handler)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); } - src/schemas.ts:488-495 (schema)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) },