Work seamlessly with GitLab from the command line. Manage merge requests, issues, pipelines, releases, and more — without leaving your terminal.
A powerful CLI that brings the full GitLab workflow to your terminal with a familiar, intuitive interface.
Create, review, approve, and merge MRs without leaving your terminal. Supports draft MRs, assignees, reviewers, and labels.
glab mr create --title "Feature" --draftFull issue lifecycle management. Create, assign, label, comment, and close issues from the command line.
glab issue list --state openedTrigger pipelines, view job logs, retry failed builds, and monitor CI status right from your terminal.
glab pipeline run --branch mainClone, create, fork, and manage repositories. Full support for groups and namespaces.
glab repo clone owner/repoFollows the same command patterns as GitHub CLI (gh). If you know gh, you already know glab.
glab <noun> <verb> [flags]Login via browser OAuth or personal access tokens. Tokens auto-refresh when expired. Works with gitlab.com and any self-hosted instance.
glab auth loginManage package registries (npm, Maven, PyPI, etc.) and container image repositories directly from the CLI.
glab package list --type npmAnalyze pipeline success rates, duration trends, slowest jobs, and flaky test detection to optimize your CI/CD.
glab pipeline stats --days 30Built-in Model Context Protocol server with 74 tools, 4 resources, and 5 prompt templates for AI integration.
glab mcp installMultiple installation methods to fit your workflow. Pick whichever suits you best.
brew tap PhilipKram/tap https://github.com/PhilipKram/Gitlab-CLI brew install PhilipKram/tap/glab
# Requires Go 1.22+ go install github.com/PhilipKram/gitlab-cli@latest
Download pre-built binaries for Linux, macOS, and Windows from the releases page.
Available for amd64 and arm64.
git clone https://github.com/PhilipKram/Gitlab-CLI.git cd Gitlab-CLI make build # Binary at ./bin/glab
Authenticate with your GitLab instance. OAuth is the default — just run glab auth login and it opens your browser.
The CLI starts a local server on port 7171, opens your browser for authorization, and exchanges the code for a token using PKCE — no client secret needed.
# OAuth login (default) — opens your browser glab auth login # Login to a specific host glab auth login --hostname gitlab.example.com # Login with a personal access token instead glab auth login --token glpat-xxxxxxxxxxxxxxxxxxxx # Or set an environment variable export GITLAB_TOKEN="glpat-xxxxxxxxxxxxxxxxxxxx"
Before your first OAuth login, create an OAuth application in your GitLab instance under Settings > Applications:
http://localhost:7171/auth/redirectapi read_user write_repository openid profile
OAuth tokens expire after ~2 hours. glab automatically detects expiry and refreshes in the background using the stored refresh token.
Run glab auth status to see when your token expires. Tokens provided via environment variables are never auto-refreshed.
Comprehensive coverage of GitLab features organized into intuitive command groups.
Global Flag:
--repo, -R
Select a GitLab repository using HOST/OWNER/REPO format.
When omitted, glab resolves the host from the git remote, falls back to the default host, then to the first authenticated host.
Common patterns for day-to-day GitLab usage, straight from the terminal.
Create, review, comment on, and merge a merge request — all without leaving the terminal.
# Create a merge request from current branch glab mr create --title "Add user authentication" \ --description "Implements OAuth2 login flow" \ --assignee @alice --reviewer @bob \ --label feature,auth --draft # List open MRs assigned to you glab mr list --state opened # Check out a teammate's MR for review glab mr checkout 42 # Leave an inline comment on the diff glab mr comment 42 --body "Consider refactoring this" \ --file "src/auth.go" --line 57 # Approve and merge glab mr approve 42 glab mr merge 42 --squash --remove-source-branch
Trigger, monitor, and debug CI/CD pipelines without opening the GitLab web UI.
# Trigger a pipeline on main glab pipeline run --branch main --variables DEPLOY_ENV=staging # Watch pipeline status glab pipeline list --ref main --limit 5 # Debug a failed job glab pipeline jobs 12345 glab pipeline job-log 67890
Manage bugs, features, and tasks from the command line — create, assign, label, and close issues.
# Create a bug report glab issue create --title "Login page broken on Safari" \ --label bug,P1 --assignee @alice # Find issues by label glab issue list --label bug --state opened # Close with a comment glab issue comment 42 --body "Fixed in !99" glab issue close 42
Work with remote projects, raw API access, JSON output for scripting, and self-upgrade.
# Target a project on any GitLab instance glab issue list -R gitlab.example.com/group/project glab mr list --state opened -R gitlab.example.com/team/app # Direct API access with specific host glab api '/projects?membership=true' --hostname gitlab.example.com # :id auto-resolves to current project glab api '/projects/:id/pipelines?per_page=5' # Get MR data as JSON glab mr list --json | jq '.[].title' # GraphQL queries glab api graphql --method POST \ --body '{"query":"{ currentUser { name } }"}' # Upgrade to the latest version glab upgrade --yes
Configuration stored in ~/.config/glab/. Override with the GLAB_CONFIG_DIR environment variable.
| Key | Description |
|---|---|
| editor | Preferred text editor |
| pager | Preferred pager program |
| browser | Preferred web browser |
| protocol | Git protocol: https or ssh |
| git_remote | Default git remote name |
| Key | Description |
|---|---|
| client_id | OAuth application ID |
| redirect_uri | OAuth redirect URI |
| oauth_scopes | OAuth scopes |
| protocol | Git protocol for this host |
| api_host | API hostname override |
| Variable | Description |
|---|---|
| GITLAB_TOKEN | Authentication token (overrides stored config) |
| GLAB_TOKEN | Authentication token (alternative) |
| GITLAB_HOST | Default GitLab hostname (default: gitlab.com) |
| GLAB_CONFIG_DIR | Configuration directory path |
# Store OAuth client ID for a self-hosted instance glab config set client_id <app-id> --host gitlab.example.com # Store custom redirect URI glab config set redirect_uri http://localhost:8080/callback --host gitlab.example.com # Store custom OAuth scopes glab config set oauth_scopes "api read_user write_repository" --host gitlab.example.com
Run the MCP server as a standalone HTTP service so remote AI clients can connect over the network. Supports shared-token auth, per-user OAuth, persistent tokens across restarts, Docker deployment, and reverse proxy setups.
# Start HTTP server (auto-generates a bearer token, printed to stderr) glab mcp serve --transport http # Custom host, port, and token glab mcp serve --transport http --host 0.0.0.0 --port 9090 --token my-secret # Stateless mode (simpler, no session tracking) glab mcp serve --transport http --stateless # Register the remote server with Claude Code glab mcp install --transport http --host myserver.example.com --port 8080 --token my-secret
A single bearer token shared by all clients. If you omit --token, a random 64-character hex token is generated and printed to stderr.
The token is persisted to ~/.config/glab/mcp_token so clients stay authenticated across server restarts.
Authorization: Bearer <token>
When --client-id is set, each user authenticates individually via GitLab OAuth.
The server implements the MCP authorization spec (RFC 8414, dynamic client registration, PKCE).
MCP clients like Claude Code handle the flow automatically.
glab mcp serve --transport http --client-id <app-id>
# 1. Create a GitLab OAuth application with redirect URI: # http://<server-host>:<port>/auth/redirect # 2. Start the server with your OAuth app ID glab mcp serve --transport http \ --client-id my-oauth-app-id \ --gitlab-host gitlab.example.com # 3. Behind a reverse proxy? Set the external URL for correct callbacks glab mcp serve --transport http \ --client-id my-oauth-app-id \ --gitlab-host gitlab.example.com \ --external-url https://mcp.example.com # Each user's GitLab API calls use their own OAuth token and permissions
| Flag | Default | Description |
|---|---|---|
| --transport | stdio | Transport mode: stdio or http |
| --host | localhost | HTTP listen address |
| --port | 8080 | HTTP listen port |
| --token | (auto) | Bearer token (auto-generated and persisted if empty) |
| --no-auth | false | Disable bearer token authentication |
| --stateless | false | Stateless HTTP mode (no session tracking) |
| --base-path | /mcp | HTTP endpoint path |
| --client-id | GitLab OAuth application ID (enables per-user OAuth) | |
| --gitlab-host | from config | GitLab hostname for OAuth |
| --external-url | Public base URL for OAuth callbacks behind a reverse proxy |
Deploy the remote MCP server as a Docker container for production environments.
# Build the Docker image docker build -t glab-mcp . # Run with shared token auth (-v persists credentials across restarts) docker run -p 8080:8080 -v glab-mcp-data:/config \ -e GITLAB_TOKEN=glpat-xxxxxxxxxxxx \ glab-mcp --token my-secret # Run with per-user OAuth docker run -p 8080:8080 -v glab-mcp-data:/config \ glab-mcp \ --client-id my-oauth-app-id \ --gitlab-host gitlab.example.com \ --external-url https://mcp.example.com
For production deployments, run behind a reverse proxy that provides TLS termination, rate limiting, and access logging.
Use --external-url so OAuth callbacks resolve to the public hostname.
# Proxy all MCP traffic (including SSE streams and OAuth endpoints) location /mcp { proxy_pass http://127.0.0.1:8080/mcp; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_buffering off; # required for SSE proxy_cache off; proxy_read_timeout 86400s; # long timeout for SSE streams } # Forward OAuth endpoints when using --client-id location /oauth { proxy_pass http://127.0.0.1:8080/oauth; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } location /auth { proxy_pass http://127.0.0.1:8080/auth; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } location /.well-known { proxy_pass http://127.0.0.1:8080/.well-known; proxy_set_header Host $host; }