wizard

package
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

browser.go opens the system default browser to the wizard web UI URL, enabling the graphical setup flow.

cli.go implements the non-interactive CLI wizard mode, collecting configuration from command-line flags and stdin without a TUI or web UI.

clients.go defines supported MCP clients (IDEs) and their configuration file formats and paths for wizard-assisted installation.

Package wizard implements an interactive setup wizard that launches when the binary runs in a terminal (double-click, direct execution) rather than as an MCP server via stdio pipe.

dirpicker.go provides an interactive directory picker for selecting IDE configuration paths during wizard setup.

envfile.go reads and writes .env files for storing GitLab credentials and server configuration used by the MCP server.

install.go installs or updates the MCP server entry in IDE configuration files, merging the server JSON block with existing client config.

jsonmerge.go provides a deep-merge function for combining JSON objects, used when inserting or updating MCP server entries in IDE config files.

paths.go resolves platform-specific paths for IDE configuration directories and the user home directory on Linux, macOS, and Windows.

prompt.go handles interactive user input prompts for the wizard, including validation and default value handling.

run.go is the entry point for the setup wizard, dispatching to the appropriate UI mode (TUI, web, or CLI) based on the environment.

tui.go implements the terminal UI (TUI) wizard mode using the Bubble Tea framework for interactive, in-terminal configuration.

webui.go implements the browser-based wizard UI, serving a local HTTP server with embedded assets for graphical MCP server configuration.

wizard.go defines core wizard types, shared state, and the configuration model used across all wizard UI modes.

Index

Constants

View Source
const DefaultGitLabURL = ""

DefaultGitLabURL is pre-filled in UI modes as a convenience default.

View Source
const EnvFileName = ".gitlab-mcp-server.env"

EnvFileName is the name of the env file where secrets are stored.

View Source
const ServerEntryName = "gitlab"

ServerEntryName is the name used for the server entry in all clients.

Variables

View Source
var LogLevelOptions = []string{"debug", "info", "warn", "error"}

LogLevelOptions lists the configurable log levels.

Functions

func Apply

func Apply(w io.Writer, result *Result) error

Apply writes the env file with secrets, then writes MCP configurations for selected clients, and prints a summary. It is called after any UI mode collects user input.

func DefaultBinaryName

func DefaultBinaryName() string

DefaultBinaryName returns the binary name for the current platform.

func DefaultInstallDir

func DefaultInstallDir() string

DefaultInstallDir returns the platform-standard directory for installing binaries.

  • Windows: %LOCALAPPDATA%\gitlab-mcp-server
  • macOS/Linux: ~/.local/bin

func EnvFilePath

func EnvFilePath() string

EnvFilePath returns the path to the env file in the user's home directory.

func ExpandPath

func ExpandPath(path string) (string, error)

ExpandPath expands a leading ~ to the user's home directory.

func GenerateEntry

func GenerateEntry(clientID ClientID, cfg ServerConfig) map[string]any

GenerateEntry returns the JSON-compatible map structure for the "gitlab" server entry, specific to the given client. Secrets (GITLAB_URL, GITLAB_TOKEN, GITLAB_SKIP_TLS_VERIFY) are NOT included in client configs — they live in the env file. VS Code uses native envFile support; other clients rely on the server loading the env file at startup. JetBrains (display-only) still uses the full env map since it cannot load files.

func InstallBinary

func InstallBinary(destDir string) (string, error)

InstallBinary copies the currently running binary to destDir. Returns the full path of the installed binary. Skips copy if the source and destination resolve to the same path.

func IsInteractiveTerminal

func IsInteractiveTerminal() bool

IsInteractiveTerminal reports whether stdin is connected to an interactive terminal (character device) rather than a pipe or file.

func MaskToken

func MaskToken(token string) string

MaskToken returns the first 8 characters of a token followed by asterisks.

func MergeServerEntry

func MergeServerEntry(configPath, rootKey, serverName string, entry map[string]any) error

MergeServerEntry reads an existing JSON config file (or starts fresh), sets the server entry under the given rootKey, and writes the result back. It preserves all other keys in the file.

func RestartHint

func RestartHint(clientID ClientID) string

RestartHint returns a user-friendly hint for how to activate the new config.

func RootKey

func RootKey(clientID ClientID) string

RootKey returns the JSON root key under which the server entry is placed.

func Run

func Run(version string, mode UIMode, r io.Reader, w io.Writer) error

Run executes the setup wizard using the selected UI mode. In "auto" mode it cascades: Web UI → Bubble Tea TUI → plain CLI.

func RunCLI

func RunCLI(version string, r io.Reader, w io.Writer) error

RunCLI executes the interactive setup wizard using plain terminal I/O.

func RunTUI

func RunTUI(version string, w io.Writer) error

RunTUI runs the Bubble Tea interactive setup wizard. It uses the alternate screen buffer to provide a clean full-screen experience.

func RunWebUI

func RunWebUI(version string, w io.Writer) error

RunWebUI starts a local HTTP server and opens the setup wizard in the browser. It blocks until the user completes configuration or the context is cancelled.

func TokenCreationURL

func TokenCreationURL(gitlabURL string) string

TokenCreationURL returns the GitLab URL for creating a personal access token with the "api" scope pre-selected, which is required for full MCP functionality.

