Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion acceptance/cmd/aitools/mcp/help/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ Choose servers with --names (server names as listed by 'aitools mcp list', or se
last part of a service name, such as github, is enough when only one schema has it), --profile
(every server of one profile), or --all. --profile also narrows --names or --all to one profile, and
--agents narrows any of them to some agents.
Interactive selection is not available yet, so one of --names, --profile or --all is required.
In a terminal, with none of --names, --profile or --all, the command shows the installed servers to
choose from. Without a terminal, one of them is required.
With --profile or --all and nothing installed to remove, the command succeeds and removes nothing.

Only entries this CLI wrote are removed. An entry that this CLI did not write, and that is not a Databricks
Expand Down
23 changes: 13 additions & 10 deletions acceptance/cmd/aitools/mcp/hidden/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ Each server runs through 'databricks aitools mcp serve' with that profile's cred

Services come from --names: full names such as system.ai.github, or leaf names such as github. Leaf names
resolve in --location, which defaults to system.ai, or to the one schema that the full names in --names share when there are no leaf names.
Agents come from --agents. Without it, every detected MCP-capable agent is used.
Agents come from --agents.

Interactive selection is not available yet: in a terminal, pass both --names and --agents.
With --output json, both are required.
In a terminal, the command asks for whatever is not given: the profile, the servers and the agents (detected
agents are pre-checked). It confirms the plan when it asked for any of them, and it asks before each sign-in unless
--login or --no-login is given. Without a terminal, --names is required and the agents default to every detected
MCP-capable agent. With --output json, --names and --agents are required.

Supported agents: claude-code, cursor, codex, opencode, copilot, antigravity, gemini

Expand All @@ -54,13 +56,14 @@ Examples:
databricks aitools mcp add --names github,web_search --agents claude-code,cursor --profile dogfood

Flags:
--agents string Agents to install for, comma-separated (default: every detected MCP-capable agent)
--force[=true|false] Overwrite an existing server with the same name that this CLI did not write
-h, --help[=true|false] help for add
--location string Schema to resolve leaf names in, as <catalog>.<schema> (default: system.ai, or the one schema that the full names in --names share when there are no leaf names)
--login[=true|false] Sign in to each sign-in-required server that was installed, after the installs
--name string Server name to use instead of the generated one; only with exactly one service
--names string Services to install: full names (system.ai.github) or leaf names (github), comma-separated
--agents string Agents to install for, comma-separated (default: a picker in a terminal; otherwise every detected MCP-capable agent)
--force[=true|false] Overwrite an existing server with the same name that this CLI did not write
-h, --help[=true|false] help for add
--location string Schema to resolve leaf names in, as <catalog>.<schema> (default: system.ai, or the one schema that the full names in --names share when there are no leaf names)
--login[=true|false] Sign in to each sign-in-required server that was installed, after the installs
--name string Server name to use instead of the generated one; only with exactly one service
--names string Services to install: full names (system.ai.github) or leaf names (github), comma-separated
--no-login[=true|false] Do not sign in; print the login commands for sign-in-required servers (default without a terminal; in a terminal, the default asks for each one)

Global Flags:
--debug[=true|false] enable debug logging
Expand Down
40 changes: 30 additions & 10 deletions cmd/aitools/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import (
"github.com/spf13/cobra"
)

// Prompt text shared by install, uninstall and the mcp commands.
const (
// cancelledMessage is printed when the user declines at a prompt, and the command ends without a change.
cancelledMessage = "Cancelled."
)

// Package-level seams for testability. Tests override these via helpers in
// install_test.go.
var (
Expand Down Expand Up @@ -521,7 +527,7 @@ func defaultPromptAgentSelection(_ context.Context, scope string, choices []agen
var selected []string
field := agentPickerField(scope, options, &selected)
form := huh.NewForm(huh.NewGroup(field)).WithShowHelp(false)
if err := runPicker(form, field.GetFiltering); err != nil {
if err := runPicker(newPicker(form, field.GetFiltering)); err != nil {
return nil, promptError(err)
}
if len(selected) == 0 {
Expand All @@ -548,23 +554,36 @@ func agentPickerField(scope string, options []huh.Option[string], selected *[]st
}

// pickerModel runs a form as huh's Run does, except that Esc cancels it too.
// The install and mcp pickers share it.
type pickerModel struct {
form *huh.Form
// searching reports whether a multi-select in the form is searching. Esc
// then belongs to the form, which leaves the search.
// then belongs to the form, which leaves the search. Nil for a form with no
// search.
searching func() bool
// onKey runs after each message the form takes; nil when nothing depends on
// the keys.
onKey func()
cancelled bool
}

func (p *pickerModel) Init() tea.Cmd { return p.form.Init() }

func (p *pickerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if key, ok := msg.(tea.KeyMsg); ok && key.Type == tea.KeyEsc && !p.searching() {
if key, ok := msg.(tea.KeyMsg); ok && key.Type == tea.KeyEsc && (p.searching == nil || !p.searching()) {
p.cancelled = true
return p, tea.Quit
}
next, cmd := p.form.Update(msg)
p.form = next.(*huh.Form)
if p.onKey != nil {
p.onKey()
// The form renders its fields as it takes a message, so an empty one
// shows what onKey set.
next, refresh := p.form.Update(nil)
p.form = next.(*huh.Form)
return p, tea.Batch(cmd, refresh)
}
return p, cmd
}

Expand All @@ -577,19 +596,20 @@ func (p *pickerModel) View() string {
return p.form.View()
}

// newPicker returns the program of form. Run sets the commands that submit and
// cancel a form, and newPicker sets them too, since it runs the form without Run.
// newPicker returns the program of form, whose search searching reports (nil for
// none). Run sets the commands that submit and cancel a form, and newPicker sets
// them too, since it runs the form without Run.
func newPicker(form *huh.Form, searching func() bool) *pickerModel {
form.SubmitCmd = tea.Quit
form.CancelCmd = tea.Interrupt
return &pickerModel{form: form, searching: searching}
}

// runPicker runs form and returns huh.ErrUserAborted when the user cancels it,
// with Esc or Ctrl+C. It takes the program options huh's Run sets: the picker
// draws on stderr, so a redirected stdout gets none of it, and reports focus.
func runPicker(form *huh.Form, searching func() bool) error {
p := newPicker(form, searching)
// runPicker runs the picker p and returns huh.ErrUserAborted when the user
// cancels it, with Esc or Ctrl+C. It takes the program options huh's Run sets:
// the picker draws on stderr, so a redirected stdout gets none of it, and
// reports focus.
func runPicker(p *pickerModel) error {
_, err := tea.NewProgram(p, tea.WithOutput(os.Stderr), tea.WithReportFocus()).Run()
return pickerError(p.cancelled, err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/aitools/mcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func resolveProfile(ctx context.Context, flagValue string) (string, error) {
case 1:
return profiles[0].Name, nil
}
return "", failure(categoryProfileRequired, "several workspace profiles exist; pass --profile. Found: %s", strings.Join(profiles.Names(), ", "))
return "", failureWithCause(categoryProfileRequired, &profileChoice{profiles: profiles}, "several workspace profiles exist; pass --profile. Found: %s", strings.Join(profiles.Names(), ", "))
}

// mcpWorkspaceProfile reports whether auto-detect may pick p. It accepts the profiles that --profile accepts: a
Expand Down
Loading
Loading