create_merge_request
Create a new merge request in GitLab by specifying source and target branches, title, description, assignees, reviewers, labels, and milestone for code review and integration.
Instructions
Create a new merge request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assignee_ids | No | Array of user IDs to assign | |
| description | No | Merge request description | |
| labels | No | Comma-separated list of labels | |
| milestone_id | No | Milestone ID | |
| project_id | Yes | Project ID or path | |
| reviewer_ids | No | Array of user IDs to review | |
| source_branch | Yes | Source branch name | |
| target_branch | Yes | Target branch name | |
| title | Yes | Merge request title |
Implementation Reference
- src/handlers/merge-requests.ts:219-248 (handler)The handler function that implements the create_merge_request tool by constructing the request data and calling the GitLab API to POST /projects/{project_id}/merge_requests.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:173-219 (schema)The MCP tool schema definition for create_merge_request, including inputSchema used for validation.{ 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/server.ts:185-188 (registration)Server-side registration and dispatching of the create_merge_request tool call to the handler.case "create_merge_request": return await this.mergeRequestHandlers.createMergeRequest( args as unknown as CreateMergeRequestParams );
- src/types.ts:283-293 (schema)TypeScript interface defining the 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; }