func WriteEnvFile

func WriteEnvFile(cfg ServerConfig) (string, error)

WriteEnvFile writes the GitLab secrets to the env file at EnvFilePath(). The file is created with restricted permissions (0600 on Unix, 0644 on Windows).

Types

type ClientID

type ClientID string

ClientID identifies a supported MCP client.

const (
	// ClientVSCode identifies Visual Studio Code with GitHub Copilot MCP configuration.
	ClientVSCode ClientID = "vscode"
	// ClientClaudeDesktop identifies Claude Desktop MCP configuration.
	ClientClaudeDesktop ClientID = "claude-desktop"
	// ClientClaudeCode identifies Claude Code CLI MCP configuration.
	ClientClaudeCode ClientID = "claude-code"
	// ClientCursor identifies Cursor MCP configuration.
	ClientCursor ClientID = "cursor"
	// ClientWindsurf identifies Windsurf MCP configuration.
	ClientWindsurf ClientID = "windsurf"
	// ClientJetBrains identifies JetBrains IDE MCP configuration guidance.
	ClientJetBrains ClientID = "jetbrains"
	// ClientCopilotCLI identifies GitHub Copilot CLI MCP configuration.
	ClientCopilotCLI ClientID = "copilot-cli"
	// ClientOpenCode identifies OpenCode MCP configuration.
	ClientOpenCode ClientID = "opencode"
	// ClientCrush identifies Crush MCP configuration.
	ClientCrush ClientID = "crush"
	// ClientZed identifies Zed editor MCP configuration.
	ClientZed ClientID = "zed"
)

type ClientInfo

type ClientInfo struct {
	ID              ClientID
	Name            string
	ConfigPath      string // resolved config file path ("" for display-only clients)
	DisplayOnly     bool   // true for clients where we print JSON instead of writing a file
	DefaultSelected bool   // true if this client should be pre-selected in the wizard
}

ClientInfo describes an MCP client and how to configure it.

func AllClients

func AllClients() []ClientInfo

AllClients returns the list of supported MCP clients with resolved config paths.

type Prompter

type Prompter struct {
	// contains filtered or unexported fields
}

Prompter handles interactive user input via a reader/writer pair.

func NewPrompter

func NewPrompter(r io.Reader, w io.Writer) *Prompter

NewPrompter creates a Prompter reading from r and writing to w.

func (*Prompter) AskChoice

func (p *Prompter) AskChoice(prompt string, options []string) (int, error)

AskChoice presents numbered options and returns the 0-based selected index.

func (*Prompter) AskMultiChoice

func (p *Prompter) AskMultiChoice(prompt string, options []string, defaults []bool) ([]bool, error)

AskMultiChoice presents checkboxes for multi-select. Returns a boolean slice indicating which options were selected. Accepts space-separated numbers or "a" for all.

func (*Prompter) AskPassword

func (p *Prompter) AskPassword(prompt string) (string, error)

AskPassword prompts for sensitive input. The value is visible in the terminal since we use no TUI library; a warning is shown by the caller.

func (*Prompter) AskPasswordDefault

func (p *Prompter) AskPasswordDefault(prompt, defaultVal string) (string, error)

AskPasswordDefault prompts for sensitive input with a masked default. If the user presses Enter without typing, the existing value is kept.

func (*Prompter) AskString

func (p *Prompter) AskString(prompt string) (string, error)

AskString prompts for a non-empty string. Repeats until non-empty input.

func (*Prompter) AskStringDefault

func (p *Prompter) AskStringDefault(prompt, defaultVal string) (string, error)

AskStringDefault prompts with a default value shown in brackets. Returns the default if the user presses Enter without typing.

func (*Prompter) AskYesNo

func (p *Prompter) AskYesNo(prompt string, defaultYes bool) (bool, error)

AskYesNo prompts for y/n. defaultYes determines the default for empty input.

type Result

type Result struct {
	InstallDir      string
	BinaryPath      string
	Config          ServerConfig
	SelectedClients []int // indices into AllClients()
}

Result holds all data collected from the user by any UI mode.

type ServerConfig

type ServerConfig struct {
	BinaryPath    string
	GitLabURL     string
	GitLabToken   string
	SkipTLSVerify bool
	MetaTools     bool
	AutoUpdate    bool
	LogLevel      string
	YoloMode      bool
}

ServerConfig holds the user's configuration values for the MCP server.

func LoadExistingConfig

func LoadExistingConfig() (ServerConfig, bool)

LoadExistingConfig reads the existing .gitlab-mcp-server.env file and returns a ServerConfig populated with the stored values. If the file does not exist or cannot be parsed, it returns an empty config and false.

type UIMode

type UIMode string

UIMode represents the wizard UI mode.

const (
	// UIModeAuto tries richer interfaces first and falls back to plain CLI.
	UIModeAuto UIMode = "auto" // try web → TUI → CLI
	// UIModeWeb runs the browser-based setup wizard.
	UIModeWeb UIMode = "web"
	// UIModeTUI runs the terminal UI setup wizard.
	UIModeTUI UIMode = "tui"
	// UIModeCLI runs the plain command-line setup wizard.
	UIModeCLI UIMode = "cli"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL