get_merge_request
Retrieve detailed information about a specific GitLab merge request using project ID and merge request internal ID to access status, changes, and metadata.
Instructions
Get details of a specific merge request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| merge_request_iid | Yes | Merge request internal ID | |
| project_id | Yes | Project ID or path |
Implementation Reference
- src/handlers/merge-requests.ts:112-133 (handler)The core handler function that resolves the merge request IID (if needed) and fetches the merge request details from the GitLab API, returning formatted JSON response.async getMergeRequest(args: GetMergeRequestParams) { const mergeRequestIid = await this.resolveMergeRequestIid( args.project_id, args.merge_request_iid, args.source_branch ); const data = await this.client.get( `/projects/${encodeURIComponent( args.project_id )}/merge_requests/${mergeRequestIid}` ); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- src/types.ts:254-258 (schema)TypeScript interface defining the input parameters for the get_merge_request tool.export interface GetMergeRequestParams { project_id: string; merge_request_iid?: number; source_branch?: string; }
- src/tools/merge-requests.ts:63-83 (registration)Tool registration object defining the name, description, and input schema for 'get_merge_request'.{ name: 'get_merge_request', description: 'Get details of a merge request. Either merge_request_iid or source_branch must be provided.', inputSchema: { type: 'object', properties: { project_id: { type: 'string', description: 'Project ID or path', }, merge_request_iid: { type: 'number', description: 'Merge request internal ID', }, source_branch: { type: 'string', description: 'Source branch name (alternative to merge_request_iid)', }, }, required: ['project_id'], },
- src/handlers/merge-requests.ts:32-76 (helper)Helper method used by getMergeRequest to resolve merge request IID from source branch if not provided directly.private async resolveMergeRequestIid( projectId: string, mergeRequestIid?: number, sourceBranch?: string ): Promise<number> { if (mergeRequestIid) { return mergeRequestIid; } if (!sourceBranch) { throw new Error( "Either merge_request_iid or source_branch must be provided" ); } // Find MR by source branch const mrs = (await this.client.get( `/projects/${encodeURIComponent( projectId )}/merge_requests?source_branch=${encodeURIComponent( sourceBranch )}&state=opened&per_page=1` )) as GitLabMergeRequest[]; if (!mrs || mrs.length === 0) { // Try all states if no open MR found const allMrs = (await this.client.get( `/projects/${encodeURIComponent( projectId )}/merge_requests?source_branch=${encodeURIComponent( sourceBranch )}&per_page=1` )) as GitLabMergeRequest[]; if (!allMrs || allMrs.length === 0) { throw new Error( `No merge request found for source branch: ${sourceBranch}` ); } return allMrs[0].iid; } return mrs[0].iid; }
- src/server.ts:181-184 (registration)Server dispatch case that routes calls to the 'get_merge_request' tool to the appropriate handler.case "get_merge_request": return await this.mergeRequestHandlers.getMergeRequest( args as unknown as GetMergeRequestParams );