Repository navigation
Add aitools mcp list and remove - #7549
Conversation
|
Commit: Regression test reportSelected 5 changed tests (limit=20, 0 not selected) 5 tests: regression=5 unreleased=0 coverage=0 failing=0
TestAccept/cmd/aitools/mcp/drift-profile-missing: branch ✅ | main (70d24e3) ❌ | latest (v1.27.0) ❌main (70d24e3): latest (v1.27.0): TestAccept/cmd/aitools/mcp/help: branch ✅ | main (70d24e3) ❌ | latest (v1.27.0) ❌main (70d24e3): latest (v1.27.0): TestAccept/cmd/aitools/mcp/hidden: branch ✅ | main (70d24e3) ❌ | latest (v1.27.0) ❌main (70d24e3): latest (v1.27.0): TestAccept/cmd/aitools/mcp/list-and-remove: branch ✅ | main (70d24e3) ❌ | latest (v1.27.0) ❌main (70d24e3): latest (v1.27.0): 1 more failure details omitted, see the full report in the run. |
✅ Integration test reportCommit: 710f6db
Top 15 slowest tests (at least 2 minutes):
|
99311a2 to
3abce18
Compare
7db8c31 to
9967822
Compare
3abce18 to
7239f89
Compare
9967822 to
3d361ee
Compare
f3c3d22 to
182ccf9
Compare
6e86c42 to
30b949b
Compare
39b5bc1 to
aa53c0e
Compare
eb0b033 to
95c5e54
Compare
aa53c0e to
86996e1
Compare
789b8ae to
f61d0f6
Compare
24cec5b to
3e359a6
Compare
f61d0f6 to
2427a96
Compare
3e359a6 to
73db797
Compare
2427a96 to
451d8a7
Compare
Label `aitools` PRs, the largest group of PRs without a product label. Examples: databricks#7549, databricks#7474, databricks#7667. This pull request and its description were written by Isaac. Co-authored-by: Isaac <no-reply@databricks.com>
451d8a7 to
12cb417
Compare
31cb8ba to
9a1857a
Compare
59de987 to
406ef75
Compare
113a0d4 to
2ad5e5b
Compare
3780ef7 to
8a7c2e3
Compare
64f9579 to
e4be8db
Compare
220a20c to
607c6d0
Compare
763aebd to
2c5b663
Compare
| Use: "remove", | ||
| Short: "Remove Databricks managed MCP servers from coding agents", | ||
| Long: `Remove Databricks managed MCP servers that this CLI installed. | ||
|
|
There was a problem hiding this comment.
The first sentence says --profile "narrows" --all or --names, which reads like it's only a modifier, but the second sentence lists it as a standalone selection (one of --names, --profile or --all is required). remove --profile logfood with no --names or --all removes every server of that profile—could you make that clearer in the first sentence? Something like "Choose servers with --names …, --profile (all servers of one profile), or --all. --profile also narrows --names or --all to one profile, and --agents narrows …" would avoid the double-read.
There was a problem hiding this comment.
Reworded in dd8e7e6: the first sentence now says --profile alone chooses every server of one profile, and that it also narrows --names or --all.
| } | ||
|
|
||
| // checkedBinding returns the binding file of a checked server: the file the check resolved, or the error that stopped it. | ||
| func checkedBinding(check mcp.EntryCheck) bindingFile { |
There was a problem hiding this comment.
When check.Path != "" but check.Err != nil—a config file that resolved but whose profile read failed with an unexpected error—this returns bindingFile{path: check.Path} and drops the error. The ownership check in agentStatus then proceeds as if the config is healthy, because EntryServes only compares paths and doesn't need the profile contents. The result is that the agent entry gets a definite status (installed / modified) instead of unknown, which could surprise a reader. Is silently dropping the error intentional here, or should ownership also report unknown when the entry check itself errored? A one-line comment saying why the error is safe to drop would help either way.
There was a problem hiding this comment.
Intentional. Ownership compares only the entry's service, profile name and config file path (mcp.EntryServes), so it doesn't need the profile's contents, and the agent status is still accurate. The server itself is reported as unknown, with a warning for the config file. Added a comment saying so in 2f27649.
anton-107
left a comment
There was a problem hiding this comment.
Approving. I reviewed only what this PR adds on top of aitools-mcp/04-add, at 2f27649. The unit tests and the cmd/aitools/mcp acceptance tests pass locally, and CI is green. Both earlier bot comments are addressed: the help is reworded, and checkedBinding has its comment.
Two notes, neither blocking:
-
A moved config can hold an unrelated entry with the same name. To reproduce, record
github-logfoodfor Claude Code at~/.claude.json. Then setCLAUDE_CONFIG_DIRto a directory whose.claude.jsonholds the user's owngithub-logfood(npx my-own-github-mcp).listshowsClaude Code (path changed)with no hint.remove --names github-logfoodrefuses, and its hint says to delete that entry by hand or "take the entry over with add --force". Either one destroys the user's own server. Claude Code no longer reads the recorded file, so it looks safe to remove our entry from that file and drop the record. At the least, the hint for an entry that is not a Databricks entry shouldn't suggest deleting it or overwriting it (planRemovalaroundmcp_remove.go:477-485,changedEntryFix). -
A named server that
--agentsnarrows to nothing goes unreported. Runremove --names github-logfood,genie-logfood --agents cursorwithgithub-logfoodinstalled for Claude Code only.github-logfoodis in neitherremovednorskipped, and the command exits 0. Name it alone (--names github-logfood --agents cursor) and you get "no selected MCP server is installed for Cursor". It would be more consistent to report it inskipped, or to refuse it as the single-name case does (mcp_remove.go:166-172,194-196).
|
Thanks, both are fixed:
|
3a2b3bf to
d7e527f
Compare
4e33938 to
270baac
Compare
d7e527f to
742a896
Compare
One commit for the restack onto main. The individual commits, up to 4e33938, are in the pull request's history. Co-authored-by: Isaac <no-reply@databricks.com>
270baac to
710f6db
Compare
❌ Integration test reportCommit: 4f2fda3
1097 interesting tests: 1068 MISS, 11 RECOVERED, 6 PANIC, 6 KNOWN, 6 FAIL
Top 50 slowest tests (at least 2 minutes):
|
This is part of a stack, on top of databricks#7549, that adds the hidden `databricks aitools mcp` command group. This PR adds the stdio-to-HTTP bridge that `serve` will use. Nothing calls it yet. ## Changes - The new `Bridge` type's `Run` POSTs each stdin message's exact bytes to the endpoint and writes each answer to stdout as one line. Requests run concurrently. - A message waits for the notification before it, up to 2 s (`notificationWait`). Each stalled notification can hold the next message for one such wait, so a chain of stalled notifications adds up to 2 s per notification. - A request without a matching response gets a `-32000` error. A non-2xx body passes through when it is that request's response, such as `-32006` under 401. - A 404 for a request with a session id starts a new session. `initialize` and `notifications/initialized` are replayed silently, and the old session is replaced only after the replay succeeds. - An `initialize` that opens a session but whose stream ends, goes idle or is cut before the client gets its answer is followed by a DELETE for that session. Without this, the server kept the session open until it expired. The session is adopted only when the answer has a result. - SSE accepts LF, CR and CRLF line endings and one leading BOM, and limits an event's data to 64 MiB. - A hook's output is checked before any of it is written. Answers to notifications and client responses are not forwarded. - `Bridge.Authenticate` is required and must not be nil. `Bridge.Transport` is optional. Nil means `http.DefaultTransport`. ## Why `serve` relays MCP responses over stdio. The package is separate so an in-process fake endpoint can test it. A probe of a Databricks managed MCP endpoint returned `Mcp-Session-Id` on `initialize`, and `tools/list` worked with or without the session headers. The bridge sends both, as the [MCP transports specification](https://modelcontextprotocol.io/specification/2025-11-25/basic/transports) requires. The transport is injectable so that a profile's TLS settings reach the upstream client. ## Decisions to review - The 10-minute idle watchdog starts before the POST, so it also bounds the wait for response headers. Cost: a plain JSON answer slower than 10 minutes is cut. Starting it after the headers would let a server that never answers hold the request forever. - A request waits up to 2 s for the notification before it, then goes out anyway. Cost: a chain of slow notifications delays the stream by 2 s each. - The replay restores only `initialize` and `notifications/initialized`. Logging levels and subscriptions set later are lost on a session restart. ## Tests - Session recovery and framing: `TestRunAnswersPingDuringReplay`, `TestRunDeletesSessionReplacedByInitialize`, `TestReadEvents` (CR, BOM), `TestReadEventsLimitsEventData`. - Unanswered initialize: `TestRunDeletesSessionOfUnansweredInitialize` covers a stream that ends, goes idle, or is cut. - Ordering: `TestRunHoldsRequestUntilNotificationWaitFromItsPost`, `TestRunWritesNothingWhenHookOutputIsInvalid`. - `go test -race -count=5 ./libs/aitools/mcp/proxy/...`, `GOOS=windows go vet` and golangci-lint pass on the package. - Not tested: sign-in challenges and `-32042`, which come in a later change. The TLS settings are not exercised, since `serve` does not build the transport yet. No acceptance test, because no command is wired. This pull request and its description were written by Isaac. Co-authored-by: Isaac <no-reply@databricks.com>
This pull request is part of a stack that adds the hidden
databricks aitools mcpcommand group, on top of #7544 (aitools mcp add). It addslist, which shows installed servers and their drift, andremove, which deletes only the entries this CLI wrote.Changes
aitools mcp listgroups servers by profile and shows each agent entry asinstalled,changed(addwould write it differently),missing_on_disk,modified,path_changed, orunknown(the entry or its config could not be read). Profile drift isprofile_missingorhost_changed. Entries this CLI did not write are listed as unmanaged. It makes no network calls.aitools mcp removechooses servers with--names,--profileor--all, and narrows agents with--agents. It deletes an entry only when it is the one this CLI wrote.listandremoveoffer no delete oradd --forcehint for such an entry.--namesrun that names its server is refused.--names, a run refuses before anything is written when a named server has a changed Databricks entry, when its records are all for agents this CLI does not know, or when--agentsnarrows it to no agent. It removes nothing and exits 1. The reason is inskipped, or inerrorfor the--agentscase. Records for an unknown agent are kept and reported as skipped, so an older CLI does not drop a newer CLI's records.removetakes the entry from the file the agent now reads, if the record's file lost it.addrecords absolute config paths, soremoverun from another directory finds the same file.servehints namedatabricks aitools mcp remove --names <server>. An empty[DEFAULT]section reads as "no longer exists" instead of "has no host".Why
After
add, nothing shows which servers are installed, whether their profile still exists, or whether an agent config changed under them.removedeletes only what this CLI wrote, so an entry a user wrote under the same name is never touched.Decisions to review
removeedits the file the agent now reads, rather than refusing. Cost: it edits a file the record does not name, under the same ownership check.listfor that agent, while the entry stays in the agent config.--namesmatches a server name exactly, then without case. A service name applies to every profile unless--profilenarrows it.unknown, rather than failinglistand hiding the other agents. Cost: a broken file leaves its servers unchecked until fixed.--namesrun refuses when a named server has a changed Databricks entry, rather than removing the others and exiting 0. Cost: the user reruns without that name to remove the rest.listkeeps showing it. Its hint says to delete the entry by hand, and never offersadd --force, becauseaddrefuses a Databricks entry for another binding whatever--forcesays.Tests
TestBuildMcpListAndRemoveAgreeAfterConfigMovedcovers both moved-config cases.TestSelectInstallsExactServerNameWinscovers name matching.TestRenderMcpListLeavesOtherEntryAlonecovers thelisthint for a non-Databricks entry.TestMcpRemoveDropsRecordOfEntryThisCLIDidNotWrite,TestMcpRemoveDropsRecordWhenMovedConfigHasOtherEntryandTestMcpRemoveLeavesOtherSameNameEntryWhenAgentConfigMovedcover the record drop without a refusal, and leave the other entry untouched.TestMcpRemoveRefusesWhenNamedEntryIsKept,TestMcpRemoveKeepsServerWhenMovedConfigHasChangedDatabricksEntryandTestMcpRemoveRefusesNamedEntryWithOnlyUnknownAgentcover the refusals.TestMcpRemoveRefusesNamedServerThatAgentsNarrowsToNothingcovers the--agentsrefusal.TestMcpRemoveKeepsRecordOfUnknownAgentcovers the kept record.list-and-remove,drift-profile-missingandrepair-and-warningscover text and JSON output.go test ./cmd/aitools/andgo test ./acceptance -run TestAccept/cmd/aitools/mcppass.How to review
Refactors that keep behavior: the agent-config reader and ownership check in
libs/aitools/mcp/agentconfig/(unmanaged.go,writer.go),AbsoluteAsWrittenmoved tolibs/aitools/mcpconfig/abspath.go, and the helpers incmd/aitools/mcp_entries.gothat list and remove share. Read closely:cmd/aitools/mcp_list.gofor statuses and warnings, andcmd/aitools/mcp_remove.gofor selection, the per-copy plan inplanRemoval, and the moved-config path.This pull request and its description were written by Isaac.