Skip to main content
Glama
Alosies
by Alosies

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
NameRequiredDescriptionDefault
merge_request_iidYesMerge request internal ID
project_idYesProject ID or path

Implementation Reference

  • 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), }, ], }; }
  • 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; }
  • 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'], },
  • 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 );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Alosies/gitlab-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server