Repository navigation
Add streamable HTTP bridge for the aitools MCP proxy - #7540
Merged
Merged
Conversation
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 12, 2026 12:12
beafb3d to
ad50549
Compare
simonfaltum
changed the base branch from
aitools-mcp/04-add
to
aitools-mcp/05-list-remove
November 12, 2026 12:25
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 12, 2026 12:25
ad50549 to
4ecc28f
Compare
This was referenced Nov 12, 2026
simonfaltum
force-pushed
the
aitools-mcp/05-list-remove
branch
from
November 12, 2026 14:35
7db8c31 to
9967822
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 12, 2026 14:36
4ecc28f to
2f43e8a
Compare
simonfaltum
force-pushed
the
aitools-mcp/05-list-remove
branch
from
November 12, 2026 17:07
9967822 to
3d361ee
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 12, 2026 17:08
2f43e8a to
3c43783
Compare
simonfaltum
force-pushed
the
aitools-mcp/05-list-remove
branch
2 times, most recently
from
November 12, 2026 20:05
6e86c42 to
30b949b
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
2 times, most recently
from
November 12, 2026 22:00
4688f64 to
ed4190f
Compare
simonfaltum
force-pushed
the
aitools-mcp/05-list-remove
branch
from
November 13, 2026 15:05
eb0b033 to
95c5e54
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 13, 2026 15:05
6634449 to
5c42df0
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 16, 2026 12:47
5c42df0 to
ad029dd
Compare
simonfaltum
force-pushed
the
aitools-mcp/05-list-remove
branch
from
November 16, 2026 13:19
789b8ae to
f61d0f6
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
2 times, most recently
from
November 16, 2026 13:32
851225d to
fd9cdef
Compare
simonfaltum
force-pushed
the
aitools-mcp/05-list-remove
branch
from
November 16, 2026 13:32
f61d0f6 to
2427a96
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 16, 2026 14:49
fd9cdef to
6594052
Compare
simonfaltum
force-pushed
the
aitools-mcp/05-list-remove
branch
2 times, most recently
from
November 16, 2026 15:14
451d8a7 to
12cb417
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 16, 2026 15:14
6594052 to
1174f67
Compare
simonfaltum
force-pushed
the
aitools-mcp/05-list-remove
branch
from
November 16, 2026 15:53
12cb417 to
59de987
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 16, 2026 15:53
1174f67 to
2eafa10
Compare
simonfaltum
force-pushed
the
aitools-mcp/05-list-remove
branch
from
November 17, 2026 10:52
59de987 to
406ef75
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 17, 2026 10:52
2eafa10 to
0ca1f43
Compare
simonfaltum
force-pushed
the
aitools-mcp/05-list-remove
branch
from
November 17, 2026 15:11
220a20c to
607c6d0
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
4 times, most recently
from
November 17, 2026 19:58
3294173 to
752ff9c
Compare
Collaborator
✅ Integration test reportCommit: 752ff9c
Top 17 slowest tests (at least 2 minutes):
|
anton-107
approved these changes
Nov 19, 2026
anton-107
left a comment
Contributor
There was a problem hiding this comment.
Approving. I didn't find anything I'd block on. This is a two-way door: the package has no callers yet, keeps no persisted state, and sits behind a hidden command.
What I checked: go test -race -count=3 on the package and GOOS=windows go vet both pass. I also fuzzed eventLines/readEvents against a reference SSE parser with random chunk boundaries (LF, CR, CRLF, leading BOM, comments, other event types; 20k inputs) and numberKey against big.Rat equality (50k pairs). No mismatches. I read the rejoin and replay path, the provisional session, the gates and the shutdown ordering end to end and found no races or lost answers.
Non-blocking notes:
- Unadopted initialize session never ends. If an initialize gets a 2xx with
Mcp-Session-Idbut its stream ends before the result, or idle or shutdown cuts it, that session is never DELETEd. The DELETE deferred indeliverInitializeruns only once an answer arrives. Probe: a 200 SSE withMcp-Session-Id: s-newand only a comment event. The client gets the-32000and no DELETE is ever sent fors-new. Server expiry cleans it up, butforwardcould endx.sessionwhen!x.answered. Authenticateis required, but the field doesn't say so. A nil value panics innewRequest(bridge.go:365), whileTransportdocuments its nil default. One sentence on the field would make the contract clear beforeservewires it.- SSE event left open at EOF. One without a closing blank line is still delivered (
sse.go:54). The SSE spec discards it. This is lenient and documented, so I'm only noting it.
Member
Author
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 19, 2026 11:42
986009a to
f9157d1
Compare
simonfaltum
force-pushed
the
aitools-mcp/05-list-remove
branch
2 times, most recently
from
November 19, 2026 13:39
270baac to
710f6db
Compare
One commit for the restack onto main. The individual commits, up to 986009a, are in the pull request's history. Co-authored-by: Isaac <no-reply@databricks.com>
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 19, 2026 14:16
f9157d1 to
088569a
Compare
simonfaltum
enabled auto-merge
November 19, 2026 14:16
Collaborator
❌ Integration test reportCommit: 65f3314
1333 interesting tests: 1314 MISS, 6 KNOWN, 6 RECOVERED, 5 PANIC, 2 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
…ricks#7550) This pull request is part of a stack that adds the hidden `databricks aitools mcp` command group. It builds on databricks#7540 and adds `aitools mcp serve`, the stdio command that each installed MCP entry runs. ## Changes - `aitools mcp serve --profile <p> --service <full name> [--agent <name>]`, hidden. It runs the binding checks, then bridges stdin and stdout to the service endpoint with the profile's credentials. - Stdout carries only JSON-RPC, so `--output` and a log file on stdout are refused. Binding failures exit 2, except a token failure at startup that is not a rejection, such as a network error or a 5xx. That one says the failure is temporary, gives no login hint, and exits 1. `mcp add` still exits 1 on a binding failure. - A profile with no usable credential at startup, such as one with a host, no `auth_type` and no cached token, gets the login hint and exits 2, as a rejected token does. - Login hints name the config file of a pinned profile through `DATABRICKS_CONFIG_FILE`, with forward slashes at startup as at runtime. `mcp.AuthenticateBound` takes that file, so the bind checks the same file the hint names. - A rejected token fails that request with the login hint, and serve stops with exit 2. A transient token failure (a network error, a timeout, a 5xx from the token endpoint) fails only that request, with no login hint, and serve keeps running. - Each token fetch first checks that the profile still names the bound host and workspace, in the config file it was bound to. A profile re-pointed during the session, for example by `databricks auth login --profile P --host B`, fails that request before any token is fetched, with the binding error. A changed binding is checked again 50 ms later before the request fails, since a write that replaces `.databrickscfg` can hide the profile for a moment. Serve then stops the same way as after a rejected token: later requests fail at once, and it exits 2. - A server with no install record has no `remove` to suggest. Its per-token check holds the profile to the host and workspace serve bound to at start. A missing profile gets the startup setup message, and a host change says to restart the server, which binds the current host. - `cmd/root`: `Execute` closes the log file and restores the default logger on return, also after a panic. ## Why Each entry that `mcp add` writes runs `aitools mcp serve`. It binds to one profile before it reads stdin, so a profile that points elsewhere at start fails with a message instead of sending a token to another host. The token cache is keyed by profile name and records no host, so the binding is checked again before each token fetch, not only at start. ## Decisions to review - Only a rejected token or a changed binding stops the proxy: a 400 or 401 from the token endpoint with `invalid_grant` or `invalid_client`, or the CLI's U2M client reporting an invalid refresh token. Everything else fails only its request, including anything the check cannot classify. The reason is a laptop that wakes before the network is back: stopping there leaves the agent with a dead server until the entry restarts. Cost: an unclassified error keeps failing requests instead of stopping serve. - A changed binding is checked twice, 50 ms apart, before serve stops. Cost: a real re-point stops serve 50 ms later. - A log file that is also stderr is allowed, so `--log-file stdout` works on a Unix terminal. Windows refuses it, because a console is not a regular file there. ## Tests - `cmd/aitools`: a rejected token stops the proxy with exit 2, the hint, and no later token request. A transient failure fails only its request, and the next request succeeds. `TestCredentialRejected` checks each error shape. - `TestRefreshGuardStopsOnBindingChange` and `TestServeProxyRepointedProfileSendsNoToken` check that a re-pointed profile fails before any token fetch and stops serve. `TestCheckBindingWithRetry` covers the second check. - `TestServeBindFailureTokenStatus` covers the startup exit codes, including a missing credential, which exits 2 with the hint. `TestServeBindHostOnlyProfileNeedsLogin` runs the real credential chain on such a profile. - `TestBindingCheckWithoutRecordChecksStartHost` and `TestCheckUnrecordedBindingWordsChangesWithoutRecord` cover the messages for a server with no install record. - `cmd/root`: the stdout refusal, and logger restore after a panic and a normal return. - Acceptance `serve-passthrough` checks each stdout line is one JSON-RPC message; `serve-binding-errors` checks exit 2 and the stderr text. - `go test ./cmd/aitools/ ./libs/aitools/mcp/...` and the `TestAccept/cmd/aitools/mcp/serve` acceptance tests pass. - Not tested: a real token refresh end to end, because the fake cannot fail one. Windows: only `go vet` and a test build ran, so the console behavior is from reading the code. ## How to review Refactors that keep behavior: `serve` takes `add`'s flag names from `mcpconfig`, and its tests and helpers were reshaped in `cmd/aitools/mcp_serve_test.go` and `libs/testserver`. Read closely: `cmd/root/root.go` and `cmd/root/stdout_protocol*.go` for the stdout refusal, `libs/aitools/mcp/proxy/bridge.go` and `run.go` for the token failure paths, and `bindingCheck`, `checkBindingWithRetry`, and the exit status in `cmd/aitools/mcp_serve.go`. 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 is part of a stack, on top of #7549, that adds the hidden
databricks aitools mcpcommand group. This PR adds the stdio-to-HTTP bridge thatservewill use. Nothing calls it yet.Changes
Bridgetype'sRunPOSTs each stdin message's exact bytes to the endpoint and writes each answer to stdout as one line. Requests run concurrently.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.-32000error. A non-2xx body passes through when it is that request's response, such as-32006under 401.initializeandnotifications/initializedare replayed silently, and the old session is replaced only after the replay succeeds.initializethat 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.Bridge.Authenticateis required and must not be nil.Bridge.Transportis optional. Nil meanshttp.DefaultTransport.Why
serverelays 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 returnedMcp-Session-Idoninitialize, andtools/listworked with or without the session headers. The bridge sends both, as the MCP transports specification requires. The transport is injectable so that a profile's TLS settings reach the upstream client.Decisions to review
initializeandnotifications/initialized. Logging levels and subscriptions set later are lost on a session restart.Tests
TestRunAnswersPingDuringReplay,TestRunDeletesSessionReplacedByInitialize,TestReadEvents(CR, BOM),TestReadEventsLimitsEventData.TestRunDeletesSessionOfUnansweredInitializecovers a stream that ends, goes idle, or is cut.TestRunHoldsRequestUntilNotificationWaitFromItsPost,TestRunWritesNothingWhenHookOutputIsInvalid.go test -race -count=5 ./libs/aitools/mcp/proxy/...,GOOS=windows go vetand golangci-lint pass on the package.-32042, which come in a later change. The TLS settings are not exercised, sinceservedoes not build the transport yet. No acceptance test, because no command is wired.This pull request and its description were written by Isaac.