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
1 change: 1 addition & 0 deletions .nextchanges/cli/browser-open-no-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* `databricks auth login` no longer waits for the browser that the default opener starts to close before it continues. ([#7551](https://github.com/databricks/cli/pull/7551))
4 changes: 2 additions & 2 deletions acceptance/cmd/aitools/mcp/add-text/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ genie_one_mcp-logfood system.ai.genie_one_mcp
github-logfood system.ai.github
claude-code installed [TEST_TMP_DIR]/home/.claude.json
cursor installed [TEST_TMP_DIR]/home/.cursor/mcp.json
system.ai.github needs sign-in. Run: databricks aitools mcp login system.ai.github --profile logfood
system.ai.github needs sign-in. Run: DATABRICKS_CONFIG_FILE=[TEST_TMP_DIR]/.databrickscfg databricks aitools mcp login system.ai.github --profile logfood
Public repositories only until a repository owner installs https://github.com/apps/databricks-github-connector (on AWS GovCloud, https://github.com/apps/databricks-gh-connector-gov-cloud).

Cursor may ask you to approve genie_one_mcp-logfood, github-logfood. Run cursor-agent mcp enable <name> for each (`agent` in the Cursor docs), or approve them in Cursor's MCP settings.
Expand All @@ -30,7 +30,7 @@ genie_one_mcp-logfood system.ai.genie_one_mcp
github-logfood system.ai.github
claude-code already installed, re-asserted [TEST_TMP_DIR]/home/.claude.json
cursor already installed, re-asserted [TEST_TMP_DIR]/home/.cursor/mcp.json
system.ai.github needs sign-in. Run: databricks aitools mcp login system.ai.github --profile logfood
system.ai.github needs sign-in. Run: DATABRICKS_CONFIG_FILE=[TEST_TMP_DIR]/.databrickscfg databricks aitools mcp login system.ai.github --profile logfood
Public repositories only until a repository owner installs https://github.com/apps/databricks-github-connector (on AWS GovCloud, https://github.com/apps/databricks-gh-connector-gov-cloud).

=== Cursor config
Expand Down
11 changes: 7 additions & 4 deletions acceptance/cmd/aitools/mcp/help/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ Each agent of a server has one of these statuses. The JSON output uses the same
--profile lists the servers of that profile only. Unmanaged entries have no profile, so they are not
listed then.

This command makes no network calls. It always exits 0 when entries have drifted or cannot be checked;
an entry or agent config that cannot be checked is a warning.
Without --check this command makes no network calls. With --check, a token is requested for each profile,
the sign-in state of each sign-in-required server is read, and the recorded binary is checked. It always exits 0
when entries have drifted or cannot be checked; an entry or agent config that cannot be checked is a warning.

Usage:
databricks aitools mcp list [flags]
Expand All @@ -31,7 +32,8 @@ Examples:
databricks aitools mcp list --output json

Flags:
-h, --help[=true|false] help for list
--check[=true|false] Also check tokens, sign-in state and the recorded binary (uses the network)
-h, --help[=true|false] help for list

Global Flags:
--debug[=true|false] enable debug logging
Expand All @@ -54,7 +56,8 @@ entry, is left in place, and the install record for its agent is dropped. A Data
this CLI is left in place and reported, and a --names run that names its server is refused. When an agent's config
moved, the entry is removed from the file it was written to and from the file the agent reads now.
Entries that run 'aitools mcp serve' without an install record are not chosen by any flag;
'aitools mcp list' shows them as unmanaged. Provider credentials are not deleted.
'aitools mcp list' shows them as unmanaged. Your sign-ins to services are kept; 'aitools mcp logout'
removes one.

Usage:
databricks aitools mcp remove [flags]
Expand Down
7 changes: 6 additions & 1 deletion acceptance/cmd/aitools/mcp/hidden/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ aitools help does not list mcp

>>> [CLI] aitools mcp --help
Databricks managed MCP servers give coding agents tools for Databricks services, such as GitHub or web search.
Use 'add' to install them into coding agents, bound to a Databricks profile.
Use 'add' to install them into coding agents, bound to a Databricks profile, 'list' to see what is installed,
and 'remove' to uninstall them. Some services use your account with an external provider, such as GitHub:
'login' signs you in to one and 'logout' removes the sign-in.

Usage:
databricks aitools mcp [command]

Available Commands:
add Install Databricks managed MCP servers into coding agents
list List Databricks managed MCP servers installed by this CLI
login Sign in to a Databricks managed MCP service with your account
logout Remove your sign-in to a Databricks managed MCP service
remove Remove Databricks managed MCP servers from coding agents

Flags:
Expand Down Expand Up @@ -54,6 +58,7 @@ Flags:
--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

Expand Down
2 changes: 1 addition & 1 deletion acceptance/cmd/aitools/mcp/list-and-remove/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ genie_one_mcp-logfood system.ai.genie_one_mcp

github-logfood system.ai.github
claude-code installed [TEST_TMP_DIR]/home/.claude.json
system.ai.github needs sign-in. Run: databricks aitools mcp login system.ai.github --profile logfood
system.ai.github needs sign-in. Run: DATABRICKS_CONFIG_FILE=[TEST_TMP_DIR]/.databrickscfg databricks aitools mcp login system.ai.github --profile logfood
Public repositories only until a repository owner installs https://github.com/apps/databricks-github-connector (on AWS GovCloud, https://github.com/apps/databricks-gh-connector-gov-cloud).

>>> [CLI] aitools mcp add --profile dogfood --names system.ai.genie_one_mcp --agents claude-code
Expand Down
3 changes: 3 additions & 0 deletions acceptance/cmd/aitools/mcp/list-check/.databrickscfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[logfood]
host = $DATABRICKS_HOST
token = test-token-list-check-$UNIQUE_NAME
1 change: 1 addition & 0 deletions acceptance/cmd/aitools/mcp/list-check/out.test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cloud = false
97 changes: 97 additions & 0 deletions acceptance/cmd/aitools/mcp/list-check/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@

=== Install a service that needs no sign-in and one that does

>>> [CLI] aitools mcp add --profile logfood --names system.ai.genie_one_mcp,system.ai.github --agents claude-code
Profile logfood ([DATABRICKS_URL])
Agents (named with --agents): claude-code

genie_one_mcp-logfood system.ai.genie_one_mcp
claude-code installed [TEST_TMP_DIR]/home/.claude.json

github-logfood system.ai.github
claude-code installed [TEST_TMP_DIR]/home/.claude.json
system.ai.github needs sign-in. Run: DATABRICKS_CONFIG_FILE=[TEST_TMP_DIR]/.databrickscfg databricks aitools mcp login system.ai.github --profile logfood
Public repositories only until a repository owner installs https://github.com/apps/databricks-github-connector (on AWS GovCloud, https://github.com/apps/databricks-gh-connector-gov-cloud).

=== list --check: the token mints, and GitHub needs sign-in

>>> [CLI] aitools mcp list --check
Profile logfood ([DATABRICKS_URL], config file [TEST_TMP_DIR]/.databrickscfg) token ok
genie_one_mcp-logfood system.ai.genie_one_mcp Claude Code
github-logfood system.ai.github Claude Code sign-in needed
to sign in: run `DATABRICKS_CONFIG_FILE=[TEST_TMP_DIR]/.databrickscfg databricks aitools mcp login system.ai.github --profile logfood`

=== Once the sign-in completes, GitHub is signed in

>>> [CLI] api post /api/2.1/unity-catalog/mcp-services/system.ai.github/user-credentials --profile logfood --json {}

>>> [CLI] aitools mcp list --check
Profile logfood ([DATABRICKS_URL], config file [TEST_TMP_DIR]/.databrickscfg) token ok
genie_one_mcp-logfood system.ai.genie_one_mcp Claude Code
github-logfood system.ai.github Claude Code signed in

=== A recorded binary that is gone is reported as missing

>>> [CLI] aitools mcp list --check --output json
{
"profiles": [
{
"profile": "logfood",
"host": "[DATABRICKS_URL]",
"config_file": "[TEST_TMP_DIR]/.databrickscfg",
"status": "ok",
"servers": [
{
"name": "genie_one_mcp-logfood",
"service": "system.ai.genie_one_mcp",
"host": "[DATABRICKS_URL]",
"sign_in_required": false,
"status": "ok",
"agents": [
{
"name": "claude-code",
"path": "[TEST_TMP_DIR]/home/.claude.json",
"status": "installed"
}
],
"check": {
"token": "ok",
"binary": "failed"
}
},
{
"name": "github-logfood",
"service": "system.ai.github",
"host": "[DATABRICKS_URL]",
"sign_in_required": true,
"status": "ok",
"agents": [
{
"name": "claude-code",
"path": "[TEST_TMP_DIR]/home/.claude.json",
"status": "installed"
}
],
"check": {
"token": "ok",
"sign_in": "ok",
"binary": "failed"
}
}
]
}
],
"unmanaged": [],
"warnings": []
}

=== logout ends the sign-in; list --check shows it needed again

>>> [CLI] aitools mcp logout system.ai.github --profile logfood
Signed out of system.ai.github on profile logfood.

>>> [CLI] aitools mcp list --check
Profile logfood ([DATABRICKS_URL], config file [TEST_TMP_DIR]/.databrickscfg) token ok
genie_one_mcp-logfood system.ai.genie_one_mcp Claude Code binary missing
github-logfood system.ai.github Claude Code sign-in needed, binary missing
to sign in: run `DATABRICKS_CONFIG_FILE=[TEST_TMP_DIR]/.databrickscfg databricks aitools mcp login system.ai.github --profile logfood`
28 changes: 28 additions & 0 deletions acceptance/cmd/aitools/mcp/list-check/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Isolate HOME so the agent config files and the state file land in this test directory.
sethome home
mkdir -p home/.claude
envsubst < .databrickscfg > out && mv out .databrickscfg
export DATABRICKS_CONFIG_FILE=.databrickscfg

# The services of system.ai, created in the fake workspace. The fake serves what the scripts create, as in add-text.
MSYS_NO_PATHCONV=1 $CLI api post "/api/2.1/unity-catalog/mcp-services?parent=schemas/system.ai&mcp_service_id=genie_one_mcp" --profile logfood --json '{"comment": "Ask questions about your data"}' &> LOG.create-genie_one_mcp-logfood
MSYS_NO_PATHCONV=1 $CLI api post "/api/2.1/unity-catalog/mcp-services?parent=schemas/system.ai&mcp_service_id=github" --profile logfood --json '{"comment": "Repositories, issues, pull requests", "config": {"source_connection": {"name": "connections/github", "options": {"oauth_provider": "OAUTH_PROVIDER_GITHUB_MCP"}}}}' &> LOG.create-github-logfood

title "Install a service that needs no sign-in and one that does"
trace $CLI aitools mcp add --profile logfood --names system.ai.genie_one_mcp,system.ai.github --agents claude-code

title "list --check: the token mints, and GitHub needs sign-in"
trace $CLI aitools mcp list --check

title "Once the sign-in completes, GitHub is signed in"
MSYS_NO_PATHCONV=1 trace $CLI api post /api/2.1/unity-catalog/mcp-services/system.ai.github/user-credentials --profile logfood --json '{}' > /dev/null
trace $CLI aitools mcp list --check

title "A recorded binary that is gone is reported as missing"
# The state records the binary that add was started with, which is $CLI, as JSON writes it. Both servers record it.
update_file.py home/.databricks/aitools/skills/.state.json "$(python3 -I -c 'import json,sys; print(json.dumps(sys.argv[1])[1:-1])' "$CLI")" /nonexistent/databricks
trace $CLI aitools mcp list --check --output json

title "logout ends the sign-in; list --check shows it needed again"
trace $CLI aitools mcp logout system.ai.github --profile logfood
trace $CLI aitools mcp list --check
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[logfood]
host = $DATABRICKS_HOST
token = test-token-login-flips-active-$UNIQUE_NAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cloud = false
90 changes: 90 additions & 0 deletions acceptance/cmd/aitools/mcp/login-flips-active/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@

=== A service that needs no sign-in exits 0 and says so

>>> [CLI] aitools mcp login system.ai.genie_one_mcp --profile logfood
system.ai.genie_one_mcp does not need sign-in.

=== login prints the sign-in URL and waits; the sign-in completes in the browser

>>> retry --until Waiting for sign-in cat login.txt
Sign in with the same account you use for Databricks profile logfood.
Open this URL to sign in to system.ai.github:
[DATABRICKS_URL]/mcp-service-login?name=system.ai.github&o=[WORKSPACE_ID]
Waiting for sign-in...

>>> [CLI] api post /api/2.1/unity-catalog/mcp-services/system.ai.github/user-credentials --profile logfood --json {}

>>> cat login.txt
Sign in with the same account you use for Databricks profile logfood.
Open this URL to sign in to system.ai.github:
[DATABRICKS_URL]/mcp-service-login?name=system.ai.github&o=[WORKSPACE_ID]
Waiting for sign-in...
Signed in to system.ai.github on profile logfood.
Public repositories only until a repository owner installs https://github.com/apps/databricks-github-connector (on AWS GovCloud, https://github.com/apps/databricks-gh-connector-gov-cloud).

=== login again when already signed in returns at once

>>> [CLI] aitools mcp login system.ai.github --profile logfood --output json
Already signed in to system.ai.github on profile logfood.
Public repositories only until a repository owner installs https://github.com/apps/databricks-github-connector (on AWS GovCloud, https://github.com/apps/databricks-gh-connector-gov-cloud).
{
"service": "system.ai.github",
"profile": "logfood",
"host": "[DATABRICKS_URL]",
"state": "ACTIVE"
}

=== logout removes the sign-in; a second logout finds nothing and still exits 0

>>> [CLI] aitools mcp logout system.ai.github --profile logfood
Signed out of system.ai.github on profile logfood.

>>> [CLI] aitools mcp logout system.ai.github --profile logfood --output json
Not signed in to system.ai.github on profile logfood.
{
"service": "system.ai.github",
"profile": "logfood",
"host": "[DATABRICKS_URL]",
"state": "NOT_SIGNED_IN"
}

=== add --login installs the server and signs in during the same run

>>> retry --until Waiting for sign-in cat add.txt
Profile logfood ([DATABRICKS_URL])
Agents (named with --agents): claude-code

github-logfood system.ai.github
claude-code installed [TEST_TMP_DIR]/home/.claude.json
Public repositories only until a repository owner installs https://github.com/apps/databricks-github-connector (on AWS GovCloud, https://github.com/apps/databricks-gh-connector-gov-cloud).
Sign in with the same account you use for Databricks profile logfood.
Open this URL to sign in to system.ai.github:
[DATABRICKS_URL]/mcp-service-login?name=system.ai.github&o=[WORKSPACE_ID]
Waiting for sign-in...

>>> [CLI] api post /api/2.1/unity-catalog/mcp-services/system.ai.github/user-credentials --profile logfood --json {}

>>> cat add.txt
Profile logfood ([DATABRICKS_URL])
Agents (named with --agents): claude-code

github-logfood system.ai.github
claude-code installed [TEST_TMP_DIR]/home/.claude.json
Public repositories only until a repository owner installs https://github.com/apps/databricks-github-connector (on AWS GovCloud, https://github.com/apps/databricks-gh-connector-gov-cloud).
Sign in with the same account you use for Databricks profile logfood.
Open this URL to sign in to system.ai.github:
[DATABRICKS_URL]/mcp-service-login?name=system.ai.github&o=[WORKSPACE_ID]
Waiting for sign-in...
Signed in to system.ai.github on profile logfood.

>>> jq .mcp | [.servers[] | {name, service, profile, agents: (.agents | keys)}] home/.databricks/aitools/skills/.state.json
[
{
"name": "github-logfood",
"service": "system.ai.github",
"profile": "logfood",
"agents": [
"claude-code"
]
}
]
39 changes: 39 additions & 0 deletions acceptance/cmd/aitools/mcp/login-flips-active/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Isolate HOME so the agent config files and the state file land in this test directory.
sethome home
mkdir -p home/.claude
envsubst < .databrickscfg > out && mv out .databrickscfg
export DATABRICKS_CONFIG_FILE=.databrickscfg
# No browser: the CLI prints the sign-in URL and polls.
export BROWSER=none

# The services of system.ai, created in the fake workspace. The fake serves what the scripts create, as in add-text.
MSYS_NO_PATHCONV=1 $CLI api post "/api/2.1/unity-catalog/mcp-services?parent=schemas/system.ai&mcp_service_id=genie_one_mcp" --profile logfood --json '{"comment": "Ask questions about your data"}' &> LOG.create-genie_one_mcp-logfood
MSYS_NO_PATHCONV=1 $CLI api post "/api/2.1/unity-catalog/mcp-services?parent=schemas/system.ai&mcp_service_id=github" --profile logfood --json '{"comment": "Repositories, issues, pull requests", "config": {"source_connection": {"name": "connections/github", "options": {"oauth_provider": "OAUTH_PROVIDER_GITHUB_MCP"}}}}' &> LOG.create-github-logfood

title "A service that needs no sign-in exits 0 and says so"
trace $CLI aitools mcp login system.ai.genie_one_mcp --profile logfood

title "login prints the sign-in URL and waits; the sign-in completes in the browser"
$CLI aitools mcp login system.ai.github --profile logfood > login.txt 2>&1 &
PID=$!
trace retry --until "Waiting for sign-in" cat login.txt
MSYS_NO_PATHCONV=1 trace $CLI api post /api/2.1/unity-catalog/mcp-services/system.ai.github/user-credentials --profile logfood --json '{}' > /dev/null
wait $PID
trace cat login.txt

title "login again when already signed in returns at once"
trace $CLI aitools mcp login system.ai.github --profile logfood --output json

title "logout removes the sign-in; a second logout finds nothing and still exits 0"
trace $CLI aitools mcp logout system.ai.github --profile logfood
trace $CLI aitools mcp logout system.ai.github --profile logfood --output json

title "add --login installs the server and signs in during the same run"
$CLI aitools mcp add --profile logfood --names system.ai.github --agents claude-code --login > add.txt 2>&1 &
PID=$!
trace retry --until "Waiting for sign-in" cat add.txt
MSYS_NO_PATHCONV=1 trace $CLI api post /api/2.1/unity-catalog/mcp-services/system.ai.github/user-credentials --profile logfood --json '{}' > /dev/null
wait $PID
trace cat add.txt
trace jq '.mcp | [.servers[] | {name, service, profile, agents: (.agents | keys)}]' home/.databricks/aitools/skills/.state.json
rm login.txt add.txt
7 changes: 7 additions & 0 deletions acceptance/cmd/aitools/mcp/login-flips-active/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The background login and add print their sign-in line after a moment, which a slow runner can take longer than the
# retry default of 2.5 seconds to show. The retries wait up to 30 seconds.
Env.RETRY_MAX_ATTEMPTS = "60"
Env.RETRY_INTERVAL_MS = "500"

# The background login and add write these files, and the script removes them.
Ignore = ["login.txt", "add.txt"]
21 changes: 16 additions & 5 deletions cmd/aitools/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,14 +823,25 @@ func forgetStalePluginRecords(ctx context.Context, scope string, items []agentPl
}
}

// topLevelFailure returns the run error when it has no per-agent entry, or nil
// when the failure is already reported per agent — so a per-agent failure is not
// duplicated in the top-level error/errorCategory fields.
// topLevelFailure returns the errors of runErr that have no per-agent entry, joined, or nil when every
// error is a per-agent failure. A per-agent failure is reported in its agent entry and is not repeated in the
// top-level error and errorCategory fields.
func topLevelFailure(runErr error) error {
if _, ok := errors.AsType[*agentErrors](runErr); ok {
if _, ok := errors.AsType[*agentErrors](runErr); !ok {
return runErr
}
// A run error that joins per-agent failures with others keeps the others.
joined, ok := runErr.(interface{ Unwrap() []error })
if !ok {
return nil
}
return runErr
var others []error
for _, err := range joined.Unwrap() {
if _, ok := errors.AsType[*agentErrors](err); !ok {
others = append(others, err)
}
}
return errors.Join(others...)
}

// executePlan carries out the plan and returns each agent's outcome. Skills
Expand Down
Loading
Loading