DEV Community

Cover image for Turning GitLab Merge Requests into MCP-Native Data with gitlabmcp
archies-coder
archies-coder

Posted on

Turning GitLab Merge Requests into MCP-Native Data with gitlabmcp

Turning GitLab Merge Requests into MCP-Native Data with gitlabmcp

AI copilots are only as helpful as the context they can reach. Most GitLab reviews still involve tab juggling and copy-pasting links into assistants. So I built @archisbhoir/gitlabmcp: an MCP server plus npm library that exposes complete merge request context (commits, discussions, pipelines, approvals, diffs, jobs) to any MCP-compatible client with one command.

Why a GitLab MCP server?

  • Unified MR snapshot: GitLab splits data between GraphQL and REST. MCP clients want one payload.
  • Transport flexibility: Some copilots launch stdio servers locally; others prefer HTTP. Supporting both keeps the codebase unified.
  • Automation hooks: Once the data is normalized, I can reuse it from scripts without spinning up a server.

What the MCP server provides

  • npx @archisbhoir/gitlabmcp@latest starts either a stdio server (perfect for Claude Desktop) or an HTTP server (gitlabmcp-http).
  • Tool catalog includes:
    • get_merge_request for the full view (commits, diffs, pipelines, approvals, discussions).
    • Focused helpers: get_merge_request_commits, get_merge_request_discussions, get_merge_request_diffs, get_merge_request_approvals, get_merge_requests_by_user, create_merge_request, health_check.
    • Pipeline tooling: get_merge_request_pipelines, get_pipeline, get_pipeline_jobs (with status scoping).
  • Drop-in MCP configs live in the README for Claude Desktop or any MCP client; you can also hit /mcp via HTTP for remote/browsers.

Library mode for scripting

Need MR or pipeline data in a Node script? Install and call the exports directly:

npm install @archisbhoir/gitlabmcp
Enter fullscreen mode Exit fullscreen mode
import {
  getMergeRequestView,
  fetchAllCommits,
  fetchAllDiscussions,
  getMRChangesRest,
  getMRApprovalsRest,
  getMRPipelines,
  getPipeline,
  getPipelineJobs,
} from '@archisbhoir/gitlabmcp';

const view = await getMergeRequestView('group/project', '123');
const pipelines = await getMRPipelines('group/project', '123');
const jobs = await getPipelineJobs('group/project', '456', { scope: 'failed' });
Enter fullscreen mode Exit fullscreen mode

All helpers read GITLAB_BASE_URL and GITLAB_TOKEN from process.env (or .env), so scripts get the same normalization as the MCP server.

Quick-start commands

# Stdio MCP server (Claude Desktop, other stdio clients)
npx @archisbhoir/gitlabmcp@latest

# HTTP MCP server
npx -p @archisbhoir/gitlabmcp@latest node dist/server-http.js
Enter fullscreen mode Exit fullscreen mode

Set the environment variables first:

export GITLAB_BASE_URL=https://gitlab.example.com
export GITLAB_TOKEN=glpat-your-token-with-read_api-or-api
Enter fullscreen mode Exit fullscreen mode

Pipelines front and center

Release engineers often ask for pipeline history while reviewing a merge request. Instead of opening GitLab separately, copilots can call:

  • get_merge_request_pipelines → all pipelines tied to an MR.
  • get_pipeline → details on any pipeline (status, SHA, web URL, source).
  • get_pipeline_jobs → individual jobs filtered by status (running, failed, manual, etc.).

Combine those with MR discussions or diffs to build “summarize failing jobs” workflows entirely inside your MCP client.

Visualizing the data flow

gitlab mcp server data flow graphql, rest

Where to go next

Whether you want your AI assistant to summarize discussions, remind you of pending approvals, or watch pipeline failures, gitlabmcp keeps GitLab context flowing directly into the MCP ecosystem. Let me know how it works for you and what tooling you’d like layered on top.

Top comments (0)