·

GitLab MCP With Cursor

Set up GitLab MCP in Cursor so your AI agent can manage repositories, merge requests, and CI/CD pipelines right from your editor.

Cursor's Agent Mode is where GitLab MCP feels most like a natural extension of the editor rather than a bolted-on integration — you're already in a chat panel next to your code, so pulling an MR's review comments or checking a pipeline's status doesn't require breaking your flow to open a browser tab. This topic covers connecting the server, the browsing/commenting workflow, pipeline monitoring, and the specific limitations Cursor users hit that don't show up in a plain terminal tool.

Connecting GitLab MCP to Cursor Agent Mode

Cursor reads MCP config from .cursor/mcp.json (project) or ~/.cursor/mcp.json (global). The format matches the general MCP JSON convention:

{
  "mcpServers": {
    "gitlab": {
      "command": "npx",
      "args": ["-y", "@gitlab-org/mcp-server"],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "${env:GITLAB_PERSONAL_ACCESS_TOKEN}",
        "GITLAB_API_URL": "https://gitlab.com/api/v4"
      }
    }
  }
}

Enable it in Cursor Settings → Features → MCP (or Cursor Settings → MCP depending on your Cursor version — this menu path has moved a couple of times across recent releases). You should see the gitlab server listed with a green status dot and a tool count once it connects. If the dot is gray or red, click into the server entry — Cursor surfaces the last connection error there, which is usually faster to read than digging through logs.

For self-managed GitLab, add the instance URL and, if your instance uses a self-signed cert on an internal network, be prepared to handle TLS verification at the OS/certificate-store level rather than disabling verification in the MCP server config — Cursor doesn't give you a per-server TLS override, so this has to be solved system-wide (add the internal CA to your machine's trust store).

{
  "mcpServers": {
    "gitlab": {
      "command": "npx",
      "args": ["-y", "@gitlab-org/mcp-server"],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "${env:GITLAB_PAT_INTERNAL}",
        "GITLAB_API_URL": "https://gitlab.internal.company.com/api/v4"
      }
    }
  }
}

Once connected, enable Agent Mode (not plain Chat/Ask mode — tool calling requires it) and confirm with a trivial prompt:

List my 5 most recently updated GitLab projects.

Tips
- Confirm you're in Agent Mode, not Ask mode — MCP tools aren't callable from Cursor's plain chat mode, and the failure looks like the agent "not knowing about" GitLab rather than an obvious mode error.
- For self-managed GitLab with internal certs, fix TLS trust at the OS level — Cursor's MCP config has no per-server TLS bypass option.
- Check the server's status dot and click through to the error detail in Cursor Settings before assuming a bad token — sometimes it's just a stale npx cache; clear it with npx clear-npx-cache if a package update isn't picking up.


Browsing and Commenting on Merge Requests via Cursor

The natural Cursor workflow is: you're editing a file, you know (or suspect) it's part of an open MR, and you want the review context without leaving the editor.

Pulling MR context tied to your current work:

I'm working on http_client.py in my-group/backend-services. Is this file
part of any open merge request right now? If so, show me the unresolved
review comments on it.

This requires list_merge_requests (open, filtered by branch if Cursor knows your current git branch) followed by list_merge_request_diffs/discussion tools scoped to that file. Cursor Agent Mode generally infers your current branch from the workspace's git state without you needing to state it, which is a nice ambient advantage over CLI tools that need the branch named explicitly.

Posting a targeted inline comment while reviewing a teammate's MR:

Open MR !178 in my-group/backend-services. Show me the diff for
retry_logic.py. I think the exponential backoff calculation on line 67
has an off-by-one — post a comment there explaining the issue and
suggesting the fix.

