feat(cli): add interactive setup wizard (gitlab-mcp init)#101
Merged
Conversation
- Add src/cli/init module with @clack/prompts for interactive CLI - Support GitLab.com and self-hosted instance configuration - Role-based preset selection (6 roles including readonly) - MCP client detection (8 clients including Claude Desktop/Code) - Auto-generate JSON configs with deep links for Claude Desktop - CLI installation for Claude Code (claude mcp add command) - Connection testing before config generation - PAT creation URL generation with pre-filled scopes Closes #62
📊 Test Coverage ReportOverall Coverage: 90.71% Coverage Details
Coverage Report: View detailed coverage report
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Adds an interactive gitlab-mcp init setup wizard to help first-time users configure GitLab MCP across different GitLab instances, roles, and MCP clients.
Changes:
- Introduces a new
src/cli/init/module implementing an interactive setup wizard, connection validation, and config generation. - Adds
initsubcommand parsing and wiring in the main CLI entrypoint. - Adds/updates unit tests to cover the wizard flow, config generation, and connection helpers.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Adds new runtime dependencies used by the init wizard. |
| yarn.lock | Locks new transitive deps for prompts/browser-opening helpers. |
| src/main.ts | Adds init flow entrypoint wiring. |
| src/cli-utils.ts | Adds init subcommand parsing to CLI args. |
| src/cli/init/wizard.ts | Implements the interactive wizard flow (prompts, validation, config output). |
| src/cli/init/connection.ts | Implements URL validation, PAT URL generation, and connection test logic. |
| src/cli/init/config-generator.ts | Generates client configs, CLI commands, and Claude deep link. |
| src/cli/init/types.ts | Defines wizard types and role/client metadata. |
| src/cli/init/index.ts | Exports init module surface for consumers. |
| tests/unit/main.test.ts | Updates main tests to account for new init flag + wizard mock. |
| tests/unit/main.entry.test.ts | Mocks init module to avoid importing wizard deps during entry tests. |
| tests/unit/cli-utils.test.ts | Adds coverage for init subcommand parsing. |
| tests/unit/cli/init/* | Adds unit tests for wizard, connection, config generator, and types. |
- Use strict hostname matching in isGitLabSaas() to prevent substring attacks (notgitlab.com, gitlab.company.com) - Remove unused generateEnvExports function - Make runWizard import lazy to avoid loading dependencies eagerly - Use dynamic import for ESM-only 'open' package in CommonJS context - Add error handling for browser open in headless environments - Use URL-safe Base64 encoding in Claude deep links - Add tests for isGitLabSaas edge cases and URL-safe Base64
- Extract browser utils to separate module for better testability - Use eval-based dynamic import for ESM-only 'open' package in CommonJS - Replace execSync with spawnSync to prevent command injection - Mask PAT tokens in terminal output for security - Update tests to mock browser module properly
Add injectable import function to browser.ts for testability. Add comprehensive tests covering success and error paths. Coverage now 100% for browser.ts.
Ensure index.ts re-exports are covered by tests.
- Fix Linux platform handling in Claude Desktop config path - Add CLI command token masking for terminal output - Add security warning when displaying deep link with encoded token - Update tests to mock spawnSync instead of execSync
- Add shellEscape() for CLI command env values to prevent injection - Add null coalescing for connectionResult.username and error - Add test for shell special character escaping
- Fix regex pattern to handle escaped quotes in token values - Remove misleading comment from test
- Normalize instance URL in wizard (strip trailing / and /api/v4) - Normalize URL in config-generator before writing to GITLAB_API_URL - Rename test from "--init flag" to "init subcommand" - Add return after process.exit for TypeScript/test compatibility - Fix wizard test mocks to use mockReset for consistent state
- Add comment explaining PAT URL uses full scopes before readOnly is known - Update parseCliArgs mocks to return full CliArgs shape with all fields
Add 10-second AbortController timeout to prevent hanging on slow or unresponsive GitLab instances. Includes proper cleanup in finally block.
|
🎉 This PR is included in version 6.26.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
Implements interactive setup wizard for first-time users (#62).
src/cli/init/with @clack/prompts for beautiful CLI experiencedeveloper→developersenior-developer→senior-devtech-lead→full-accessdevops→devopsreviewer→code-reviewerreadonly→readonly/and/api/v4from user inputTest plan
Closes #62