This guide explains how to use @zereight/mcp-gitlab with Claude Code.
Claude Code supports multiple ways to register a local stdio MCP server:
claude mcp add— fastest for personal local setupclaude mcp add-json— useful when you already have JSON config ready- Project
.mcp.json— best when you want a team-shared configuration in version control
- Claude Code installed
- Node.js available in your shell
- GitLab access via either:
- Personal Access Token (PAT), or
- OAuth application for local browser auth
Use an API URL, not the web root:
https://gitlab.com/api/v4https://your-gitlab.example.com/api/v4
This is the fastest path for a local personal setup.
claude mcp add --transport stdio \
--scope local \
--env GITLAB_PERSONAL_ACCESS_TOKEN=glpat-your-token \
--env GITLAB_API_URL=https://gitlab.com/api/v4 \
gitlab -- npx -y @zereight/mcp-gitlabOptional flags you can add as extra --env values:
GITLAB_READ_ONLY_MODE=trueUSE_GITLAB_WIKI=trueUSE_MILESTONE=trueUSE_PIPELINE=true
Useful management commands:
claude mcp list
claude mcp get gitlab
claude mcp remove gitlabInside Claude Code, use:
/mcp
to inspect server status.
Use this for a local browser-based auth flow instead of a PAT.
claude mcp add --transport stdio \
--scope local \
--env GITLAB_USE_OAUTH=true \
--env GITLAB_OAUTH_CLIENT_ID=your-client-id \
--env GITLAB_OAUTH_REDIRECT_URI=http://127.0.0.1:8888/callback \
--env GITLAB_API_URL=https://gitlab.com/api/v4 \
gitlab -- npx -y @zereight/mcp-gitlabIf your GitLab OAuth app is confidential, also add:
--env GITLAB_OAUTH_CLIENT_SECRET=your-client-secretUse this when you want to register a ready-made JSON server config.
PAT example:
claude mcp add-json gitlab '{"type":"stdio","command":"npx","args":["-y","@zereight/mcp-gitlab"],"env":{"GITLAB_PERSONAL_ACCESS_TOKEN":"glpat-your-token","GITLAB_API_URL":"https://gitlab.com/api/v4"}}'OAuth example:
claude mcp add-json gitlab '{"type":"stdio","command":"npx","args":["-y","@zereight/mcp-gitlab"],"env":{"GITLAB_USE_OAUTH":"true","GITLAB_OAUTH_CLIENT_ID":"your-client-id","GITLAB_OAUTH_REDIRECT_URI":"http://127.0.0.1:8888/callback","GITLAB_API_URL":"https://gitlab.com/api/v4"}}'Use a project-scoped config when you want the server definition shared with your team.
Create a .mcp.json file at your project root:
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": ["-y", "@zereight/mcp-gitlab"],
"env": {
"GITLAB_API_URL": "https://gitlab.com/api/v4",
"GITLAB_READ_ONLY_MODE": "false"
}
}
}
}Then add secrets via environment variables in your shell before starting Claude Code.
After the server is loaded, try:
List my GitLab projects.
Wrong:
https://gitlab.com
Correct:
https://gitlab.com/api/v4
Your GitLab OAuth application redirect URI must exactly match:
GITLAB_OAUTH_REDIRECT_URI
If the GitLab app is confidential, GITLAB_OAUTH_CLIENT_SECRET is required.
Use:
claude mcp list
claude mcp get gitlabClaude Code supports multiple scopes:
local— private to you in the current project contextproject— stored in project.mcp.jsonfor sharinguser— available across projects for your user account