Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
43c9234
Add aitools mcp login, logout and list --check
simonfaltum Nov 12, 2026
21a4746
Create the Claude Code config dir in the list-check and login accepta…
simonfaltum Nov 12, 2026
9ca8b7a
Update the public-repository note in the login acceptance golden
simonfaltum Nov 12, 2026
4d57631
Read the MCP state from the shared skills state file in login acceptance
simonfaltum Nov 12, 2026
3745c1c
Seed MCP services in the sign-in acceptance tests
simonfaltum Nov 13, 2026
97a649a
Update the MCP golden outputs for the list and add flags
simonfaltum Nov 13, 2026
3dce9f6
Share the sign-in helpers between login, logout and add
simonfaltum Nov 13, 2026
fccdbba
Check the binding in login and logout, and classify their failures
simonfaltum Nov 13, 2026
9cff3c6
Bound the sign-in wait and ignore a FAILED state left by an earlier a…
simonfaltum Nov 13, 2026
3bde911
Sign in to every server in add --login, and keep sign-in failures
simonfaltum Nov 13, 2026
f50a1cf
Report list --check failures as warnings and check each profile in it…
simonfaltum Nov 13, 2026
5075b46
Tidy the sign-in messages and drop the internal references from comments
simonfaltum Nov 13, 2026
84f4173
Acceptance: set MSYS_NO_PATHCONV on the sign-in credential calls and …
simonfaltum Nov 13, 2026
0e144a9
Format and lint the list and login tests
simonfaltum Nov 13, 2026
fab1ace
Escape service names in credential and service requests
simonfaltum Nov 13, 2026
526f116
Refuse service names with URL syntax in login and logout
simonfaltum Nov 13, 2026
e4cb616
Refuse service names with URL syntax in serve
simonfaltum Nov 13, 2026
cf27540
Delete a FAILED sign-in left by an earlier attempt before the page opens
simonfaltum Nov 13, 2026
995402e
Name the unrelated-error check in mapListError
simonfaltum Nov 13, 2026
40fc86d
Treat only the service's own 404 as not found in sign-in
simonfaltum Nov 13, 2026
301d348
Share the service lookup of sign-in commands
simonfaltum Nov 13, 2026
1ab14a2
Check sign-in against the service's requirement in list --check
simonfaltum Nov 13, 2026
09f8a9a
Check the profile's token with a request in list --check
simonfaltum Nov 13, 2026
49a84a6
Report a directory or an empty command as a missing binary in list --…
simonfaltum Nov 13, 2026
fdecdc7
Name the profile in login and logout JSON as soon as it is resolved
simonfaltum Nov 13, 2026
1125343
Keep the run error when login or logout JSON cannot be written
simonfaltum Nov 13, 2026
7d6ac3e
Set the browser explicitly in the sign-in tests that expect it to open
simonfaltum Nov 13, 2026
d3377bf
Poll for the sign-in while the browser command is still running
simonfaltum Nov 13, 2026
07f9353
Send the output of the browser command to stderr during sign-in
simonfaltum Nov 13, 2026
30c17d6
Share the DATABRICKS_CONFIG_FILE prefix of hint commands
simonfaltum Nov 13, 2026
12ed9b3
Name the config file in auth and login hints for a pinned server
simonfaltum Nov 13, 2026
62576d5
Print the add --login sign-in hint once and with the right command
simonfaltum Nov 13, 2026
26a5195
Restore the config file environment in a defer in list --check
simonfaltum Nov 13, 2026
0dcd5dc
Reuse the failed status and group the timeout category with the others
simonfaltum Nov 13, 2026
73ec666
Fix the top-level failure docs, the --login help and the sign-in fixt…
simonfaltum Nov 13, 2026
fec0211
Update the aitools goldens for the pinned hints and the --login help
simonfaltum Nov 13, 2026
2380f66
Order the results of the sign-in test helper as the linter expects
simonfaltum Nov 13, 2026
26d44d6
Expect the resolved config file in the list --check warning test
simonfaltum Nov 13, 2026
898858e
Write pinned config file paths with forward slashes in hints
simonfaltum Nov 13, 2026
1f9885b
Serialize the default browser opener and return when a browser comman…
simonfaltum Nov 13, 2026
fb67ddb
Name the pinned config file in the login hint of a refresh or binding…
simonfaltum Nov 13, 2026
1585c04
Name the file the shell reads in the login hint of an unpinned list -…
simonfaltum Nov 13, 2026
c8e4efc
Let logout remove a credential whose service the profile can no longe…
simonfaltum Nov 13, 2026
e37fe70
Print no login hint after an add --login failure that a login does no…
simonfaltum Nov 13, 2026
3388d61
Report a skipped list --check and the sign-in of a server the service…
simonfaltum Nov 13, 2026
ad2c90e
Synchronize the sign-in test that reads the opened URL, and gate the …
simonfaltum Nov 13, 2026
32aeab8
Describe refused service names in PathSafeName's doc as the commands'…
simonfaltum Nov 13, 2026
19d8c85
Name the profile of a failed state read, and say when login finds the…
simonfaltum Nov 13, 2026
06f2f5b
Document the sign-in commands, switch on the sign-in state, and link …
simonfaltum Nov 13, 2026
b97453f
List the remaining sign-in states explicitly in the switches
simonfaltum Nov 13, 2026
e01c5e2
libs/browser: stub the default launcher in the tests
simonfaltum Nov 13, 2026
8aa98bc
libs/browser: do not wait for the browser the default opener starts
simonfaltum Nov 13, 2026
04c597e
libs/exec: test WithInheritOutputToStderr and correct its doc
simonfaltum Nov 13, 2026
5300253
aitools mcp login: keep polling through server and network errors
simonfaltum Nov 13, 2026
74ff994
aitools mcp login: name the sign-in URL only when the page was shown
simonfaltum Nov 13, 2026
97eacf5
aitools mcp list --check: say how to sign in when a sign-in is needed
simonfaltum Nov 13, 2026
6b00388
aitools mcp list --check: bound each profile and mark only refused to…
simonfaltum Nov 13, 2026
fa645c0
aitools mcp list --check: skip only the servers that cannot be checked
simonfaltum Nov 13, 2026
6bd6bc1
aitools mcp add --login: record each server's sign-in in the JSON doc…
simonfaltum Nov 13, 2026
3e6594c
aitools mcp list: derive the profile token from the servers' checks
simonfaltum Nov 13, 2026
fd51d23
acceptance: keep setup output in LOG files and edit the state with up…
simonfaltum Nov 13, 2026
d5bf45d
aitools, browser: table tests and doc comments
simonfaltum Nov 13, 2026
c69ce88
libs/aitools/mcp: discard the timeout helper's result in a test
simonfaltum Nov 13, 2026
3922c6d
aitools mcp list --check: bound each request, not the whole profile
simonfaltum Nov 13, 2026
8eb4d40
Adapt serve's tests to the rejected-token refresh rule
simonfaltum Nov 13, 2026
4a8c08c
Expect STATE_INVALID for an unreadable state file in mcp login
simonfaltum Nov 13, 2026
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
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 @@ -13,7 +13,7 @@ Cursor may ask you to approve genie_one_mcp-logfood. Run: cursor-agent mcp enabl
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
Cursor may ask you to approve github-logfood. Run: cursor-agent mcp enable github-logfood (the Cursor docs call the CLI agent), or approve it in Cursor's MCP settings.

