update_merge_request
Modify an existing GitLab merge request by updating its title, description, state, target branch, labels, assignees, milestone, or source branch removal setting.
Instructions
Update an existing 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 | |
| title | No | New merge request title | |
| description | No | New merge request description | |
| state_event | No | Change merge request state | |
| target_branch | No | New target branch | |
| labels | No | Array of label names | |
| assignee_ids | No | Array of user IDs to assign | |
| milestone_id | No | Milestone ID to assign | |
| remove_source_branch | No | Remove source branch when merged |
Implementation Reference
- src/api/merge-requests.ts:66-95 (handler)The implementation of the update_merge_request API function, which calls the GitLab PUT endpoint to update a merge request.
export async function updateMergeRequest( projectId: string, mergeRequestIid: number, options: { title?: string; description?: string; state_event?: "close" | "reopen"; target_branch?: string; labels?: string[]; assignee_ids?: number[]; milestone_id?: number; remove_source_branch?: boolean; } ): 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}`; const mergeRequest = await gitlabPut<GitLabMergeRequest>(endpoint, { ...options, labels: options.labels?.join(",") }); return GitLabMergeRequestSchema.parse(mergeRequest); } - src/schemas.ts:475-483 (schema)Input validation schema for the update_merge_request tool.
export const UpdateMergeRequestSchema = z.object({ project_id: z.string().describe("Project ID or URL-encoded path"), merge_request_iid: z.number().describe("Merge request internal ID"), title: z.string().optional().describe("New merge request title"), description: z.string().optional().describe("New merge request description"), state_event: z.enum(["close", "reopen"]).optional().describe("Change merge request state"), target_branch: z.string().optional().describe("New target branch"), labels: z.array(z.string()).optional().describe("Array of label names"), assignee_ids: z.array(z.number()).optional().describe("Array of user IDs to assign"), - src/server.ts:425-430 (registration)Handler registration and execution logic for the update_merge_request tool within the main server loop.
case "update_merge_request": { const args = UpdateMergeRequestSchema.parse(request.params.arguments); const { project_id, merge_request_iid, ...options } = args; const mergeRequest = await api.updateMergeRequest(project_id, merge_request_iid, options); return { content: [{ type: "text", text: JSON.stringify(mergeRequest, null, 2) }] }; }