Repository navigation
Add MCP state records, drift check and profile binding checks - #7537
Merged
Merged
Conversation
simonfaltum
force-pushed
the
aitools-mcp/03-state
branch
2 times, most recently
from
November 12, 2026 11:57
e003f2d to
99f703a
Compare
simonfaltum
force-pushed
the
aitools-mcp/03-state
branch
from
November 12, 2026 12:11
99f703a to
39c0dec
Compare
simonfaltum
force-pushed
the
aitools-mcp/02-discovery
branch
from
November 12, 2026 14:24
773f68b to
93a7090
Compare
simonfaltum
force-pushed
the
aitools-mcp/03-state
branch
from
November 12, 2026 14:25
39c0dec to
acc3ee6
Compare
Collaborator
✅ Integration test reportCommit: 01d1905
Top 7 slowest tests (at least 2 minutes):
|
simonfaltum
force-pushed
the
aitools-mcp/02-discovery
branch
from
November 13, 2026 15:05
93a7090 to
a4521da
Compare
simonfaltum
force-pushed
the
aitools-mcp/03-state
branch
from
November 13, 2026 15:05
1dade3d to
03c01a0
Compare
simonfaltum
force-pushed
the
aitools-mcp/03-state
branch
from
November 16, 2026 12:47
03c01a0 to
8356812
Compare
simonfaltum
force-pushed
the
aitools-mcp/02-discovery
branch
from
November 16, 2026 12:47
a4521da to
833aeaa
Compare
simonfaltum
force-pushed
the
aitools-mcp/03-state
branch
3 times, most recently
from
November 16, 2026 14:49
94587e4 to
a9c735c
Compare
simonfaltum
force-pushed
the
aitools-mcp/02-discovery
branch
from
November 16, 2026 14:49
20af1c2 to
68461a5
Compare
simonfaltum
force-pushed
the
aitools-mcp/03-state
branch
2 times, most recently
from
November 17, 2026 10:52
fa4d812 to
13dc173
Compare
simonfaltum
force-pushed
the
aitools-mcp/02-discovery
branch
2 times, most recently
from
November 17, 2026 12:02
1a3cc65 to
7350da2
Compare
simonfaltum
force-pushed
the
aitools-mcp/03-state
branch
from
November 17, 2026 12:02
13dc173 to
3233f8f
Compare
simonfaltum
force-pushed
the
aitools-mcp/02-discovery
branch
from
November 17, 2026 12:36
5fedd5e to
f1ff0ee
Compare
simonfaltum
force-pushed
the
aitools-mcp/03-state
branch
2 times, most recently
from
November 17, 2026 15:11
2d1b8f3 to
1d8c127
Compare
simonfaltum
marked this pull request as ready for review
November 18, 2026 16:20
anton-107
approved these changes
Nov 19, 2026
anton-107
left a comment
Contributor
There was a problem hiding this comment.
No blocking findings. I checked the order Bind runs in against SDK v0.199.0. ResolveNonAuthFromEnv skips the host, the auth attributes and workspace_id, so cfg.Host and the credential come only from the profile section, and both are checked before EnsureResolved contacts the host. A file that holds only MCP records loads as no install on every LoadState path: version, scope, update, uninstall, the legacy guard and plugin records. Older CLIs read schema v3 without a version check. Unit tests pass locally and CI is green on Linux, macOS and Windows.
Non-blocking notes:
- Losing records disables the drift check. An older CLI that saves the shared file drops the
mcpsection, as the description says. After that,servetakes the "No install record" path and binds to whatever host the profile names now. The check fails open, andremovecan no longer find the entry. This is worth keeping in mind for how strict the no-record path should be onceaddships. binding.go:83:ctx = env.Set(ctx, mcpconfig.ConfigFileEnv, configFile)doesn't seem to reach anything. The loaders usecfg.ConfigFileor the process env, and the doc comment says the token store reads the process env. Either drop it or name who reads it.profileGoneErrorandconfigFileErrorhardcodeDATABRICKS_CONFIG_FILEin their messages. They could usemcpconfig.ConfigFileEnv, now that this PR adds it.- A config-file mismatch reports
PROFILE_HOST_CHANGED. A separate category would be easier to tell apart in later telemetry. This one is optional.
Member
Author
|
Thanks! On the notes:
|
simonfaltum
force-pushed
the
aitools-mcp/02-discovery
branch
from
November 19, 2026 11:42
09e8767 to
b5f9653
Compare
simonfaltum
force-pushed
the
aitools-mcp/03-state
branch
from
November 19, 2026 11:42
9bc1ae9 to
5191786
Compare
One commit for the restack onto main. The individual commits, up to 9bc1ae9, are in the pull request's history. Co-authored-by: Isaac <no-reply@databricks.com>
simonfaltum
force-pushed
the
aitools-mcp/03-state
branch
from
November 19, 2026 12:33
5191786 to
01d1905
Compare
simonfaltum
enabled auto-merge
November 19, 2026 12:34
Collaborator
❌ Integration test reportCommit: a96c087
1295 interesting tests: 1277 MISS, 8 KNOWN, 5 PANIC, 5 FAIL
Top 50 slowest tests (at least 2 minutes):
|
idelafuente-oc
pushed a commit
to idelafuente-oc/cli
that referenced
this pull request
Nov 20, 2026
…#7544) This pull request is part of the stack that adds the hidden `databricks aitools mcp` command group. It builds on databricks#7537 and adds `aitools mcp add`, which installs Databricks managed MCP servers into coding agents non-interactively, bound to one CLI profile. ## Changes - `aitools mcp add --names ... --agents ...` installs full names (`system.ai.github`) or leaf names into the named agents, or into every detected agent without `--agents`. Leaf names resolve in `--location`, which defaults to `system.ai` or to the one schema the full names share. A leaf next to full names outside `system.ai` is refused. - Refusals that need no request come first: flags, unknown or non-MCP agents, the binary name, a profile that is missing, has no host, or is account-level (refused before any credential is sent), a server whose profile changed, and a name held by another server or by an entry this CLI did not write, unless `--force`. - A named agent that is not installed is refused. `InstalledForMCP` counts an agent as installed when its config directory, skills, MCP file or a binary on PATH is present. A home variable (`CODEX_HOME`, `COPILOT_HOME`, `CLAUDE_CONFIG_DIR`, `GEMINI_CLI_HOME`, `XDG_CONFIG_HOME`) set away from its default leaves only the MCP file's directory to count. - `--name` and stored names over 32 characters (`mcp.MaxServerNameLen`) are refused, as are invalid names. - A name conflict refuses the run for a named agent, and fails only that agent for a detected one. An agent that already holds the server's binding under another name refuses the run either way, since a second entry would run the same server twice; the error says which entry to remove or rename. - Entries run `databricks aitools mcp serve`, with `DATABRICKS_CONFIG_FILE` pinned when it is set. The binary path comes from argv at run time, made absolute when possible. When PATH finds it only in the working directory (`exec.ErrDot`, which Windows returns), the running executable's absolute path is used. Otherwise the output notes that agents must find `databricks` on PATH. - A sole profile whose host names its workspace in `?w=` is auto-detected. On Windows, a drive-relative path is refused unless it is on the working directory's drive. - The read-only refusal suggests `--agents` only for named agents. A successful add prints the service's note, if it has one. ## Why Coding agents cannot use Databricks managed MCP servers yet. The state and agent-config writers from the earlier PRs need a command that calls them. The group stays hidden until `serve` lands, so no release ships an entry that cannot start. ## Decisions to review - A conflict in a detected agent skips that agent for one server, and the run continues. Cost: no top-level error for it. `add` still fails when a requested service reaches no agent. - A missing or host-less profile is refused by the check `serve` runs, so both commands print the same text. Without an install record it names the service and how to set it up, with no `remove` hint. - `UNKNOWN_AGENT` covers a known agent that is not installed. No telemetry category fits. - A stored name held by another state entry has no `--force` override. - An agent whose binary is on PATH counts as installed, so `add` creates its config directory on the first write. - A server whose profile changed is refused, never rebound. ## How to review Refactors, no behavior change: `Bind` is split into `CheckBinding`, `BoundConfig` and `AuthenticateBound` (`libs/aitools/mcp/binding.go`). The exported helpers are `ResolveConfigFile` and `AbsoluteAsWritten` (`configfile.go`), `ErrProfileMissing` (`state.go`), `SystemAILocation` (`known.go`), and `mcpconfig.EnvKeys` (`mcpconfig/spec.go`). New behavior, to read closely: `FindEntry` (`binding.go`), now exported, matches services ignoring case, as Unity Catalog names do, and `Bind` inherits that; `cmd/aitools/mcp_add.go` (`planAdds`, `chooseName`, `locationOf`, `agentFailureError`), `libs/aitools/agents/agents.go` (`InstalledForMCP`, `mcpHomeMoved`), `cmd/aitools/mcp.go` (`mcpWorkspaceProfile`), and the drive-relative rule in `AbsoluteAsWritten`. ## Tests - Unit, `cmd/aitools`: name planning and conflicts, refusals before any request, recording when one server fails, distinct agent failures, and which agents count as installed. - Unit, `libs/aitools`: the MCP-home presence rule, the profile check with no entry, and `EntryEnv`. - Acceptance `acceptance/cmd/aitools/mcp/`: two services and agents, text and JSON output, two profiles, an unparsable config, an uninstalled agent, and the hidden group. - `go test -race` on `cmd/aitools` and `libs/aitools`, the aitools acceptance tests, `GOOS=windows go vet`, golangci-lint and `./task checks` pass. - Not tested: `serve` (a later PR), the picker, and real agent processes. This pull request and its description were written by Isaac. Co-authored-by: Isaac <no-reply@databricks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request is part of a stack, on top of #7538, that adds the hidden
databricks aitools mcpcommand group. It adds MCP state records, drift checks and profile binding checks. Nothing calls them yet.Changes
mcpsection of the aitools state file (schema v3). A file with only MCP records counts as no install. Installer saves keep the section. Uninstall andSaveMCPStateremove the file once nothing remains.Reconcilereportsprofile_missingandhost_changed, using the host and workspace the SDK resolves, with no network.Bindchecks the profile before it resolves credentials, so a re-pointed host is never contacted.UNCATEGORIZED. Only failed authentication isAUTH_FAILED.BindError.ExitCode()returns 2, which theservePR maps to the process exit status.Why
A proxy must refuse to start when its profile was deleted or re-pointed, or an agent would silently use the wrong workspace. It must never send another workspace's credential.
Decisions to review
mcpsection on its next save, and itsuninstalldeletes a file that holds only MCP records.PROFILE_HOST_CHANGED, rather than printing the no-record notice, because binding through this file would switch the server silently. ChangingDATABRICKS_CONFIG_FILEmeans removing and adding the server again.~/.databrickscfg, notDATABRICKS_CONFIG_FILE.DATABRICKS_TOKENor other auth variables into the profile. A profile without a token uses the SDK chain for its host.profile.WithHost. A profile that drops its workspace selector is not detected, since the recorded ID may come from the API.ServerNameandcapServerNamefrom Add MCP service discovery, known services and naming for aitools #7538 produce them, and agents name toolsmcp__<name>__<tool>, which users' allow rules match, so changing either function later renames the tools of every existing install.Tests
TestBindHostChangedDoesNotContactNewHostfails if a re-pointed host gets a request.TestBindWorkspaceFollowsSDKResolutioncovers the host query.TestBindEntryInOtherConfigFileFailsClosedandTestBindNeverUsesEnvTokenForProfileWithoutTokencover the config-file and credential rules.TestUninstallRemovesLeftoverFilesWithoutSkills,TestUpdateAfterPruningEverySkillAddsNewSkillsandTestInstallSpecificSkillWithEmptyStateFilepass on main's behavior, which users without MCP records keep.TestLoadStateHidesOnlyMCPOnlyFilesandTestUninstallKeepsStateFileWithMCPRecordscover the shared file.experimental/aitoolsandcmd/aitoolsacceptance tests (goldens unchanged),GOOS=windows go vet,golangci-lintandtask checks.This pull request and its description were written by Isaac.