create_merge_request
Create a merge request to propose code changes from a source branch to a target branch in a GitLab project, enabling code review and integration.
Instructions
Create a new merge request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project ID or path | |
| title | Yes | Merge request title | |
| source_branch | Yes | Source branch name | |
| target_branch | Yes | Target branch name | |
| description | No | Merge request description | |
| assignee_ids | No | Array of user IDs to assign | |
| reviewer_ids | No | Array of user IDs to review | |
| labels | No | Comma-separated list of labels | |
| milestone_id | No | Milestone ID |
Implementation Reference
- src/handlers/merge-requests.ts:219-248 (handler)The main handler function in MergeRequestHandlers class that executes the create merge request logic by constructing the request payload and calling the GitLab API POST endpoint.async createMergeRequest(args: CreateMergeRequestParams) { const requestData: any = { title: args.title, source_branch: args.source_branch, target_branch: args.target_branch, }; if (args.description) { requestData.description = args.description; } if (args.assignee_ids) requestData.assignee_ids = args.assignee_ids; if (args.reviewer_ids) requestData.reviewer_ids = args.reviewer_ids; if (args.labels) requestData.labels = args.labels; if (args.milestone_id) requestData.milestone_id = args.milestone_id; const data = await this.client.post( `/projects/${encodeURIComponent(args.project_id)}/merge_requests`, requestData ); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- src/tools/merge-requests.ts:174-219 (schema)MCP tool definition for 'create_merge_request' including the detailed inputSchema used for validation and documentation.name: 'create_merge_request', description: 'Create a new merge request', inputSchema: { type: 'object', properties: { project_id: { type: 'string', description: 'Project ID or path', }, title: { type: 'string', description: 'Merge request title', }, source_branch: { type: 'string', description: 'Source branch name', }, target_branch: { type: 'string', description: 'Target branch name', }, description: { type: 'string', description: 'Merge request description', }, assignee_ids: { type: 'array', items: { type: 'number' }, description: 'Array of user IDs to assign', }, reviewer_ids: { type: 'array', items: { type: 'number' }, description: 'Array of user IDs to review', }, labels: { type: 'string', description: 'Comma-separated list of labels', }, milestone_id: { type: 'number', description: 'Milestone ID', }, }, required: ['project_id', 'title', 'source_branch', 'target_branch'], },
- src/types.ts:283-293 (schema)TypeScript interface defining the input parameters for the createMergeRequest handler.export interface CreateMergeRequestParams { project_id: string; title: string; source_branch: string; target_branch: string; description?: string; assignee_ids?: number[]; reviewer_ids?: number[]; labels?: string; milestone_id?: number; }
- src/server.ts:185-188 (registration)Dispatch registration in the main server switch statement that routes 'create_merge_request' tool calls to the appropriate handler method.case "create_merge_request": return await this.mergeRequestHandlers.createMergeRequest( args as unknown as CreateMergeRequestParams );