# Search Merge Requests — GitLab

> Find merge requests whose title or description matches a search term. Use this when the user refers to a merge request by what it is about ("the MR about the Redis cache refactor", "the payments migration MR") rather than by number - it is…

- Key: `gitlab-search-merge-requests`
- Type: Action (Read-only)
- Version: 0.0.1
- App: GitLab (`gitlab`) — https://pipedream.com/apps/gitlab.md
- This page (HTML): https://pipedream.com/apps/gitlab/actions/search-merge-requests
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/gitlab/actions/search-merge-requests/search-merge-requests.mjs

## Description

Find merge requests whose title or description matches a search term. Use this when the user refers to a merge request by what it is about ("the MR about the Redis cache refactor", "the payments migration MR") rather than by number - it is the fastest way to turn a description into the `iid` that every other merge request tool needs. ALWAYS set **Project** (or **Group**) when you know which one the user means: a project-scoped search returns in well under a second, whereas an unscoped search scans every project the account can access and, on accounts that belong to many projects, can take tens of seconds and time out (HTTP 408). Leave both blank only when the project is genuinely unknown. Use **List Merge Requests** instead when there is no text to match and you only want to filter by state, author, reviewer or branch. Matching is case-insensitive substring, not fuzzy - prefer one or two distinctive words over a whole sentence. [See the documentation](https://docs.gitlab.com/api/merge_requests/#list-merge-requests)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `search` | `string` | Yes | Text to match against the merge request title and/or description (case-insensitive substring). Use a few distinctive keywords, e.g. redis cache rather than the MR that refactors the Redis cache layer. |
| `projectId` | `string` | No | Limit the search to this project, given as a path (group/project, e.g. backend/payments) or a numeric project ID. Mutually exclusive with Group. |
| `groupId` | `string` | No | Limit the search to every project in this group, given as a full path or a numeric group ID. Cannot be combined with Project — setting both is rejected. |
| `searchIn` | `string` | No | Which fields to match against. Defaults to title,description. Narrow to title when the user is quoting an MR name and description matches would be noise. |
| `state` | `string` | No | Return merge requests in this state. Defaults to opened. Set to all when the merge request being looked for may already be merged or closed — a common case when searching by description. |
| `scope` | `string` | No | Narrow the results by the authenticated user's relationship to the merge request. reviews_for_me answers "what is waiting on my review?", assigned_to_me "what is assigned to me?", and created_by_me "what did I open?". Defaults to all. |
| `maxResults` | `integer` | No | Maximum number of matches to return in total, paginating as needed. Defaults to 20, which is usually plenty for a lookup. |
| `detail` | `string` | No | How much of each record to return. summary (the default) returns the fields needed to identify and triage a merge request and is much cheaper to read. Use full only when you need a field the summary omits. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
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 accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "gitlab",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "gitlab-search-merge-requests",
  arguments: {
    search: "Search",
    projectId: "Project",
  },
})
```

**TypeScript**

```ts
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-search-merge-requests",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    gitlab: { authProvisionId: "apn_xxxxxxx" },
    search: "Search",
    projectId: "Project",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "gitlab-search-merge-requests",
    "configured_props": {
      "gitlab": { "authProvisionId": "apn_xxxxxxx" },
      "search": "Search",
      "projectId": "Project"
    }
  }'
```

---

- App: https://pipedream.com/apps/gitlab.md · All apps: https://pipedream.com/apps
