Skip to content

feat(cli): add interactive setup wizard (gitlab-mcp init)#101

Merged
polaz merged 26 commits intomainfrom
feat/62-init-wizard
Jan 22, 2026
Merged

feat(cli): add interactive setup wizard (gitlab-mcp init)#101
polaz merged 26 commits intomainfrom
feat/62-init-wizard

Conversation

@polaz
Copy link
Copy Markdown
Member

@polaz polaz commented Jan 21, 2026

Summary

Implements interactive setup wizard for first-time users (#62).

  • New module: src/cli/init/ with @clack/prompts for beautiful CLI experience
  • Instance support: GitLab.com SaaS and self-hosted instances
  • Role-based presets: 6 wizard roles mapped to GITLAB_MCP_PRESET values:
    • developerdeveloper
    • senior-developersenior-dev
    • tech-leadfull-access
    • devopsdevops
    • reviewercode-reviewer
    • readonlyreadonly
  • MCP client detection: 8 clients (Claude Desktop, Claude Code, Cursor, VSCode Copilot, Windsurf, Cline, Roo Code, Generic)
  • Auto-configuration: JSON configs with Claude Deep Links, CLI commands for Claude Code
  • Connection validation: Tests GitLab connection before generating config
  • PAT helper: Opens browser with pre-filled token scopes
  • URL normalization: Strips trailing / and /api/v4 from user input

Test plan

  • Unit tests for all modules (96 tests)
  • Coverage > 86% for cli/init files (93.85%)
  • Lint passes
  • Build passes
  • All existing tests pass

Closes #62

- 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
Copilot AI review requested due to automatic review settings January 21, 2026 22:46
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 21, 2026

📊 Test Coverage Report

Overall Coverage: 90.71%

Coverage Details

Metric Percentage
Statements 90.71%
Branches 83.58%
Functions 79.02%
Lines 91.17%

Coverage Report: View detailed coverage report

This report was generated automatically from your PR changes.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 21, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 init subcommand 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.

polaz added 2 commits January 22, 2026 01:19
- 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
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 4 comments.

- 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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.

polaz added 2 commits January 22, 2026 02:19
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
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 5 comments.

polaz added 2 commits January 22, 2026 02:33
- 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
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.

- Fix regex pattern to handle escaped quotes in token values
- Remove misleading comment from test
@polaz polaz requested a review from Copilot January 22, 2026 00:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.

polaz added 2 commits January 22, 2026 10:04
- 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
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.

- Add comment explaining PAT URL uses full scopes before readOnly is known
- Update parseCliArgs mocks to return full CliArgs shape with all fields
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 1 comment.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 1 comment.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 1 comment.

Add 10-second AbortController timeout to prevent hanging on slow
or unresponsive GitLab instances. Includes proper cleanup in finally block.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated no new comments.

@polaz polaz merged commit cb6f080 into main Jan 22, 2026
25 checks passed
@polaz polaz deleted the feat/62-init-wizard branch January 22, 2026 10:40
sw-release-bot bot pushed a commit that referenced this pull request Jan 22, 2026
## [6.26.0](v6.25.0...v6.26.0) (2026-01-22)

### Features

* **cli:** add interactive setup wizard (gitlab-mcp init) ([#101](#101)) ([cb6f080](cb6f080)), closes [#62](#62)
@sw-release-bot
Copy link
Copy Markdown

🎉 This PR is included in version 6.26.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): Interactive setup wizard (gitlab-mcp init)

3 participants