=== Running it again re-asserts the entries, and nothing is written twice
Expand All @@ -29,7 +29,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

=== Cursor config

Expand Down
2 changes: 2 additions & 0 deletions acceptance/cmd/aitools/mcp/hidden/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ Flags:
--force Overwrite an existing server with the same name that this CLI did not write
-h, --help 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)
--login 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 Do not sign in; print the login commands for sign-in-required servers (default)

Global Flags:
--debug enable debug logging
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

>>> [CLI] aitools mcp add --profile dogfood --names system.ai.genie_one_mcp --agents claude-code
Profile dogfood ([DATABRICKS_URL])
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
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
96 changes: 96 additions & 0 deletions acceptance/cmd/aitools/mcp/list-check/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

=== 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

=== 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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cloud = false
89 changes: 89 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,89 @@

=== 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.

=== 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.
{
"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
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
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.

>>> 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 @@ -758,14 +758,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
12 changes: 12 additions & 0 deletions cmd/aitools/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1822,3 +1822,15 @@ func TestNoAgentsMessageMatchesTheDetection(t *testing.T) {
printNoAgentsMessage(ctx, installInvocation{scope: installer.ScopeGlobal})
assert.Contains(t, stderr.String(), "No supported coding agents found on PATH.")
}

// TestTopLevelFailureKeepsErrorsOutsideAgents checks that a run error which joins per-agent failures with another failure,
// such as a sign-in that failed, keeps the other failure as the document's top-level error.
func TestTopLevelFailureKeepsErrorsOutsideAgents(t *testing.T) {
signInErr := errors.New("sign-in failed")
agentErr := &agentErrors{err: errors.New("agent failed")}

assert.NoError(t, topLevelFailure(agentErr))
top := topLevelFailure(errors.Join(agentErr, signInErr))
require.ErrorIs(t, top, signInErr)
assert.Equal(t, signInErr.Error(), top.Error())
}
3 changes: 3 additions & 0 deletions cmd/aitools/mcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
categoryProfileRequired protos.AitoolsErrorCategory = "PROFILE_REQUIRED"
categoryPermissionDenied protos.AitoolsErrorCategory = "MCP_PERMISSION_DENIED"
categoryLocationNotFound protos.AitoolsErrorCategory = "MCP_LOCATION_NOT_FOUND"
categorySignInTimeout protos.AitoolsErrorCategory = "SIGN_IN_TIMEOUT"
)

// NewMcpCmd returns the `aitools mcp` group. It stays hidden until the whole MCP
Expand All @@ -39,6 +40,8 @@ func NewMcpCmd() *cobra.Command {
cmd.AddCommand(NewMcpAddCmd())
cmd.AddCommand(NewMcpListCmd())
cmd.AddCommand(NewMcpRemoveCmd())
cmd.AddCommand(NewMcpLoginCmd())
cmd.AddCommand(NewMcpLogoutCmd())
cmd.AddCommand(NewMcpServeCmd())
return cmd
}
Expand Down
Loading
Loading