feat: add CLI arguments support for configuration #291
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.