Maintained by: Dmitry Prudnikov | Original Author: zereight
A fork of the original zereight/gitlab-mcp
GitLab MCP(Model Context Protocol) Server. Includes bug fixes and improvements over the original GitLab MCP server.
This fork is actively maintained and enhanced with strict TypeScript standards, Yarn 4 support, and improved development workflows.
- Node.js: >=18.0.0 (required for native fetch API support)
- GitLab: Compatible with GitLab.com and self-hosted instances
When using with the Claude App, you need to set up your API key and URLs directly.
Add to your ~/.codex/config.toml
:
[mcp_servers.gitlab]
command = "yarn"
args = ["dlx", "-q", "@structured-world/gitlab-mcp@latest", "stdio"]
env = { "GITLAB_TOKEN" = "mytoken", "GITLAB_API_URL" = "https://gitlab.com" }
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": ["-y", "@structured-world/gitlab-mcp"],
"env": {
"GITLAB_TOKEN": "your_gitlab_token",
"GITLAB_API_URL": "your_gitlab_api_url",
"GITLAB_PROJECT_ID": "your_project_id", // Optional: default project
"GITLAB_ALLOWED_PROJECT_IDS": "", // Optional: comma-separated list of allowed project IDs
"GITLAB_READ_ONLY_MODE": "false",
"GITLAB_API_TIMEOUT_MS": "20000", // API timeout in milliseconds (default: 20000)
"USE_GITLAB_WIKI": "false", // use wiki api?
"USE_MILESTONE": "false", // use milestone api?
"USE_PIPELINE": "false", // use pipeline api?
"USE_VARIABLES": "true", // use variables api?
"SKIP_TLS_VERIFY": "false" // skip SSL cert verification (dev only)
}
}
}
}
{
"inputs": [
{
"type": "promptString",
"id": "gitlab-token",
"description": "Gitlab Token to read API",
"password": true
}
],
"servers": {
"GitLab-MCP": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@structured-world/gitlab-mcp"],
"env": {
"GITLAB_TOKEN": "${input:gitlab-token}",
"GITLAB_API_URL": "your-fancy-gitlab-url",
"GITLAB_READ_ONLY_MODE": "true",
...
}
}
}
}
Transport Mode Selection:
-
PORT environment variable present β Server starts in HTTP mode with both SSE and StreamableHTTP endpoints (
/sse
and/mcp
) -
No PORT environment variable β Server starts in stdio mode for direct MCP communication
-
Explicit
stdio
argument β Forces stdio mode regardless of PORT -
stdio mcp.json
{
"mcpServers": {
"gitlab": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITLAB_TOKEN",
"-e",
"GITLAB_API_URL",
"-e",
"GITLAB_READ_ONLY_MODE",
"-e",
"USE_GITLAB_WIKI",
"-e",
"USE_MILESTONE",
"-e",
"USE_PIPELINE",
"-e",
"USE_VARIABLES",
"ghcr.io/structured-world/gitlab-mcp:latest"
],
"env": {
"GITLAB_TOKEN": "your_gitlab_token",
"GITLAB_API_URL": "https://gitlab.com", // Optional, for self-hosted GitLab
"GITLAB_READ_ONLY_MODE": "false",
"USE_GITLAB_WIKI": "true",
"USE_MILESTONE": "true",
"USE_PIPELINE": "true",
"USE_VARIABLES": "true"
}
}
}
}
- HTTP Server (SSE + StreamableHTTP)
docker run -i --rm \
-e PORT=3002 \
-e GITLAB_TOKEN=your_gitlab_token \
-e GITLAB_API_URL="https://gitlab.com" \
-e GITLAB_READ_ONLY_MODE=true \
-e USE_GITLAB_WIKI=true \
-e USE_MILESTONE=true \
-e USE_PIPELINE=true \
-p 3333:3002 \
ghcr.io/structured-world/gitlab-mcp:latest
For modern MCP clients (recommended):
{
"mcpServers": {
"gitlab": {
"type": "streamable-http",
"url": "http://localhost:3333/mcp"
}
}
}
For legacy SSE clients (backwards compatibility):
{
"mcpServers": {
"gitlab": {
"type": "sse",
"url": "http://localhost:3333/sse"
}
}
}
The GitLab MCP Server automatically selects the appropriate transport mode based on your configuration:
Configuration | Transport Mode | Endpoints Available | Use Case |
---|---|---|---|
PORT env var present | HTTP (Dual) | /sse and /mcp |
Web clients, HTTP-based MCP clients |
No PORT env var | stdio | N/A | Direct MCP communication, CLI usage |
stdio argument |
stdio | N/A | Force stdio mode (overrides PORT) |
HTTP Mode (Dual Transport):
- Runs Express server on specified PORT
- Provides both SSE (
/sse
) and StreamableHTTP (/mcp
) endpoints simultaneously - Perfect for web-based MCP clients and backwards compatibility
- Supports session management and reconnection
stdio Mode:
- Direct stdin/stdout communication
- No HTTP server required
- Optimal for command-line tools and direct MCP protocol usage
- Lower resource usage
GITLAB_TOKEN
: Your GitLab personal access token.GITLAB_API_URL
: Your GitLab API URL. (Default:https://gitlab.com
)GITLAB_PROJECT_ID
: Default project ID. If set, Overwrite this value when making an API request.GITLAB_ALLOWED_PROJECT_IDS
: Optional comma-separated list of allowed project IDs. When set with a single value, acts as a default project (like the old "lock" mode). When set with multiple values, restricts access to only those projects. Examples:- Single value
123
: MCP server can only access project 123 and uses it as default - Multiple values
123,456,789
: MCP server can access projects 123, 456, and 789 but requires explicit project ID in requests
- Single value
GITLAB_READ_ONLY_MODE
: When set to 'true', restricts the server to only expose read-only operations. Useful for enhanced security or when write access is not needed. Also useful for using with Cursor and it's 40 tool limit.GITLAB_DENIED_TOOLS_REGEX
: When set as a regular expression, it excludes the matching tools.GITLAB_API_TIMEOUT_MS
: API request timeout in milliseconds. (Default:20000
- 20 seconds). If GitLab API doesn't respond within this time, the request will be aborted and a timeout error will be returned to the MCP client.USE_GITLAB_WIKI
: When set to 'true', enables the wiki-related tools (list_wiki_pages, get_wiki_page, create_wiki_page, update_wiki_page, delete_wiki_page). Supports both project-level and group-level wikis. By default, wiki features are disabled.USE_MILESTONE
: When set to 'true', enables the milestone-related tools (list_milestones, get_milestone, create_milestone, edit_milestone, delete_milestone, get_milestone_issue, get_milestone_merge_requests, promote_milestone, get_milestone_burndown_events). By default, milestone features are disabled.USE_PIPELINE
: When set to 'true', enables the pipeline-related tools (list_pipelines, get_pipeline, list_pipeline_jobs, list_pipeline_trigger_jobs, get_pipeline_job, get_pipeline_job_output, create_pipeline, retry_pipeline, cancel_pipeline, play_pipeline_job, retry_pipeline_job, cancel_pipeline_job). By default, pipeline features are disabled.USE_LABELS
: When set to 'true', enables the label-related tools (list_labels, get_label, create_label, update_label, delete_label). By default, label features are enabled.USE_MRS
: When set to 'true', enables the merge request-related tools (list_merge_requests, get_merge_request, create_merge_request, update_merge_request, merge_merge_request, get_merge_request_diffs, list_merge_request_diffs, mr_discussions, create_merge_request_thread, create_merge_request_note, update_merge_request_note, create_draft_note, update_draft_note, delete_draft_note, publish_draft_note, bulk_publish_draft_notes, get_draft_note, list_draft_notes). By default, merge request features are enabled.USE_FILES
: When set to 'true', enables the file-related tools (get_file_contents, get_repository_tree, create_or_update_file, push_files, upload_markdown). By default, file operation features are enabled.USE_VARIABLES
: When set to 'true', enables the CI/CD variables-related tools (list_variables, get_variable, create_variable, update_variable, delete_variable). Supports both project-level and group-level variables. By default, variables features are enabled.GITLAB_AUTH_COOKIE_PATH
: Path to an authentication cookie file for GitLab instances that require cookie-based authentication. When provided, the cookie will be included in all GitLab API requests.SKIP_TLS_VERIFY
: When set to 'true', skips TLS certificate verification for all GitLab API requests (both REST and GraphQL). WARNING: This bypasses SSL certificate validation and should only be used for testing with self-signed certificates or trusted internal GitLab instances. Never use this in production environments.
You can customize tool descriptions at runtime using environment variables following the pattern GITLAB_TOOL_{TOOL_NAME}
. This feature is specifically designed to optimize agentic usage by:
- Improving AI agent tool selection - Customize descriptions to match your specific workflows and use cases
- Enhancing semantic clarity - Provide context-specific descriptions that help AI agents understand when to use each tool
- Reducing ambiguity - Replace generic descriptions with precise, workflow-oriented explanations
- Optimizing for your domain - Use terminology and concepts familiar to your AI agents and team
GITLAB_TOOL_{TOOL_NAME}="Your custom description"
Where {TOOL_NAME}
is the uppercase version of the tool name with underscores preserved.
# Customize the list_projects tool description
export GITLAB_TOOL_LIST_PROJECTS="Show all available GitLab projects in our organization"
# Customize the create_merge_request tool description
export GITLAB_TOOL_CREATE_MERGE_REQUEST="Create a new MR following our team's review process"
# Customize the get_file_contents tool description
export GITLAB_TOOL_GET_FILE_CONTENTS="Read source code files from the repository"
# Multiple customizations
export GITLAB_TOOL_LIST_PROJECTS="List user projects"
export GITLAB_TOOL_GET_PROJECT="Get project details including settings"
export GITLAB_TOOL_CREATE_WORK_ITEM="Create tickets for our sprint planning"
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": ["-y", "@structured-world/gitlab-mcp"],
"env": {
"GITLAB_TOKEN": "your_token",
"GITLAB_API_URL": "https://gitlab.com",
"GITLAB_TOOL_LIST_PROJECTS": "Show our team's GitLab projects",
"GITLAB_TOOL_CREATE_MERGE_REQUEST": "Create MR with our review standards",
"GITLAB_TOOL_GET_FILE_CONTENTS": "Read code from repo"
}
}
}
}
- Description Override Only: Only the tool description is overridden - the tool name and functionality remain unchanged
- Schema Preservation: Schema field descriptions are NOT affected - they remain hardcoded for consistency
- Case Sensitivity: Tool names in environment variables must be UPPERCASE (e.g.,
LIST_PROJECTS
notlist_projects
) - Invalid Names: Invalid tool names in environment variables are ignored with a warning in debug logs
- Content Guidelines: Descriptions can be any valid string but should be kept concise for better UX
- Scope: Works with all 86 available tools across all entities (Core, Work Items, Merge Requests, Files, etc.)
85 Tools Available - Organized by entity and functionality below.
- Modular Entity Architecture - Separate entities for Labels, Merge Requests, Files, Pipelines, etc.
- Environment-Gated Features - Enable/disable tool groups with USE_* environment variables
- Work Items Management - Modern GraphQL API for Issues, Epics, Tasks, and more
- Complete GitLab API Coverage - Repository, Merge Requests, Pipelines, Wiki, and more
- Tier-based Feature Detection - Automatically enables features based on your GitLab tier
- Read-only Mode Support - Safe operation mode for production environments
All issue management has been migrated to the Work Items GraphQL API. The legacy REST API issue tools (create_issue
, update_issue
, etc.) have been removed. Use the Work Items tools (create_work_item
, update_work_item
, etc.) instead for better performance and more features.
Removed/Migrated Tools from v2.0
The following issue-related tools have been removed and replaced by Work Items GraphQL API:
create_issue
β Usecreate_work_item
insteadupdate_issue
β Useupdate_work_item
insteaddelete_issue
β Usedelete_work_item
insteadlist_issues
β Uselist_work_items
insteadmy_issues
β Uselist_work_items
with assignee filterget_issue
β Useget_work_item
insteadcreate_issue_link
β Useupdate_work_item
with LINKED_ITEMS widgetdelete_issue_link
β Useupdate_work_item
with LINKED_ITEMS widgetupdate_issue_note
β Useupdate_work_item
with NOTES widgetcreate_issue_note
β Useupdate_work_item
with NOTES widgetlist_issue_links
β Use Work Items GraphQL APIlist_issue_discussions
β Use Work Items GraphQL APIget_issue_link
β Use Work Items GraphQL API
- π = Read-only tool (available in GITLAB_READ_ONLY_MODE)
- βοΈ = Read/Write tool (disabled in GITLAB_READ_ONLY_MODE)
Core GitLab functionality always available.
- βοΈ
create_repository
: Create a new GitLab project - π
get_project
: Get details of a specific project - π
list_projects
: List GitLab projects with flexible scoping. DEFAULT (no group_id): Lists YOUR accessible projects across GitLab (owned/member/starred). GROUP SCOPE (with group_id): Lists all projects within a specific group/organization. Parameters automatically validate based on scope. - π
search_repositories
: Search for GitLab projects - π
list_project_members
: List members of a GitLab project
- βοΈ
create_branch
: Create a new branch in a GitLab project - π
get_branch_diffs
: Get the changes/diffs between two branches or commits in a GitLab project - βοΈ
fork_repository
: Fork a GitLab project to your account or specified namespace
- βοΈ
create_note
: Create a new note (comment) to an issue or merge request - π
download_attachment
: Download an uploaded file from a GitLab project by secret and filename
- π
get_commit
: Get details of a specific commit - π
get_commit_diff
: Get changes/diffs of a specific commit - π
list_commits
: List repository commits with filtering options
- π
get_namespace
: Get details of a namespace by ID or path - π
list_namespaces
: List all namespaces available to the current user - π
verify_namespace
: Verify if a namespace path exists - π
get_users
: Get GitLab user details by usernames
- π
get_project_events
: List all visible events for a specified project. Note: before/after parameters accept date format YYYY-MM-DD only - π
list_events
: List all events for the currently authenticated user. Note: before/after parameters accept date format YYYY-MM-DD only - π
list_group_iterations
: List group iterations with filtering options
Requires USE_LABELS=true environment variable (enabled by default). Supports both project and group labels.
- βοΈ
create_label
: Create a new label in a project or group - βοΈ
update_label
: Update an existing label in a project or group - βοΈ
delete_label
: Delete a label from a project or group - π
get_label
: Get a single label from a project or group - π
list_labels
: List labels for a project or group
Requires USE_MRS=true environment variable (enabled by default).
- βοΈ
create_merge_request
: Create a new merge request in a GitLab project - βοΈ
update_merge_request
: Update a merge request (Either mergeRequestIid or branchName must be provided) - βοΈ
merge_merge_request
: Merge a merge request in a GitLab project - π
get_merge_request
: Get details of a merge request (Either mergeRequestIid or branchName must be provided) - π
get_merge_request_diffs
: Get the changes/diffs of a merge request (Either mergeRequestIid or branchName must be provided) - π
list_merge_request_diffs
: List merge request diffs with pagination support (Either mergeRequestIid or branchName must be provided) - π
list_merge_requests
: List merge requests in a GitLab project with filtering options - π
mr_discussions
: List discussion items for a merge request
- βοΈ
create_merge_request_thread
: Create a new thread on a merge request - βοΈ
create_merge_request_note
: Add a new note to an existing merge request thread - βοΈ
update_merge_request_note
: Modify an existing merge request thread note
- βοΈ
create_draft_note
: Create a draft note for a merge request - βοΈ
update_draft_note
: Update an existing draft note - βοΈ
delete_draft_note
: Delete a draft note - βοΈ
publish_draft_note
: Publish a single draft note - βοΈ
bulk_publish_draft_notes
: Publish all draft notes for a merge request - π
get_draft_note
: Get a single draft note from a merge request - π
list_draft_notes
: List draft notes for a merge request
Requires USE_FILES=true environment variable (enabled by default).
- βοΈ
create_or_update_file
: Create or update a single file in a GitLab project - βοΈ
push_files
: Push multiple files to a GitLab project in a single commit - π
get_file_contents
: Get the contents of a file or directory from a GitLab project - π
get_repository_tree
: Get the repository tree for a GitLab project (list files and directories) - βοΈ
upload_markdown
: Upload a file to a GitLab project for use in markdown content
Requires USE_VARIABLES=true environment variable (enabled by default). Supports both project-level and group-level variables.
- π
list_variables
: List all CI/CD variables for a project or group with their configuration and security settings - π
get_variable
: Get a specific CI/CD variable by key from a project or group, optionally filtered by environment scope - βοΈ
create_variable
: Create a new CI/CD variable for automated deployments and pipeline configuration in a project or group - βοΈ
update_variable
: Update an existing CI/CD variable's value, security settings, or configuration in a project or group - βοΈ
delete_variable
: Remove a CI/CD variable from a project or group
Modern GraphQL API for issues, epics, tasks, and more. Requires USE_WORKITEMS=true (enabled by default).
- βοΈ
create_work_item
: Create a new work item (epic, issue, task, etc.) in a GitLab group - βοΈ
update_work_item
: Update an existing work item - βοΈ
delete_work_item
: Delete a work item - π
get_work_item
: Get details of a specific work item by ID - π
list_work_items
: List work items from a GitLab group with optional filtering by type
Requires USE_GITLAB_WIKI=true environment variable. Supports both project-level and group-level wikis.
- βοΈ
create_wiki_page
: Create a new wiki page in a GitLab project or group - βοΈ
update_wiki_page
: Update an existing wiki page in a GitLab project or group - βοΈ
delete_wiki_page
: Delete a wiki page from a GitLab project or group - π
get_wiki_page
: Get details of a specific wiki page from a project or group - π
list_wiki_pages
: List wiki pages in a GitLab project or group
Requires USE_MILESTONE=true environment variable. Supports both project and group milestones.
- βοΈ
create_milestone
: Create a new milestone in a GitLab project or group - βοΈ
edit_milestone
: Edit an existing milestone in a GitLab project or group - βοΈ
delete_milestone
: Delete a milestone from a GitLab project or group - βοΈ
promote_milestone
: Promote a project milestone to a group milestone - π
get_milestone
: Get details of a specific project or group milestone - π
get_milestone_issue
: Get issues associated with a specific project or group milestone - π
get_milestone_merge_requests
: Get merge requests associated with a specific project or group milestone - π
get_milestone_burndown_events
: Get burndown events for a specific project or group milestone - π
list_milestones
: List milestones in a GitLab project or group with filtering options
Requires USE_PIPELINE=true environment variable.
- βοΈ
create_pipeline
: Create a new pipeline for a branch or tag - βοΈ
retry_pipeline
: Retry a failed or canceled pipeline - βοΈ
cancel_pipeline
: Cancel a running pipeline - βοΈ
play_pipeline_job
: Run a manual pipeline job - βοΈ
retry_pipeline_job
: Retry a failed or canceled pipeline job - βοΈ
cancel_pipeline_job
: Cancel a running pipeline job - π
get_pipeline
: Get details of a specific pipeline in a GitLab project - π
get_pipeline_job
: Get details of a GitLab pipeline job number - π
get_pipeline_job_output
: Get the output/trace of a GitLab pipeline job with optional pagination to limit context window usage - π
list_pipelines
: List pipelines in a GitLab project with filtering options - π
list_pipeline_jobs
: List all jobs in a specific pipeline - π
list_pipeline_trigger_jobs
: List all trigger jobs (bridges) in a specific pipeline that trigger downstream pipelines
The list-tools
CLI utility helps you explore all available GitLab MCP tools, their descriptions, parameters, and tier requirements.
# Install dependencies
yarn install
# Build the project
yarn build
# List all tools with descriptions and tier badges
yarn list-tools
# Show all tools with full parameter details
yarn list-tools --detail
# List tools in simple format (names only)
yarn list-tools --simple
# Show tools for a specific entity
yarn list-tools --entity workitems
yarn list-tools --entity "merge requests"
# Get detailed info for a specific tool
yarn list-tools --tool create_work_item
# Export as JSON for programmatic use
yarn list-tools --json
# Show environment configuration
yarn list-tools --env
# Test with different configurations
GITLAB_READONLY=true yarn list-tools # Show only read-only tools
USE_WORKITEMS=false yarn list-tools # Hide work items tools
-
Tier Badges - Visual indicators for GitLab tier requirements:
- π’ Free - Available in all GitLab tiers
- π‘ Premium - Requires GitLab Premium or higher
- π΄ Ultimate - Requires GitLab Ultimate
-
Parameter Documentation - Shows all input parameters with:
- Parameter name and type
- Required/optional status
- Detailed descriptions
-
Environment Filtering - Respects environment variables:
GITLAB_READONLY
- Show only read-only toolsUSE_*
flags - Enable/disable tool categoriesGITLAB_DENIED_TOOLS_REGEX
- Filter tools by regex pattern
-
Multiple Output Formats:
- Markdown (default) - Human-readable with formatting
- JSON - Machine-readable for automation
- Simple - Just tool names for scripting
# Find all tools related to merge requests
yarn list-tools --entity mrs
# Check what parameters are needed for creating a work item
yarn list-tools --tool create_work_item
# List all available tools with their input schemas (for MCP agents)
yarn list-tools --detail
# Export tool list for documentation
yarn list-tools --json > tools.json
# Verify read-only mode configuration
GITLAB_READONLY=true yarn list-tools --simple | wc -l
This project includes comprehensive integration tests that verify functionality against a real GitLab instance.
# Run all tests (requires .env.test configuration)
yarn test
# Run with verbose output
yarn test --verbose
# Run specific test suites
yarn test tests/integration/data-lifecycle.test.ts
yarn test tests/integration/schemas/workitems.test.ts
For rapid testing of individual MCP tools:
# Test specific tools directly
./scripts/test_mcp.sh '{"name": "list_work_items", "arguments": {"namespacePath": "test"}}'
./scripts/test_mcp.sh '{"name": "get_work_item_types", "arguments": {"namespacePath": "test"}}'
./scripts/test_mcp.sh '{"name": "create_work_item", "arguments": {"namespacePath": "test", "workItemType": "EPIC", "title": "Test Epic"}}'
The test_mcp.sh
script automatically:
- Loads environment from
.env.test
- Sends proper MCP initialization sequence
- Executes your tool call with proper JSON-RPC formatting
- Perfect for debugging individual tools and handlers
- 200+ integration tests running against real GitLab 18.3 Ultimate instance
- Data lifecycle pattern - Creates test infrastructure once, shared across dependent tests
- Work Items CRUD testing - Complete Create/Read/Update/Delete for both Issues and Epics
- Schema validation - All 50+ schemas validated against real API responses
- Dependency chain - Tests run in proper order using
--runInBand
for reliable results
For detailed testing documentation, see TESTING.md.
This GitLab MCP Server is developed and maintained with care for the community. If it saves you time or helps your workflow, consider supporting its continued development!
β Buy me a coffee with USDT (TRC-20)
TFDsezHa1cBkoeZT5q2T49Wp66K8t2DmdA
π± Scan QR code with your wallet (TronLink, Trust Wallet, Exodus, etc.)
Every contribution helps keep this project alive and growing! π
Maintained with β€οΈ by Dmitry Prudnikov Original work by zereight - Thank you for the foundation!