Skip to content

Environment Variables

Complete reference for all environment variables.

Authentication

VariableDescriptionDefault
GITLAB_TOKENGitLab personal access token
GITLAB_API_URLGitLab instance URLhttps://gitlab.com
GITLAB_AUTH_COOKIE_PATHPath to auth cookie file (cookie-based auth)

Project Scope

VariableDescriptionDefault
GITLAB_PROJECT_IDDefault project ID for requests
GITLAB_ALLOWED_PROJECT_IDSComma-separated allowed project IDs

When GITLAB_ALLOWED_PROJECT_IDS is set:

  • Single value (e.g., 123): Acts as default project, restricts to that project only
  • Multiple values (e.g., 123,456,789): Restricts access to listed projects, requires explicit project ID

Access Control

VariableDescriptionDefault
GITLAB_READ_ONLY_MODERestrict to read-only operationsfalse
GITLAB_CROSS_REFSInclude "Related:" cross-references in tool descriptionstrue
GITLAB_DENIED_TOOLS_REGEXRegex to exclude matching tools
GITLAB_DENIED_ACTIONSDisable specific CQRS actions

API Settings

VariableDescriptionDefault
GITLAB_API_TIMEOUT_MSRequest timeout in milliseconds10000
GITLAB_API_RETRY_ENABLEDEnable retry for idempotent ops (GET/HEAD/OPTIONS)true
GITLAB_API_RETRY_MAX_ATTEMPTSMax retry attempts3
GITLAB_API_RETRY_BASE_DELAY_MSBase delay for exponential backoff1000
GITLAB_API_RETRY_MAX_DELAY_MSMax delay cap for backoff4000
SKIP_TLS_VERIFYSkip SSL cert verification (dev only)false

WARNING

SKIP_TLS_VERIFY=true bypasses SSL validation. Use only for testing with self-signed certificates.

Feature Flags

Enable or disable tool groups:

VariableDescriptionDefault
USE_LABELSLabel management toolstrue
USE_MRSMerge request toolstrue
USE_FILESFile browsing and managementtrue
USE_VARIABLESCI/CD variable toolstrue
USE_WORKITEMSWork items (GraphQL API)true
USE_WEBHOOKSWebhook managementtrue
USE_SNIPPETSCode snippet toolstrue
USE_INTEGRATIONSProject integration toolstrue
USE_GITLAB_WIKIWiki page toolstrue
USE_MILESTONEMilestone toolstrue
USE_PIPELINEPipeline and CI/CD job toolstrue
USE_RELEASESRelease management toolstrue
USE_REFSBranch and tag toolstrue
USE_MEMBERSTeam member toolstrue
USE_SEARCHCross-project searchtrue

Server Configuration

VariableDescriptionDefault
PORTHTTP server port (enables HTTP mode)
HOSTServer bind address0.0.0.0

TLS Configuration

VariableDescriptionDefault
SSL_CERT_PATHPEM certificate file path
SSL_KEY_PATHPEM private key file path
SSL_CA_PATHCA certificate chain path
SSL_PASSPHRASEPrivate key passphrase
TRUST_PROXYExpress trust proxy setting

See TLS/HTTPS Configuration for detailed setup guides.

OAuth Configuration

VariableDescriptionDefault
OAUTH_ENABLEDEnable OAuth modefalse
OAUTH_SESSION_SECRETSession secret (min 32 chars)
GITLAB_OAUTH_CLIENT_IDGitLab OAuth application ID
GITLAB_OAUTH_CLIENT_SECRETClient secret (if confidential app)
GITLAB_OAUTH_SCOPESOAuth scopesapi,read_user
OAUTH_TOKEN_TTLToken lifetime in seconds3600
OAUTH_REFRESH_TOKEN_TTLRefresh token lifetime in seconds604800
OAUTH_DEVICE_POLL_INTERVALDevice flow poll interval5
OAUTH_DEVICE_TIMEOUTAuth timeout in seconds300

See OAuth Authentication for setup guide.

Schema Configuration

VariableDescriptionDefault
GITLAB_SCHEMA_MODESchema output format (flat or discriminated)flat

See Customization for schema mode details.

Logging Configuration

VariableDefaultDescription
LOG_LEVELinfoLog level: debug, info, warn, error
LOG_JSONfalseOutput logs as JSON (NDJSON) for log aggregators

Plain Text Mode (default)

Human-readable single-line format suitable for journald, systemd, and console viewing:

bash
# Default - no configuration needed
gitlab-mcp

Output:

[12:34:56.789] INFO: 192.168.1.100 abc123.. mygroup/proj - POST /mcp 200 142ms | browse_projects list | GL:200 98ms | items=15
[12:34:57.123] INFO: Session created

JSON Mode

Full JSON output for log aggregation systems (Loki, Elasticsearch, Datadog):

bash
LOG_JSON=true gitlab-mcp

Output:

json
{"level":30,"time":1737781833989,"name":"gitlab-mcp","msg":"192.168.1.100 abc123.. - - POST /mcp 200 142ms | browse_projects list | GL:200 98ms | items=15","accessLog":{"timestamp":"2026-01-25T04:10:33.989Z","clientIp":"192.168.1.100","session":"abc123..","method":"POST","path":"/mcp","status":200,"durationMs":142,"tool":"browse_projects","action":"list"}}

Each line is a valid JSON object (NDJSON format), suitable for ingestion by log aggregators.

Docker example:

bash
docker run -e LOG_JSON=true -e GITLAB_TOKEN=xxx ghcr.io/structured-world/gitlab-mcp:latest

systemd example:

ini
[Service]
Environment="LOG_JSON=true"
Environment="GITLAB_TOKEN=xxx"
ExecStart=/usr/bin/node /opt/gitlab-mcp/dist/server.js

Released under the Apache 2.0 License.