Documentation
¶
Overview ¶
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.
Index ¶
- Constants
- Variables
- func Apply(w io.Writer, result *Result) error
- func DefaultBinaryName() string
- func DefaultInstallDir() string
- func EnvFilePath() string
- func ExpandPath(path string) (string, error)
- func GenerateEntry(clientID ClientID, cfg ServerConfig) map[string]any
- func InstallBinary(destDir string) (string, error)
- func IsInteractiveTerminal() bool
- func MaskToken(token string) string
- func MergeServerEntry(configPath, rootKey, serverName string, entry map[string]any) error
- func RestartHint(clientID ClientID) string
- func RootKey(clientID ClientID) string
- func Run(version string, mode UIMode, r io.Reader, w io.Writer) error
- func RunCLI(version string, r io.Reader, w io.Writer) error
- func RunTUI(version string, w io.Writer) error
- func RunWebUI(version string, w io.Writer) error
- func TokenCreationURL(gitlabURL string) string
- func WriteEnvFile(cfg ServerConfig) (string, error)
- type ClientID
- type ClientInfo
- type Prompter
- func (p *Prompter) AskChoice(prompt string, options []string) (int, error)
- func (p *Prompter) AskMultiChoice(prompt string, options []string, defaults []bool) ([]bool, error)
- func (p *Prompter) AskPassword(prompt string) (string, error)
- func (p *Prompter) AskPasswordDefault(prompt, defaultVal string) (string, error)
- func (p *Prompter) AskString(prompt string) (string, error)
- func (p *Prompter) AskStringDefault(prompt, defaultVal string) (string, error)
- func (p *Prompter) AskYesNo(prompt string, defaultYes bool) (bool, error)
- type Result
- type ServerConfig
- type UIMode
Constants ¶
const DefaultGitLabURL = ""
DefaultGitLabURL is pre-filled in UI modes as a convenience default.
const EnvFileName = ".gitlab-mcp-server.env"
EnvFileName is the name of the env file where secrets are stored.
const ServerEntryName = "gitlab"
ServerEntryName is the name used for the server entry in all clients.
Variables ¶
var LogLevelOptions = []string{"debug", "info", "warn", "error"}
LogLevelOptions lists the configurable log levels.
Functions ¶
func Apply ¶
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 ¶
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 ¶
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 MergeServerEntry ¶
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 ¶
RestartHint returns a user-friendly hint for how to activate the new config.
func Run ¶
Run executes the setup wizard using the selected UI mode. In "auto" mode it cascades: Web UI → Bubble Tea TUI → plain CLI.
func RunTUI ¶
RunTUI runs the Bubble Tea interactive setup wizard. It uses the alternate screen buffer to provide a clean full-screen experience.
func RunWebUI ¶
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 ¶
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 ClientID = "vscode" ClientClaudeDesktop ClientID = "claude-desktop" ClientClaudeCode ClientID = "claude-code" ClientCursor ClientID = "cursor" ClientWindsurf ClientID = "windsurf" ClientJetBrains ClientID = "jetbrains" ClientCopilotCLI ClientID = "copilot-cli" ClientOpenCode ClientID = "opencode" ClientCrush ClientID = "crush" 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 ¶
NewPrompter creates a Prompter reading from r and writing to w.
func (*Prompter) AskChoice ¶
AskChoice presents numbered options and returns the 0-based selected index.
func (*Prompter) AskMultiChoice ¶
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 ¶
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 ¶
AskPasswordDefault prompts for sensitive input with a masked default. If the user presses Enter without typing, the existing value is kept.
func (*Prompter) AskString ¶
AskString prompts for a non-empty string. Repeats until non-empty input.
func (*Prompter) AskStringDefault ¶
AskStringDefault prompts with a default value shown in brackets. Returns the default if the user presses Enter without typing.
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.