Repository navigation
Add aitools mcp login, logout and list --check - #7551
Conversation
f4c096c to
62d20d0
Compare
|
Commit: Regression test reportSelected 6 changed tests (limit=20, 0 not selected) 6 tests: regression=6 unreleased=0 coverage=0 failing=0
TestAccept/cmd/aitools/mcp/add-text: branch ✅ | main (cb94103) ❌ | latest (v1.27.0) ❌main (cb94103): latest (v1.27.0): TestAccept/cmd/aitools/mcp/help: branch ✅ | main (cb94103) ❌ | latest (v1.27.0) ❌main (cb94103): latest (v1.27.0): TestAccept/cmd/aitools/mcp/hidden: branch ✅ | main (cb94103) ❌ | latest (v1.27.0) ❌main (cb94103): latest (v1.27.0): TestAccept/cmd/aitools/mcp/list-and-remove: branch ✅ | main (cb94103) ❌ | latest (v1.27.0) ❌main (cb94103): latest (v1.27.0): 2 more failure details omitted, see the full report in the run. |
✅ Integration test reportCommit: e6ae53a
Top 28 slowest tests (at least 2 minutes):
|
eec9d1a to
5b1d279
Compare
62d20d0 to
d7c9aec
Compare
5b1d279 to
9187003
Compare
d7c9aec to
d2dd977
Compare
9187003 to
48fac6f
Compare
0aa7987 to
a08bc42
Compare
7064bbc to
10450c9
Compare
a08bc42 to
4a8c08c
Compare
10450c9 to
9ec98a0
Compare
8ef469f to
d779ae1
Compare
9ec98a0 to
1d09e53
Compare
d779ae1 to
43bb551
Compare
1d09e53 to
01b4249
Compare
43bb551 to
e441c85
Compare
01b4249 to
11e6e00
Compare
e441c85 to
60bf035
Compare
2a9b99f to
c7d75cb
Compare
109bc73 to
661f21e
Compare
c7d75cb to
0b9a961
Compare
a4d1a39 to
14af751
Compare
f2e0cd4 to
e41d98d
Compare
9abcc11 to
79d56db
Compare
anton-107
left a comment
There was a problem hiding this comment.
Approving: I found nothing that blocks the merge. I reviewed only what this PR adds on top of aitools-mcp/06b-serve (c5aa08b). At 79d56db, the touched packages pass with -race (libs/aitools/mcp, libs/browser, libs/exec, cmd/aitools, libs/testserver), and so does TestAccept/cmd/aitools/mcp.
The change is reversible. aitools mcp is still hidden, and the state file format doesn't change. The one change everyone sees is that the default browser.Open now returns when the launcher exits, and that is easy to revert.
Non-blocking notes:
PathSafeNamerefuses more names than the API does. Unity Catalog names may contain%,#and?; only., space,/and control characters are forbidden.serviceResourceNamealready escapes the name withurl.PathEscape, sologin,logoutand nowserverefuse names the request would handle correctly. Thesystem.aiservices don't use these characters, so this only matters for a custom schema. Refusing just/and control characters would be enough.- A DEGRADED credential keeps waiting without being reset.
SignIndeletes a FAILED credential before opening the page, but a DEGRADED one is kept and the wait starts.list --checkreports DEGRADED as "sign-in needed". Is there a check against the real API that the provider page turns a DEGRADED credential back to ACTIVE without a delete first? If it can't, the user waits the full 5 minutes. add --loginreports the not-required state inconsistently. InsignInInstalled, a server that doesn't need sign-in getssign_in: {state: NOT_REQUIRED}even when it reached no agent. A server that needs sign-in and reached no agent gets nosign_inat all. CheckinginstalledAnywherebefore the not-required branch would make the two cases match.- A failed sign-in appears twice in the
add --loginJSON: inservers[].sign_in.errorand in the top-levelerror.TestTopLevelFailureKeepsErrorsOutsideAgentsshows this is intended. Mentioning it in the JSON contract would help consumers know they can read either.
|
Thanks!
|
49ed447 to
57552af
Compare
171374b to
ad9ad88
Compare
One commit for the restack onto main. The individual commits, up to 49ed447, are in the pull request's history. Co-authored-by: Isaac <no-reply@databricks.com>
57552af to
e6ae53a
Compare
❌ Integration test reportCommit: 4285bf9
1256 interesting tests: 1231 MISS, 9 RECOVERED, 6 PANIC, 6 KNOWN, 4 FAIL
Top 50 slowest tests (at least 2 minutes):
|
…databricks#7553) This pull request is part of a stack that adds the hidden `databricks aitools mcp` command group, on top of databricks#7551. A service that needs provider sign-in rejects `tools/list` until the user signs in, so the agent has no tool to start it. The proxy now offers one `authenticate` tool that runs the sign-in. ## Changes - A challenge makes `tools/list` return only `authenticate`. A challenge is a JSON-RPC `-32006`, a `-32042` answer with a sign-in URL, or an error result that names a sign-in URL. A `-32042` URL is accepted on the profile's host, or on any host whose `o=` or `w=` query names the bound workspace. - On a server that needs sign-in, a 401 is a challenge only when its body asks for sign-in. Any other 401 gets the `databricks auth login` hint. A server that needs no sign-in has no such handling, so its 401 passes through unchanged. - A challenged `tools/call` names `authenticate` and the login command. If `tools/list` still passes, `authenticate` is added to its first page until a call succeeds or the sign-in completes. - If the service still challenges after an "Already signed in" answer, a challenged `tools/call` is answered with the `mcp logout` command to run first, since neither `authenticate` nor `login` can fix it then. - `authenticate` runs `login`'s sign-in, sends progress naming the page, and sends `tools/list_changed` when signed in. A timeout names the URL, the last failed check and the login command. - The known-service note is printed by `mcp add`, by `mcp login` and by the authenticate tool's sign-in. `mcp list` does not read it. - The proxy never deletes an active credential. `SignIn` deletes a FAILED or DEGRADED one before it shows the page. - The page opens with no stdin, since stdin carries the protocol, and stays open when the request is cancelled. - A server with an install record takes its workspace ID from the record, so its sign-in makes no request for it. - A server with no install record reads the service at start. A rejected token there exits 2 with the login hint. ## Why Discovery fails before sign-in, so the agent can only start a sign-in through a tool that exists before it. A rejected Databricks token is not fixed by a provider sign-in, so it gets the login hint instead. ## Decisions to review - No automatic recovery when a credential reads as active but the service keeps rejecting it. Deleting and re-creating an active credential would also delete working ones, for example while the gateway catches up with a sign-in just made in a terminal. Cost: a stale provider grant needs one `mcp logout`. - A 401 that does not ask for sign-in is an auth failure, whatever its body. Cost: a gateway that answers a missing provider sign-in with a bare 401 gets the login hint instead of a sign-in. - A page is not reopened after a cancelled attempt that showed it, so a retry does not open a second tab. ## Tests - `libs/aitools/mcp/proxy/challenge_test.go` covers the challenge bodies, 401s, call-only challenges, the logout answer, page reopening, queued and cancelled calls, and progress. `TestSignInRequiredNamesTheLogoutWhileStillChallenged` covers the logout answer after "Already signed in". - `TestServeSignInUsesTheRecordedWorkspaceID` covers the workspace ID taken from the record. - Acceptance `serve-authenticate-tool` runs the stdio flow with `BROWSER=none`. - `go test -race ./cmd/aitools/ ./libs/aitools/mcp/...`, the `TestAccept/cmd/aitools/mcp` acceptance tests and `GOOS=windows go vet` on the same packages pass. - Not tested: a live `-32042` challenge, and a real browser. ## How to review Refactors that keep behavior: the sign-in path that `mcp login` and the proxy share (`libs/aitools/mcp/login.go`, `cmd/aitools/mcp_serve.go`), and the shared JSON-RPC response envelope in `libs/aitools/mcp/proxy/`. Read closely: `libs/aitools/mcp/proxy/challenge.go` (new), its `Result` method and the 401 rule, and `serveChallenge` in `cmd/aitools/mcp_serve.go`. This pull request and its description were written by Isaac. Co-authored-by: Isaac <no-reply@databricks.com>
## Release v1.28.0 ### CLI * Retry transient errors in `fs` commands: `fs cp` to a UC Volume from another Volume or DBFS (files up to 8 MiB) on HTTP 503, DBFS uploads when the upload stream is lost, and stat, read and list on UC Volumes on HTTP 500. ([#7607](#7607), [#7763](#7763), [#7839](#7839)) * `databricks auth profiles --skip-validate` now omits the `Valid` column instead of reporting `NO` for every profile. ([#7638](#7638)) * Fix Ctrl-C taking about 10 seconds to stop `databricks aitools install`, `update` or `uninstall` while it runs a coding agent's CLI, and retry reading an agent's config on Windows while the agent rewrites it. ([#7832](#7832), [#7870](#7870)) * Automatic installation of Databricks AI tools no longer asks in containers or installs for the first time without a terminal, no longer runs as root in another user's home, keeps newer skills you installed, no longer hints to install what it is about to install, and on Linux and macOS stops the calling script on Ctrl-C. ([#7828](#7828), [#7834](#7834), [#7874](#7874), [#7888](#7888), [#7890](#7890), [#7901](#7901)) * Wait before retrying a failed automatic install of Databricks AI tools, starting at 5 minutes and doubling after each failure, so a skills source or coding agent CLI that stays broken no longer slows down each of the next commands. ([#7900](#7900)) * `databricks aitools install` now cancels the agent picker on Esc. ([#7721](#7721)) * `databricks aitools uninstall --skills` now fails when its value names no skill instead of removing every skill, and `aitools update` and `uninstall` no longer prompt when a coding agent runs them; with skills in both scopes they fail and ask for `--scope`. ([#7873](#7873)) * `databricks aitools install --skills-only` and `databricks aitools update` no longer mix skill files with the Databricks plugin: install skips agents that already have the plugin, and update no longer replaces skill files from a `--skills-only` install made with this release or later while the agent's CLI was on PATH. To keep skill files from an earlier `--skills-only` install, run `databricks aitools install --skills-only` again with the agent's CLI on PATH. ([#7831](#7831), [#7903](#7903)) * `apps init` no longer suggests installing skills to Codex and Copilot users who installed the Databricks plugin with `databricks aitools install`. ([#7830](#7830)) * Fix `databricks auth login` failing with `data passed to Set was too big` on macOS and Windows for OAuth tokens too large for one keyring item. ([#7845](#7845)) * Fix the token storage mode (`auth_storage`) being read from the file named by `DATABRICKS_CONFIG_FILE` instead of the config file the profile was loaded from. ([#7733](#7733)) * `databricks auth login` no longer waits for the browser that the default opener starts to close before it continues. ([#7551](#7551)) * Allow `databricks auth docker configure` when several profiles match one workspace; the chosen profile is recorded for the registry and shown by `databricks auth docker host`. ([#7383](#7383)) * Show the HTTP status, error code and endpoint when an API error has no message, instead of a bare `Error: `, and the HTTP status and path for Files API errors that used to show an empty `databricks-api error:`. ([#7800](#7800), [#7839](#7839)) * AI agents can now submit feedback without confirmation; `--yes`/`-y` is deprecated, and agents passing `--yes=false` now get an error. ([#7795](#7795)) * Log `/.well-known/databricks-config` fetch failures with a transient HTTP status (408, 429, or 5xx other than 501) at debug level instead of as a warning, like timeouts. ([#7912](#7912)) * Fix interactive list output sometimes dropping or reordering a page of rows. ([#7804](#7804), [#7914](#7914)) * Allow `databricks sandbox forward` to forward remote ports below 10000. The sandbox refuses a few reserved platform ports with an error that names the port. ([#7861](#7861)) * Breaking: `databricks sandbox ssh` now uses local SSH keys and works with sandboxes created through the SDK or API; it no longer accepts `--port` and needs Python 3 and `openssh-server` in the sandbox. Add `databricks sandbox ssh-setup` to configure native SSH and SCP. ([#7588](#7588), [#7589](#7589), [#7590](#7590)) * `databricks ssh connect` to serverless CPU compute now defaults to environment version 5, so the first connection after upgrading starts a new server; pass `--environment-version 4` to keep the old one. ([#7847](#7847)) * `databricks ssh connect` now downloads the SSH server binaries from PyPI when GitHub is unreachable, using `PIP_INDEX_URL` or `index-url` from the per-user pip config over HTTPS only, and checks SHA-256 digests. ([#7852](#7852)) ### AI Runtime * Breaking: `compute.pool_id` is no longer accepted in AIR workload YAML; use `compute.accelerator_pool_id`. ([#7698](#7698)) * `databricks air convert-to-dabs` handles an existing output directory better: it gives the right guidance when the directory already holds the workload's bundle, `--force` no longer replaces a different bundle or an alternate root file, re-converting removes stale sidecars, and git-pinned code outside the bundle gets an `--output-dir` suggestion. ([#7835](#7835), [#7853](#7853), [#7857](#7857), [#7866](#7866)) * `air list` and `air get` now find the AI Runtime task anywhere in a multi-task job; a job with several such tasks lists one row per task (so `run_id` is no longer unique in `air list -o json`), and both report `task_key` (`air get --task-key` selects one). `air list --all-status` now orders runs by submission time instead of by their latest attempt's start. ([#7632](#7632)) * Update fallback messages for pending AI Runtime runs when AIR does not report a status reason. ([#7899](#7899)) * `air run -o json` now reports config-validation errors as a JSON error envelope, with `UNAUTHENTICATED`, `INVALID_ARGS` or the new `PERMISSION_DENIED` code. ([#7864](#7864)) ### Bundles * Bundle commands no longer hang after a request timeout on a dead HTTP/2 connection. ([#7723](#7723)) * Fix a panic when the local Terraform state is removed after it is pulled and before it is migrated to the direct engine, for example by a concurrent `bundle deploy`. ([#7778](#7778)) * The direct deployment engine now uses a Lakebase or postgres catalog that a failed create request still created, instead of failing the deploy. ([#7801](#7801)) * `bundle deploy` and `bundle run` for apps now succeed when the app's compute is already active or starting, and deploy the app when the deployment triggered by start failed. ([#7709](#7709), [#7780](#7780)) * Add `thumbnail_path` to the `apps` resource, so `bundle deploy` sets, updates and deletes the thumbnail shown for the app in the Apps UI. ([#7728](#7728)) * Fix bundle commands failing on a notebook or file path with a colon in its first segment, such as the default workspace notebook name `New Notebook 2026-10-28 12:17:43.ipynb`. ([#7851](#7851)) * `bundle run` and `pipelines run` now retry transient errors from the pipeline events and update status reads while waiting for an update. ([#7800](#7800)) ### Dependency Updates * Bump dependencies with known vulnerabilities. ([#7904](#7904)) * Update the Go SDK to [v0.203.0](https://github.com/databricks/databricks-sdk-go/releases/tag/v0.203.0). ([#7869](#7869), [#7906](#7906)) * Update `github.com/databricks/sdk-go/files` to [v0.9.0](https://github.com/databricks/sdk-go/blob/files/v0.9.0/files/CHANGELOG.md). ([#7889](#7889))
Part of a stack that adds the hidden
databricks aitools mcpcommand group, on #7550 (aitools mcp serve). It adds provider sign-in for external MCP services such as GitHub, which each user signs in to before the service's tools work.Changes
mcp login <service>prints the sign-in URL, opens it throughlibs/browser, and waits up to 5 minutes. Server and network errors while polling are retried until the timeout, which names the last one. An already signed-in caller gets "Already signed in" and no URL.mcp logout <service>deletes the caller's credential, even when its service is no longer visible.loginandlogoutrefuse a changed profile before any request./or a control character. Other URL syntax, such as?,#and%, is escaped in the request and is allowed.mcp add --loginsigns in to each sign-in-required server that reached an agent. Its JSON gains a per-serversign_inobject, given only to servers that reached an agent; a server that does not need sign-in getsNOT_REQUIRED. A failed sign-in is reported in bothservers[].sign_in.errorand the top-levelerror, which is intended, so consumers can read either. The command exits 1 and keeps the installs.mcp list --checkchecks each profile's token, then each server. A drifted server or one that cannot be read is skipped, and says why. Each check request ends after 5 seconds. A needed sign-in names the login command.DATABRICKS_CONFIG_FILE.libs/browsergainsOpenOutputToStderr, and its default opener no longer waits for a browser its launcher leaves running.Why
A sign-in is judged on the attempt that runs, so a FAILED or DEGRADED credential left by an earlier attempt is deleted before the page opens. A failed poll does not mean the user has left the provider's page, so it does not end the wait. One unreachable workspace held
list --checkfor the SDK's five-minute retry budget.Decisions to review
SignInreturns(alreadySignedIn, urlShown bool, err error), not a state. The command derives the JSON state and URL from them.?,#or%are accepted, rather than refused locally. Cost: such names reach the API.list --checksetsDATABRICKS_CONFIG_FILEin the process environment while it checks a profile, because the token store reads the process environment.logoutsends the DELETE before it looks up the service, so a credential for a deleted service can be removed. Cost: a mistyped name costs one request.Tests
TestOpenDoesNotWaitForLauncherChildinlibs/browserfailed before the fix.cmd/aitools:TestAddChecksBoundsAProfileThatNeverAnswershung past five minutes before the fix.libs/aitools/mcp.TestSignInDeletesDegradedCredentialcovers the DEGRADED deletion.TestPathSafeNameandTestServiceNameAllowsEscapedURLSyntaxcover the name check.TestSignInInstalledRecordsTheSignInOfEachServercoverssign_infor a server that reached no agent.list-checkandlogin-flips-activepass.go test -race ./cmd/aitools/ ./libs/aitools/mcp/...andGOOS=windows go veton the same packages pass.How to review
Refactors that keep behavior: the sign-in helpers shared by
login,logoutandadd --login(libs/aitools/mcp/login.go,cmd/aitools/mcp_login.go). Read closely: the poll loop inlibs/aitools/mcp/login.go, the bounded checks incmd/aitools/mcp_list.go, and the default opener inlibs/browser/browser.go, which changes howbrowser.Openwaits.This pull request and its description were written by Isaac.