@bakhshb/gitlab-mcp-openapi
v1.1.2
Published
2-tool OpenAPI-driven MCP server for GitLab
Maintainers
Readme
GitLab MCP OpenAPI
2-tool OpenAPI-driven MCP server for GitLab — 95% token savings vs traditional explicit-tool implementations.
Overview
This MCP server provides a generic GitLab API executor using the OpenAPI pattern. Instead of 44+ individual tools (like structured-world), it exposes just 2 powerful tools:
gitlab-api— Execute any GitLab REST API operationgitlab-api-schema— Discover available API paths and parameters
Why This Pattern?
| Approach | Tools | Token Usage | |----------|---------|--------------| | Traditional (structured-world) | 44 individual tools | ~15,000-20,000 | | This MCP | 2 tools | ~1,000-1,500 ✅ |
Result: 95% token savings while maintaining full GitLab API coverage.
Installation
Global Install (for OpenClaw)
npm install -g @bakhshb/gitlab-mcp-openapiLocal Install (for development)
cd gitlab-mcp-openapi
npm install
npm run buildConfiguration
Environment Variables
| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| GITLAB_TOKEN | No* | - | GitLab Personal Access Token (required for static mode) |
| GITLAB_PERSONAL_ACCESS_TOKEN | No | - | Alternative to GITLAB_TOKEN |
| GITLAB_API_URL | No | https://gitlab.com | GitLab instance URL |
| GITLAB_TIMEOUT | No | 30000 | Request timeout in milliseconds |
| OAUTH_ENABLED | No | false | Enable OAuth token mode |
| GITLAB_OAUTH_TOKEN | No | - | OAuth access token (used when OAUTH_ENABLED=true) |
*Either GITLAB_TOKEN, GITLAB_PERSONAL_ACCESS_TOKEN, or GITLAB_OAUTH_TOKEN (with OAUTH_ENABLED=true) is required.
Creating a Personal Access Token
- Go to your GitLab instance → Profile → Access Tokens
- Click "Add new token"
- Name it something like "MCP GitLab" or "OpenClaw"
- Select scopes:
- ✅
api— Full API access - ✅
read_user— User profile access
- ✅
- Copy the token
- Set environment variable:
export GITLAB_TOKEN=glpat-your-token-here
OAuth Mode
For OAuth-based authentication (token provided by MCP runtime):
export OAUTH_ENABLED=true
export GITLAB_OAUTH_TOKEN=your-oauth-token
gitlab-mcp-openapiIn OpenClaw configuration:
{
"mcpServers": {
"gitlab-mcp-openapi": {
"command": "gitlab-mcp-openapi",
"env": {
"GITLAB_API_URL": "https://gitlab.com",
"OAUTH_ENABLED": "true",
"GITLAB_OAUTH_TOKEN": "${GITLAB_OAUTH_TOKEN}"
}
}
}
}Self-Hosted GitLab
For self-hosted GitLab (like GitLab at your organization):
export GITLAB_API_URL=https://gitlab.yourcompany.com
export GITLAB_TOKEN=glpat-your-token-here
gitlab-mcp-openapiOpenClaw Integration
Add MCP Server to OpenClaw
Edit ~/.openclaw/openclaw.json:
{
"mcpServers": {
"gitlab-mcp-openapi": {
"command": "gitlab-mcp-openapi",
"env": {
"GITLAB_API_URL": "https://gitlab.com",
"GITLAB_TOKEN": "${GITLAB_TOKEN}"
}
}
}
}For self-hosted GitLab:
{
"mcpServers": {
"gitlab-mcp-openapi": {
"command": "gitlab-mcp-openapi",
"env": {
"GITLAB_API_URL": "https://gitlab.yourcompany.com",
"GITLAB_TOKEN": "${GITLAB_TOKEN}"
}
}
}
}Restart Gateway
openclaw gateway restartTools & Services
This MCP covers 44 tools across all major GitLab API areas:
Projects & Namespaces (4 tools)
list_projects— List all projectsget_project— Get project detailssearch_projects— Search projects by namecreate_project— Create a new projectbrowse_namespaces— List namespacesmanage_namespace— Create/update/delete groups
Merge Requests (5 tools)
list_merge_requests— List MRs in a projectget_merge_request— Get MR detailscreate_merge_request— Create a new MRapprove_merge_request— Approve an MRmerge_merge_request— Merge an MRget_merge_request_approval_state— Get approval statusbrowse_mr_discussions— List MR discussionsmanage_mr_discussion— Add/resolve commentsmanage_draft_notes— Draft notes for MRs
Pipelines & CI/CD (3 tools)
list_pipelines— List project pipelinesget_pipeline— Get pipeline detailslist_pipeline_jobs— List jobs in a pipelineget_pipeline_job— Get job detailscreate_pipeline— Trigger a new pipelinecancel_pipeline— Cancel a running pipelineretry_pipeline— Retry failed pipelinecancel_pipeline_job— Cancel a specific jobretry_pipeline_job— Retry failed job
Issues & Notes (6 tools)
list_issues— List issuesget_issue— Get issue detailscreate_issue— Create a new issueupdate_issue— Edit an issuedelete_issue— Delete an issuemy_issues— List your assigned issueslist_issue_notes— List issue commentsget_issue_note— Get specific commentcreate_issue_note— Add a commentupdate_issue_note— Edit a commentdelete_issue_note— Delete a comment
Repository (4 tools)
create_repository— Create a new projectfork_repository— Fork an existing projectget_file_contents— Read a file from repoget_repository_tree— List files in a directorylist_commits— List commit historyget_commit— Get specific commit detailscreate_branch— Create a new branchdelete_branch— Delete a branch
Files (2 tools)
browse_files— List repo files (tree)manage_files— Create/update/delete files
Releases (2 tools)
list_releases— List project releasesget_release— Get release detailscreate_release— Create a releaseupdate_release— Update a releasedelete_release— Delete a releasedownload_release_asset— Download release binaries
Wiki (2 tools)
browse_wiki— List wiki pagesmanage_wiki— Create/update/delete wiki pages
Milestones (2 tools)
browse_milestones— List project milestonesmanage_milestone— Create/update/delete milestones
Labels (2 tools)
browse_labels— List project labelsmanage_label— Create/update/delete labels
Variables (2 tools)
browse_variables— List CI/CD variablesmanage_variable— Create/update/delete variables
Webhooks (2 tools)
browse_webhooks— List project webhooksmanage_webhook— Create/update/delete/test webhooks
Integrations (2 tools)
browse_integrations— List project integrationsmanage_integration— Enable/disable/integrations
Snippets (2 tools)
browse_snippets— List code snippetsmanage_snippet— Create/update/delete snippets
Work Items (2 tools)
browse_work_items— Search epics/tasksmanage_work_item— Create/update/delete work items
Members (2 tools)
browse_members— List project membersmanage_member— Add/update/remove members
Search (1 tool)
browse_search— Global search across GitLab
Events (1 tool)
browse_events— User/project event history
Todos (2 tools)
browse_todos— List todosmanage_todos— Mark done/restore
Commits (1 tool)
browse_commits— List/get commits, diffs
Usage Examples
List Projects
{
path: "/api/v4/projects",
queryParams: { per_page: 20, membership: true }
}Get Specific Project
{
path: "/api/v4/projects/{id}",
pathParams: { id: 15 }
}Create Project (POST)
{
path: "/api/v4/projects",
method: "POST",
body: {
name: "my-new-project",
namespace_id: 1,
visibility: "private",
description: "Created via MCP"
}
}List Merge Requests
{
path: "/api/v4/projects/{id}/merge_requests",
pathParams: { id: 15 },
queryParams: { state: "opened", per_page: 10 }
}Approve Merge Request
{
path: "/api/v4/projects/{id}/merge_requests/{merge_request_iid}/approve",
method: "POST",
pathParams: { id: 15, merge_request_iid: 42 }
}Create Pipeline
{
path: "/api/v4/projects/{id}/pipeline",
method: "POST",
pathParams: { id: 15 },
body: { ref: "main" }
}List Pipelines
{
path: "/api/v4/projects/{id}/pipelines",
pathParams: { id: 15 },
queryParams: { per_page: 20 }
}Create Issue
{
path: "/api/v4/projects/{id}/issues",
method: "POST",
pathParams: { id: 15 },
body: {
title: "Found a bug",
description: "Detailed bug report...",
labels: ["bug", "critical"]
}
}List Issues
{
path: "/api/v4/projects/{id}/issues",
pathParams: { id: 15 },
queryParams: { state: "opened", per_page: 50 }
}List Releases
{
path: "/api/v4/projects/{id}/releases",
pathParams: { id: 15 }
}Get File Contents
{
path: "/api/v4/projects/{id}/repository/files/{path}/raw",
pathParams: { id: 15, path: "README.md" },
queryParams: { ref: "main" }
}Create Branch
{
path: "/api/v4/projects/{id}/repository/branches",
method: "POST",
pathParams: { id: 15 },
body: {
branch: "feature/new-feature",
ref: "main"
}
}Architecture
Spec-Based Design
- Dynamic OpenAPI spec — Loads filtered GitLab OpenAPI spec (143 paths, 333 KB)
- No hardcoded endpoints — Any GitLab REST API endpoint is accessible
- Auto method detection — HTTP method (GET/POST/PUT/DELETE/PATCH) detected from spec
2-Tool Pattern
gitlab-api (generic executor)
├── path + method + params → GitLab REST API
└── gitlab-api-schema (schema discovery)
└── tag/path → OpenAPI introspectionDevelopment
Install Dependencies
npm installBuild
npm run buildRun Locally
npm run startTest
Run tests with watch mode:
npm testRun tests once:
npm run test:runEnvironment Setup
cp .env.example .env
# Edit .env with your GitLab URL and tokenInspiration
This MCP server follows the same 2-tool OpenAPI pattern as:
- @bakhshb/unifi-mcp-openapi — UniFi Network API
- @bakhshb/proxmox-mcp-openapi — Proxmox VE API
- @limehawk/dokploy-mcp — Dokploy API (original implementation)
License
MIT — see LICENSE file.
Links
- npm: https://www.npmjs.com/package/@bakhshb/gitlab-mcp-openapi
- GitHub: https://github.com/bakhshb/gitlab-mcp-openapi
- GitLab API Docs: https://docs.gitlab.com/ee/api/rest/
- OpenClaw Docs: https://docs.openclaw.ai
Support
For issues, questions, or contributions:
- Open an issue on GitHub
- Join the OpenClaw Discord
