View as Markdown
GitLab icon

GitLab ACTION

Create Merge Request Comment

Post a comment on a merge request. It works in three modes, chosen by which props you set: leave File Path and Discussion ID blank for a plain comment on the merge request as a whole; set File Path plus a line number to open an inline thread anchored to that line of the diff; or set Discussion ID to reply inside an existing thread. Use Get Merge Request Diffs first to get valid file paths and line numbers, and List Merge Request Discussions to get a Discussion ID to reply to. Line numbers follow GitLab's diff rules: for a line the merge request adds or leaves unchanged, pass New Line; for a line it removes, pass Old Line; for an unchanged context line, pass both. Getting that wrong is the usual cause of a rejected inline comment. To post several review comments at once, and optionally approve in the same step, use Create Merge Request Review instead. See the documentation
  • Action
  • Writes data
  • OAuth
  • SDK
  • MCP

IMPLEMENTATION

Call this tool

Connect a user's GitLab account once, then configure and run Create Merge Request Comment from your backend or agent.

import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "gitlab-create-merge-request-comment",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    gitlab: { authProvisionId: "apn_xxxxxxx" },
    projectId: "Project",
    mergeRequestIid: 10,
  },
})

console.log(result)

SCHEMA

Inputs

Pipedream supplies the connected account. Your application provides the operation-specific values below. Dynamic inputs are resolved against that user's account.

Create Merge Request Comment inputs
Property Type Description
projectId Project string
The project, given either as its path — group/project or group/subgroup/project, e.g. backend/payments — or as its numeric project ID. The path is what appears in the project URL and is usually what a user will name, so prefer it. A pasted GitLab URL also works. Use List Projects to find the path if you only know part of the name.
Required
mergeRequestIid Merge Request IID integer
The merge request's internal ID — the !N shown in the GitLab UI and the number at the end of the merge request URL. This is not the id field, which is a much larger instance-wide number; passing id here returns a 404. Use List Merge Requests or Search Merge Requests to resolve the IID from a title, branch or author.
Required
body Body string
The comment text. Supports GitLab-flavored Markdown, so code blocks, lists and suggestion blocks all work.
Required
discussionId Discussion ID string
Set this to reply inside an existing thread instead of starting a new one. Get it from List Merge Request Discussions. Cannot be combined with File Path.
Optional
filePath File Path string
Set this to anchor the comment to a line of the diff — the file's path after the change, exactly as new_path reports it in Get Merge Request Diffs (e.g. src/api/client.py). Leave blank for a comment on the merge request as a whole.
Optional
oldFilePath Old File Path string
The file's path before the change, as old_path reports it in Get Merge Request Diffs. Only needed when the merge request renames the file — GitLab anchors a comment on a renamed file with both paths. Defaults to File Path.
Optional
newLine New Line integer
Line number in the new version of the file. Use this for a line the merge request adds, and together with Old Line for an unchanged context line. Required with File Path unless Old Line is given.
Optional
oldLine Old Line integer
Line number in the old version of the file. Use this for a line the merge request removes, and together with New Line for an unchanged context line.
Optional

REFERENCE

Tool details

Behavior hints are published with the component in the Pipedream registry and surface as MCP tool annotations, so an agent can reason about a tool before it calls it.

Registry key
gitlab-create-merge-request-comment
Version
0.0.1
App
GitLab
Authentication
OAuth
Read-only
No
Destructive
No
Open world
Yes