Skip to main content
Glama
Alosies
by Alosies

get_merge_request_diffs

Retrieve code changes from GitLab merge requests to review modifications between branches. Specify project ID with either merge request ID or source branch name.

Instructions

Get the changes/diffs of a merge request. Either merge_request_iid or source_branch must be provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesProject ID or path
merge_request_iidNoMerge request internal ID
source_branchNoSource branch name (alternative to merge_request_iid)
viewNoDiff view type

Implementation Reference

  • The core handler function implementing get_merge_request_diffs tool. Resolves merge request IID from source_branch if not provided, constructs the GitLab API URL for MR changes/diffs, fetches the data, and returns it as JSON text content.
    async getMergeRequestDiffs(args: GetMergeRequestDiffsParams) { const mergeRequestIid = await this.resolveMergeRequestIid( args.project_id, args.merge_request_iid, args.source_branch ); const params = new URLSearchParams(); if (args.view) params.append("view", args.view); const queryString = params.toString(); const url = `/projects/${encodeURIComponent( args.project_id )}/merge_requests/${mergeRequestIid}/changes${ queryString ? `?${queryString}` : "" }`; const data = await this.client.get(url); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
  • MCP tool definition including name, description, and inputSchema for the get_merge_request_diffs tool.
    { name: 'get_merge_request_diffs', description: 'Get the changes/diffs 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)', }, view: { type: 'string', enum: ['inline', 'parallel'], description: 'Diff view type', }, }, required: ['project_id'], }, },
  • src/server.ts:193-196 (registration)
    Server dispatch/registration for the tool call, routing to the mergeRequestHandlers.getMergeRequestDiffs method.
    case "get_merge_request_diffs": return await this.mergeRequestHandlers.getMergeRequestDiffs( args as unknown as GetMergeRequestDiffsParams );
  • TypeScript interface defining the parameters for the getMergeRequestDiffs handler.
    export interface GetMergeRequestDiffsParams { project_id: string; merge_request_iid?: number; source_branch?: string; view?: 'inline' | 'parallel'; }

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