For this to land as an inline diff comment rather than a generic top-level note, the tool call needs the correct file path and line number in the new version of the file (GitLab's diff commenting API is picky about old-line vs new-line references) — if Cursor posts the comment but it shows up detached from the code in the GitLab UI, the line reference was likely wrong; re-check the actual line number in the rendered diff before retrying.

Batch-processing your own review queue:

List all open MRs in my-group/backend-services where I'm a reviewer and
I haven't yet approved or commented. For each, give me a one-line summary
of what changed.

This is a legitimately time-saving pattern for anyone reviewing across several active MRs — it turns "click through five MRs to remember what each one does" into one scan-and-decide list.

Tips
- Let Cursor infer your current branch from workspace git state rather than typing it — it's usually right and saves a prompt round-trip.
- If an inline comment lands as a detached top-level note in GitLab's UI, the line reference was probably wrong — verify against the rendered diff, not just the raw file.
- Use the "list MRs where I haven't reviewed yet" pattern as a standing daily prompt — it's a genuinely useful review-queue triage.


Using Cursor to Monitor CI/CD Pipeline Status with GitLab MCP

Pipeline checks fit naturally into Cursor's pre-push habit loop: you've made changes, you're about to push, and you want to sanity-check the last pipeline state or preemptively think about what might break.

Checking status before you push:

Before I push this branch, check the status of the last pipeline run on
main for my-group/backend-services, so I know if main is currently green.

Cross-referencing a local change against a known flaky test:

Pipeline #48213 on my-group/backend-services failed on the
test_concurrent_orders job. Pull that job's log and tell me if this looks
like the same flaky test we've seen before, based on the error message
pattern.

This works reasonably well when you give the model something to pattern-match against — pasting or describing a previous known-flaky error signature in the prompt turns a vague "is this flaky" into a much more answerable comparison.

A genuinely useful pre-merge gate prompt:

For MR !178, check if the current pipeline passed. If it's still running,
tell me the estimated stages remaining. If it failed, don't do anything
else — just show me which job failed.

Note the explicit "don't do anything else" — this keeps Cursor from chaining into a retry_pipeline call you didn't ask for, which is a reasonable but sometimes unwanted default when a model interprets "check status" as implicitly including "and fix it."

Tips
- Give the model a known-flaky error signature to compare against when asking "is this the same flaky test" — vague pattern-matching without a reference point produces low-confidence guesses.
- Add explicit stop conditions ("just show me, don't retry") to pipeline-check prompts if you want pure read-only status without a follow-on write action.
- Use pipeline status checks as a pre-push habit — cheap to ask, and catches "main is already broken, don't push into a red pipeline" before you compound the problem.


Known Limitations and Workarounds for GitLab MCP in Cursor

No live pipeline streaming. Cursor's MCP tool calls are request/response, not a live stream — asking it to "watch the pipeline until it finishes" doesn't work the way watching a terminal tail -f does. The agent will make one get_pipeline call, report the state at that moment, and stop. Workaround: explicitly ask it to poll ("check again in a moment and tell me if it's still running") which triggers a fresh tool call each time you prompt, or just check the GitLab web UI directly for anything you need to actually watch live.

Large diffs get truncated in the context window. MRs with hundreds of changed lines across many files can exceed what Cursor comfortably holds alongside your open editor context, especially in a long-running Agent Mode session. Symptom: the agent's summary of "what changed" quietly omits some files. Workaround: ask for the diff of one file or one directory at a time on large MRs rather than the whole thing in one prompt.

Approval and merge-permission checks are shallow, same as the other tools in this module — Cursor can tell you an approval count but generally can't tell you whether your project's specific approval rules (required code owners, minimum approvers per rule) are satisfied. Don't let an agent's "looks approved" be your final signal; check the actual merge button state in GitLab, which enforces the real rule set server-side.

Cursor's background agent mode (if you use it) runs with whatever MCP servers are configured, but token scope becomes more important here — a background agent operating without your direct supervision, with a merge_merge_request-capable token, is a meaningfully bigger risk surface than an interactive session where you're watching each tool call. If you use Cursor's background/autonomous modes with GitLab MCP, strongly consider a read-only (read_api) token for that specific mode and keep write-capable tokens reserved for interactive sessions only.

Tips
- Don't ask Cursor to "watch until done" for pipelines — it can't stream; poll manually or check the GitLab UI for anything time-sensitive.
- Split large-MR diff requests by file or directory to avoid silent truncation in the summary.
- If you use Cursor's background/autonomous agent modes, scope that specific MCP connection's token to read-only — reserve write-capable tokens for interactive, supervised sessions.


Tips

Tips
- Confirm Agent Mode (not Ask mode) before troubleshooting a "GitLab tools aren't working" issue — it's the single most common setup mistake.
- Let Cursor infer branch/file context from your open editor rather than repeating it in every prompt — it's usually accurate and saves time.
- Treat any agent's "this MR looks mergeable" as advisory; GitLab's own protected-branch and approval-rule enforcement is the real gate.