> ## Documentation Index
> Fetch the complete documentation index at: https://onecli.sh/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Let AI Agents Work With GitLab Merge Requests

> Let agents work with GitLab projects, issues, merge requests, and branches. Connect your own GitLab OAuth app, and the gateway keeps the token hidden.

## Overview

OneCLI connects AI agents to [GitLab](https://gitlab.com) through OAuth. Agents can read projects, open and update issues and merge requests, comment, and manage branches. The gateway injects the token into every request, so your agent never sees it.

GitLab uses **your own GitLab OAuth application**, on OneCLI Cloud and self-hosted alike. Setup takes about five minutes, once.

## What you will set up

* Your own GitLab OAuth application with the required scopes
* A GitLab connection that injects the token on every request
* Per-agent, per-tool access, such as approval before merging

## Connect GitLab

**1. Create a GitLab OAuth application**

In GitLab, open **User settings** > **Applications** and click **Add new application**. Name it `OneCLI`, and select the scopes `api`, `read_user`, `read_repository`, `write_repository`, and `read_registry`.

![GitLab User settings, Applications, Add new application form with Name OneCLI, the OneCLI redirect URI, Confidential ticked, and the api scope ticked.](https://mintcdn.com/chartdbinc/dTUFGeS6j-vov2tm/images/integrations/gitlab/01-provider-new-application.png?fit=max\&auto=format\&n=dTUFGeS6j-vov2tm\&q=85\&s=9d8f5c1f8607490bd5c0871af9692c33)

The Add new application form in GitLab.

**2. Add the redirect URI**

In OneCLI, open **Connections** > **GitLab** > **Custom credentials** and copy the **Redirect URI**. Paste it into the GitLab application's **Redirect URI** and save the application.

![GitLab application page for OneCLI showing an example Application ID, the hidden Secret, the OneCLI callback URL, Confidential Yes, and OneCLI's five scopes.](https://mintcdn.com/chartdbinc/dTUFGeS6j-vov2tm/images/integrations/gitlab/02-provider-credentials.png?fit=max\&auto=format\&n=dTUFGeS6j-vov2tm\&q=85\&s=9d43ad97abb5f6c4225a8ad0620e3c34)

After saving, GitLab shows the Application ID and the Secret. Copy the secret now, GitLab shows it only once.

**3. Add your credentials and connect**

Copy the GitLab **Application ID** and **Secret** into **Custom credentials**, click **Save credentials**, then click **Connect GitLab** and **Authorize** in GitLab.

![OneCLI connect window for GitLab showing Configuration required, the setup guide link, and the Configure credentials button.](https://mintcdn.com/chartdbinc/L4k9tYUENUtEpMY8/images/integrations/gitlab/onecli-connect-gitlab.png?fit=max\&auto=format\&n=L4k9tYUENUtEpMY8\&q=85\&s=9f2c53870ad16779b23c12a845c60979)

The GitLab connect window in OneCLI before credentials are added.

## What agents can do

| Area | What agents can do |
| - | - |
| **Projects** | List and read projects, list branches |
| **Issues** | List and read issues. Create, update, and comment on issues |
| **Merge requests** | List and read merge requests. Create, update, comment on, and merge them |
| **Branches** | Create and delete branches |

## Controlling access

[Grant](https://onecli.sh/docs/guides/agent-access.md) the connection to each agent that needs it, and choose per tool what runs freely, what needs approval, and what's blocked. Put **Merge merge request** and **Delete branch** behind approval. Organization [rules](https://onecli.sh/docs/guides/rules.md) add guardrails on top. A blocked request never reaches GitLab.

To disconnect, remove the connection in **Connections** > **GitLab**, then revoke OneCLI in GitLab under **User settings** > **Applications**.

## FAQ

> [accordion] Do I need my own GitLab OAuth app on OneCLI Cloud?
>
> Yes. GitLab uses your own OAuth application on Cloud and self-hosted alike. Setup takes about five minutes, once.

> [accordion] Does the agent see my GitLab token?
>
> No. The token stays in OneCLI, and the gateway adds it to each request at the proxy. See [How it works](https://onecli.sh/docs/how-it-works.md).

> [accordion] How do I reconnect GitLab?
>
> Click **Connect GitLab** again in **Connections** > **GitLab** and authorize. Agents with access use the new connection automatically.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.