feat: add CLI arguments support for configuration#291
Merged
zereight merged 4 commits intozereight:mainfrom Jan 14, 2026
Merged
feat: add CLI arguments support for configuration#291zereight merged 4 commits intozereight:mainfrom
zereight merged 4 commits intozereight:mainfrom
Conversation
Allows configuration via command-line arguments for MCP clients that don't support environment variables (like GitHub Copilot CLI). CLI arguments take precedence over environment variables. Available arguments: - --token: GitLab Personal Access Token - --api-url: GitLab API URL - --read-only: Enable read-only mode - --use-wiki: Enable wiki API - --use-milestone: Enable milestone API - --use-pipeline: Enable pipeline API Example: npx @zereight/mcp-gitlab --token=glpat-xxx --api-url=https://gitlab.com/api/v4
There was a problem hiding this comment.
Pull request overview
This PR adds CLI argument parsing support to the GitLab MCP server to address compatibility issues with MCP clients that don't properly handle environment variables (such as GitHub Copilot CLI). CLI arguments take precedence over environment variables while maintaining full backward compatibility.
Key Changes:
- Added CLI argument parser at the top of index.ts with
--key=valueand--key valuesyntax support - Created
getConfig()helper function with TypeScript overloads to unify configuration retrieval from CLI args and environment variables - Updated all configuration constants to use
getConfig()instead of directprocess.envaccess
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| package.json | Updated package name to @alfonsodg/mcp-gitlab, bumped version to 2.0.14, and enhanced description to mention CLI args support |
| package-lock.json | Removed "peer: true" flags from various dependencies (npm version update artifact) |
| index.ts | Implemented CLI argument parser, added getConfig() helper function, and migrated all configuration variables to use the new unified config retrieval system |
| README.md | Added new section documenting CLI arguments with usage examples and available argument list for compatibility with clients having environment variable issues |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
|
@alfonsodg Thanks plz resolve conflicts |
- Integrate multi-URL support for GITLAB_API_URL - Add ENABLE_DYNAMIC_API_URL and GITLAB_POOL_MAX_SIZE options - Update HOST default to 127.0.0.1 - Maintain CLI arguments support for all new options - Bump version to 2.0.22
zereight
approved these changes
Jan 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for command-line arguments to configure the GitLab MCP server, solving compatibility issues with MCP clients that don't properly handle environment variables (like GitHub Copilot CLI).
Problem
Some MCP clients have issues with environment variables in server configurations. This makes it impossible to configure the GitLab MCP server in those clients.
Solution
Added CLI argument parsing that takes precedence over environment variables, allowing configuration through command-line arguments.
Changes
Core Changes
index.tsgetConfig()helper function with proper TypeScript overloadsgetConfig()Available CLI Arguments
--token- GitLab Personal Access Token (replacesGITLAB_PERSONAL_ACCESS_TOKEN)--api-url- GitLab API URL (replacesGITLAB_API_URL)--read-only- Enable read-only mode (replacesGITLAB_READ_ONLY_MODE)--use-wiki- Enable wiki API (replacesUSE_GITLAB_WIKI)--use-milestone- Enable milestone API (replacesUSE_MILESTONE)--use-pipeline- Enable pipeline API (replacesUSE_PIPELINE)Documentation
Usage Examples
With environment variables (existing behavior):
{ "mcpServers": { "gitlab": { "command": "npx", "args": ["-y", "@zereight/mcp-gitlab"], "env": { "GITLAB_PERSONAL_ACCESS_TOKEN": "your_token", "GITLAB_API_URL": "https://gitlab.com/api/v4" } } } }With CLI arguments (new feature):
{ "mcpServers": { "gitlab": { "command": "npx", "args": [ "-y", "@zereight/mcp-gitlab", "--token=your_token", "--api-url=https://gitlab.com/api/v4" ] } } }Backward Compatibility
✅ Fully backward compatible - All existing configurations using environment variables will continue to work without any changes.
Testing
Benefits
Related Issues
Fixes compatibility with GitHub Copilot CLI and similar MCP clients that have environment variable handling issues.