Some MCP clients (like GitHub Copilot CLI) don't pass environment variables reliably. For those clients, configure the server with CLI arguments instead.
CLI arguments take precedence over environment variables.
Install the server once:
brew tap zereight/gitlab-mcp https://github.com/zereight/gitlab-mcp
brew install zereight/gitlab-mcp/zereight-mcp-gitlabOr with npm:
npm install -g @zereight/mcp-gitlabNo global install? Pin npx to the previous stable release and keep the server flags after it, for example npx -y @zereight/mcp-gitlab@2.1.58 --token=.... Use @zereight/mcp-gitlab@latest if you always want the newest release.
{
"mcpServers": {
"gitlab": {
"command": "zereight-mcp-gitlab",
"args": ["--token=YOUR_GITLAB_TOKEN", "--api-url=https://gitlab.com/api/v4"],
"tools": ["*"]
}
}
}Deprecation notice:
--read-only=trueandGITLAB_READ_ONLY_MODEare kept for backward compatibility but will be removed in a future major version. Use--permission-mode=readonlyorGITLAB_PERMISSION_MODE=readonlyinstead.
Subcommands are not MCP server flags. They run and exit without starting the MCP server.
Run GitLab's OAuth Device Authorization Grant (GitLab 17.9+; 17.2–17.8 need
oauth2_device_grant_flow) and store a token at ~/.gitlab-mcp-token.json
(or GITLAB_OAUTH_TOKEN_PATH). This complements the existing localhost
callback flow; it does not replace it.
zereight-mcp-gitlab auth --client-id YOUR_APP_ID
zereight-mcp-gitlab auth --client-id YOUR_APP_ID --api-url https://gitlab.example.com/api/v4
zereight-mcp-gitlab auth --helpAfter auth succeeds, start the MCP server with GITLAB_USE_OAUTH=true and the
same client ID. If you use --token-path, set GITLAB_OAUTH_TOKEN_PATH to the
same path when you start the server. See OAuth2 Authentication Setup Guide.
For the full list of configuration options, see Environment Variables.
