gitlab-mcp-server-firasmosbehi
v1.6.0
Published
Model Context Protocol (MCP) server for GitLab: issues, merge requests, repository files, and CI pipelines.
Maintainers
Readme
gitlab-mcp-server
Model Context Protocol (MCP) server for GitLab: issues, merge requests, repository files, and CI pipelines/job logs.
Features
- Project discovery: current user, list projects, project details, branches/tags/labels
- Issues: search/fetch/create/update; list/add notes (comments)
- Merge Requests: list/fetch; list/add notes (comments); discussions/threads (inline-ready); lifecycle (update/approve/merge)
- Repo files: read a file from a ref (branch/tag/sha)
- Repo navigation: list repo tree, search code
- MR context: bounded diff summaries via MR changes
- CI: list pipelines, inspect a pipeline (or latest), list pipeline variables, list pipeline jobs, fetch job logs (plus tail/search), test report summary
- CI actions (guarded): create/trigger pipeline; retry/cancel/play job; retry/cancel pipeline
- Artifacts: fetch artifacts metadata and download artifacts archive (size-limited)
- Write (guarded): create branch, create commit (multi-file actions), create merge request
- MCP: resources (
gitlab://...) and prompts
Install
From npm (recommended):
npm i -g gitlab-mcp-server-firasmosbehiThis installs the gitlab-mcp-server CLI.
From source:
npm install
npm run buildConfiguration
GITLAB_AUTH_MODE(optional):pat|oauth(default:pat)GITLAB_TOKEN(required forpat): GitLab Personal Access TokenGITLAB_TRIGGER_TOKEN(optional): GitLab pipeline trigger token (forgitlab_trigger_pipeline)GITLAB_OAUTH_ACCESS_TOKEN(optional foroauth): GitLab OAuth access tokenGITLAB_OAUTH_TOKEN_FILE(optional foroauth): Path to an OAuth token JSON file (preferred)GITLAB_OAUTH_CLIENT_ID/GITLAB_OAUTH_CLIENT_SECRET/GITLAB_OAUTH_REDIRECT_URI(optional): used for token refresh andgitlab-mcp-server auth ...GITLAB_HOST(optional): defaults tohttps://gitlab.comGITLAB_USER_AGENT(optional): defaults togitlab-mcp-server/<version>LOG_LEVEL(optional):error|warn|info|debug(default:info)
OAuth Helper CLI (Optional)
To generate a token file via browser login (Authorization Code + PKCE):
gitlab-mcp-server auth login --client-id "..." --scopes "read_api" --out ./gitlab-oauth-token.jsonTo refresh an existing token file (if it has refresh_token):
gitlab-mcp-server auth refresh --file ./gitlab-oauth-token.jsonPolicy / Safety
GITLAB_MCP_READ_ONLY(optional):1|true|yesto disable all write tools (default:false)GITLAB_MCP_ENABLED_TOOLS(optional): comma-separated allowlist of tool names to exposeGITLAB_MCP_DISABLED_TOOLS(optional): comma-separated denylist of tool names to hideGITLAB_MCP_WRITE_PROJECT_ALLOWLIST(optional): comma-separated list of allowedprojectvalues for write toolsGITLAB_MCP_HOST_ALLOWLIST(optional): comma-separated list of allowedGITLAB_HOSTvalues (fails fast if not allowed)
Transport (stdio or HTTP)
GITLAB_MCP_TRANSPORT(optional):stdio|http(default:stdio)
When GITLAB_MCP_TRANSPORT=http:
GITLAB_MCP_HTTP_HOST(optional): bind host (default:127.0.0.1)GITLAB_MCP_HTTP_PORT(optional): bind port (default:3000)GITLAB_MCP_HTTP_PATH(optional): MCP endpoint path (default:/mcp)GITLAB_MCP_HTTP_ALLOWED_HOSTS(optional): comma-separated host allowlist for DNS rebinding protectionGITLAB_MCP_HTTP_STATEFUL(optional):true|false(default:true)GITLAB_MCP_HTTP_MAX_SESSIONS(optional): max in-memory sessions when stateful (default:200)GITLAB_MCP_HTTP_BEARER_TOKEN(optional): requireAuthorization: Bearer <token>on all HTTP MCP endpoints
Run Locally
export GITLAB_TOKEN="..."
npm run devBuild and run:
npm run build
npm startTest With MCP Inspector
npx @modelcontextprotocol/inspector node dist/index.jsExample MCP Client Config
Most MCP clients take a stdio command plus environment variables. Example shape:
{
"mcpServers": {
"gitlab": {
"command": "node",
"args": ["./dist/index.js"],
"env": {
"GITLAB_TOKEN": "YOUR_TOKEN_HERE",
"GITLAB_HOST": "https://gitlab.com"
}
}
}
}Docker
docker build -t gitlab-mcp-server .
docker run -e GITLAB_TOKEN="..." gitlab-mcp-serverFor HTTP transport in Docker (example):
docker run -p 3000:3000 \\
-e GITLAB_MCP_TRANSPORT=http \\
-e GITLAB_MCP_HTTP_HOST=0.0.0.0 \\
-e GITLAB_MCP_HTTP_PORT=3000 \\
-e GITLAB_MCP_HTTP_BEARER_TOKEN="change-me" \\
-e GITLAB_TOKEN="..." \\
gitlab-mcp-serverTools
Tool names exposed by this server:
gitlab_get_current_usergitlab_list_projectsgitlab_get_projectgitlab_list_branchesgitlab_list_tagsgitlab_list_project_labelsgitlab_search_issuesgitlab_get_issuegitlab_list_issue_notesgitlab_list_merge_requestsgitlab_get_merge_requestgitlab_list_merge_request_notesgitlab_list_merge_request_discussionsgitlab_get_filegitlab_list_repo_treegitlab_search_codegitlab_list_pipelinesgitlab_get_pipelinegitlab_get_latest_pipelinegitlab_list_pipeline_variablesgitlab_get_pipeline_test_report_summarygitlab_list_pipeline_jobsgitlab_get_job_loggitlab_get_job_log_tailgitlab_search_job_loggitlab_get_job_artifactsgitlab_download_job_artifactsgitlab_get_merge_request_changesgitlab_create_issuegitlab_update_issuegitlab_add_issue_notegitlab_add_merge_request_notegitlab_update_merge_requestgitlab_approve_merge_requestgitlab_unapprove_merge_requestgitlab_create_merge_request_discussiongitlab_add_merge_request_discussion_notegitlab_update_merge_request_discussion_notegitlab_merge_merge_requestgitlab_create_branchgitlab_create_commitgitlab_create_merge_requestgitlab_create_pipelinegitlab_trigger_pipelinegitlab_retry_jobgitlab_cancel_jobgitlab_play_jobgitlab_retry_pipelinegitlab_cancel_pipeline
MCP Resources and Prompts
Resources:
gitlab://helpgitlab://file?project=<...>&ref=<...>&path=<...>gitlab://job-log?project=<...>&job_id=<...>&max_chars=<...>
Prompts:
triage_issuereview_merge_requestdebug_ci_job
Security
Treat GITLAB_TOKEN like a password. Prefer least-privilege tokens and avoid granting write scopes unless you need them.
For OAuth token files, keep the JSON file private (this server writes it with 0600 permissions when possible).
OAuth threat model notes:
- OAuth access tokens are still bearer secrets; protect them the same way as PATs.
- Prefer OAuth over long-lived PATs for remote deployments so you can rotate/revoke tokens centrally.
- If you enable
GITLAB_MCP_TRANSPORT=http, strongly consider settingGITLAB_MCP_HTTP_BEARER_TOKENand restricting allowed hosts.
