Repository navigation
Add aitools mcp serve, the stdio proxy for managed MCP servers - #7550
Draft
simonfaltum wants to merge 39 commits into
Draft
simonfaltum wants to merge 39 commits into
simonfaltum wants to merge 39 commits into
Conversation
simonfaltum
force-pushed
the
aitools-mcp/06b-serve
branch
from
November 12, 2026 12:37
694ba3c to
c3af024
Compare
Contributor
|
Commit: Regression test reportSelected 15 changed tests (limit=20, 0 not selected) 15 tests: regression=15 unreleased=0 coverage=0 failing=0
TestAccept/cmd/aitools/mcp/add-agent-not-installed: branch ✅ | main (bf8caad) ❌ | latest (v1.26.0) ❌main (bf8caad): latest (v1.26.0): TestAccept/cmd/aitools/mcp/add-default-config: branch ✅ | main (bf8caad) ❌ | latest (v1.26.0) ❌main (bf8caad): latest (v1.26.0): TestAccept/cmd/aitools/mcp/add-name-notices: branch ✅ | main (bf8caad) ❌ | latest (v1.26.0) ❌main (bf8caad): latest (v1.26.0): TestAccept/cmd/aitools/mcp/add-text: branch ✅ | main (bf8caad) ❌ | latest (v1.26.0) ❌main (bf8caad): latest (v1.26.0): TestAccept/cmd/aitools/mcp/add-two-agents: branch ✅ | main (bf8caad) ❌ | latest (v1.26.0) ❌main (bf8caad): latest (v1.26.0): 10 more failure details omitted, see the full report in the run. |
Collaborator
✅ Integration test reportCommit: b52879a
Top 16 slowest tests (at least 2 minutes):
|
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/06b-serve
branch
from
November 12, 2026 14:37
eec9d1a to
5b1d279
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/06b-serve
branch
from
November 12, 2026 17:10
5b1d279 to
9187003
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/06b-serve
branch
from
November 13, 2026 00:15
9187003 to
48fac6f
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/06b-serve
branch
from
November 13, 2026 15:05
7064bbc to
10450c9
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/06b-serve
branch
from
November 16, 2026 12:47
10450c9 to
9ec98a0
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 16, 2026 13:19
ad029dd to
851225d
Compare
simonfaltum
force-pushed
the
aitools-mcp/06b-serve
branch
from
November 16, 2026 13:19
9ec98a0 to
1d09e53
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 16, 2026 13:32
851225d to
fd9cdef
Compare
simonfaltum
force-pushed
the
aitools-mcp/06b-serve
branch
from
November 16, 2026 13:32
1d09e53 to
01b4249
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/06b-serve
branch
2 times, most recently
from
November 16, 2026 15:14
11e6e00 to
2a9b99f
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/06b-serve
branch
from
November 16, 2026 15:53
2a9b99f to
c7d75cb
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
2 times, most recently
from
November 17, 2026 10:52
2eafa10 to
0ca1f43
Compare
simonfaltum
force-pushed
the
aitools-mcp/06b-serve
branch
2 times, most recently
from
November 17, 2026 11:21
0b9a961 to
e653041
Compare
The check ran after initializeContext had installed the stdout logger, so a refused command still wrote its telemetry debug line to stdout. It now runs inside initializeContext, after the log file opens and before the default logger is set, and it closes the refused file. The log file is also recorded on the context here, so Execute closes it after the last log line. Co-authored-by: Isaac <no-reply@databricks.com>
…the service name - A token that cannot be refreshed mid-session is printed once: the bridge logs it on the request that needed it, and serve exits 2 without printing it again. The session DELETE after that failure is sent without a credential, so it does not log the refresh error a second time. - A state file that cannot be read is a binding failure (exit 2). - --service must be a full three-part name, with the message naming the flag. - An unknown --agent is reported on stderr once, not at debug level. - The bound profile is no longer set as the command's config: serve logs no telemetry yet, so the setting had no effect. Card 10a adds it with the telemetry it serves. - The signal context is released by the same stop that cancels the refresh guard, so a second signal during a refresh-failure shutdown ends the process. - serveTransport sets InsecureSkipVerify on the clone's TLS config instead of replacing it. - The fake MCP endpoint answers a client response (an id with no method) with 202 and no body. - The second-signal test asserts the child was ended by the signal, not by a panic or exit. Co-authored-by: Isaac <no-reply@databricks.com>
writesToStdout read the process's os.Stdout and os.Stderr. Under `go test -json` the testing package sets os.Stderr to os.Stdout, so the stdout cases were taken for stderr and the check passed the log file through. Take the two streams as parameters, and give the tests pipes and a separate stderr of their own. Production behavior is unchanged. Co-authored-by: Isaac <no-reply@databricks.com>
On Windows os.SameFile reports any two pipes or character devices as the same file, because their file ids are zero. With stdout piped, a null device or a named-pipe log file was refused as stdout. Compare by identity only for regular files there; elsewhere nothing changes. stdout itself is matched by pointer, so the stdout keyword is still refused on every OS. Co-authored-by: Isaac <no-reply@databricks.com>
When stdout and stderr are one file, as on a terminal, a log file opened as /dev/stderr or /dev/tty was refused as stdout, while --log-file stderr was allowed. The protocol already shares that file with the diagnostics, so the check cannot help there: a destination that is the same file as stderr is not refused. Other destinations are compared as before. Co-authored-by: Isaac <no-reply@databricks.com>
Execute closed the log file through the context of the command that ran. On a panic the command's context was never returned, so the file stayed open, and the default logger kept writing to it after Execute returned, or closed. Execute now keeps a slot in its own context that initializeContext fills, closes the file in a defer (which also runs on a panic), and restores the default logger that was in place before the command. Co-authored-by: Isaac <no-reply@databricks.com>
A caller whose credential is known to be unusable has no reason to send the session DELETE at shutdown: it would fail and log the failure again. Authenticate can now return ErrSkipRequest for the DELETE. The bridge then sends and logs nothing for it. Any other request that returns the sentinel is an error like any other. Co-authored-by: Isaac <no-reply@databricks.com>
After a token refresh failure, every later request asked for a token again and logged the login hint again, a request cancelled before its failure was logged left nothing on stderr, and a stdin error after the failure exited 1 and hid the auth status. Now the first failing request carries the hint, with the restart step; later requests fail at once with a short error that does not repeat it; the session DELETE is skipped (proxy.ErrSkipRequest); and serve prints one final line and exits 2, whatever the bridge returned. Co-authored-by: Isaac <no-reply@databricks.com>
… have The fake MCP endpoint answered any service name, so a wrong service name or path in the proxy's command still passed. A name with no service now gets 404, as the gateway answers a name that has none, and the tests and the serve acceptance case seed the service they use. Co-authored-by: Isaac <no-reply@databricks.com>
… logger The stale-version skip for a command whose stdout carries a protocol had no test. Move the decision into staleVersionSkipped, which takes the build info, and test it. In initializeContext the refused log file no longer needs a close: Execute closes the file it opened. Co-authored-by: Isaac <no-reply@databricks.com>
…its dialer The flag names of serve are the constants that add writes into agent configs, so an entry binds what add wrote; a test parses that argv with serve's flags. The dialer helper existed only for a test of a constant, so it is inlined and the test dropped. The binding status doc no longer cites a list command that is not in this tree. Co-authored-by: Isaac <no-reply@databricks.com>
The serve cases ran the command without printing it, so the flags under test did not appear in the goldens. Wrap each invocation in trace. Co-authored-by: Isaac <no-reply@databricks.com>
slog.SetDefault redirects the standard log package to the new handler, so after Execute closed the log file, log.Printf still wrote to it. Execute now saves and restores log.Writer() and log.Flags() with the default logger. Co-authored-by: Isaac <no-reply@databricks.com>
The stdout check ran for every protocol command, including the default stderr log, and a failed Stat returned an error that stopped the command, so `2>&-` made `serve` fail. A stat failure now means the stream is not stdout, and writesToStdout returns a bool. Co-authored-by: Isaac <no-reply@databricks.com>
Unity Catalog names are case-insensitive, and the fake's listing already matches them that way. The MCP endpoint looked the name up exactly, so a service addressed in another case got 404. Co-authored-by: Isaac <no-reply@databricks.com>
jq -s also accepts pretty-printed or several-per-line JSON, so the passthrough test did not check that each stdout line is one message. The filter now reads each line with fromjson. The binding-errors steps send stderr to the script output, so each traced command, its stderr and its exit code appear in order in the golden. Co-authored-by: Isaac <no-reply@databricks.com>
No behavior change. The refresh-failure tests share one fake endpoint and one Authenticate, and the exit-with-status error is built by one helper. Stale-version skipping is one predicate, the refresh-failure messages are constants in the tests, and the two no-body endpoint tests are one table. Comments are trimmed to their reasons, test comments start with the test name, and the silent_err.go import is back to its original form. Co-authored-by: Isaac <no-reply@databricks.com>
…ndows console case serve checks its binding only at start. A profile re-pointed to another host during the session keeps receiving the endpoint of the bound host, so that is documented on the command. The refresh hint's restart is needed because a new spawn re-runs the binding checks. The stdout check treats a Windows console as a file that is not stdout, so `--log-file stdout` is refused there even in a terminal. Co-authored-by: Isaac <no-reply@databricks.com>
depguard forbids the standard log package outside a few generators. The import is needed here because slog.SetDefault redirects that package, and libs/log has no way to restore it. The exception is annotated where it is used. Co-authored-by: Isaac <no-reply@databricks.com>
Serve stopped on any token refresh failure. A network error, a timeout or a 5xx from the token endpoint is not a credential the user must replace, so serve now fails only the request that needed the token, with the login hint, and keeps serving. The next request asks for a token again. A failure stops serve only when the token is rejected: the token endpoint answers 400 or 401 with invalid_grant or invalid_client, or the U2M client reports an invalid refresh token. Anything else is transient, including errors that cannot be classified. Co-authored-by: Isaac <no-reply@databricks.com>
A failure that is not a rejection, such as a network blip, says nothing about the credential, so the request's error no longer tells the user to log in. It says the next request tries again. Co-authored-by: Isaac <no-reply@databricks.com>
serve printed its binding failures as bare text, while its flag errors and every other command's failures start with "Error: ". The token-refresh stop line had no prefix either. Print both as "Error: <message>" so an agent's MCP log shows one style. The exit status is unchanged. Co-authored-by: Isaac <no-reply@databricks.com>
At --log-level debug, serve logged nothing about the traffic it bridged: the bridge's HTTP client does not go through the SDK logger. Wrap the bridge's transport in a RoundTripper that logs one debug line per upstream request: the HTTP method, the JSON-RPC method and id from the body, the status, the time to the response headers, and whether a session id was sent, received, or replaced. The lines carry no body and no header value, so neither the token nor a session id nor a tool argument is logged. The wrapper lives in serve, so the bridge package is unchanged. Co-authored-by: Isaac <no-reply@databricks.com>
With an expired or invalid token the MCP endpoint answers 3xx, a redirect to sign-in. The bridge does not follow it, so every request failed with "HTTP 303" and the user got no hint. Wrap the upstream transport in a RoundTripper that turns any 3xx into an error naming the login command for the profile, with DATABRICKS_CONFIG_FILE when the profile is pinned to a config file. The request fails with that error, and serve keeps running. The Location is not read, since its query can carry state. 200 and 5xx responses pass through unchanged. Co-authored-by: Isaac <no-reply@databricks.com>
simonfaltum
force-pushed
the
aitools-mcp/06b-serve
branch
from
November 17, 2026 15:11
a9f263c to
b02d29d
Compare
simonfaltum
force-pushed
the
aitools-mcp/06a-bridge
branch
from
November 17, 2026 15:11
40a3e6b to
0d32c09
Compare
The protocol-skip change rewrote the comment of the DBR check. Keep the original line. Co-authored-by: Isaac <no-reply@databricks.com>
A refresh rejection for a profile pinned to a config file now names that file in its login command, as the sign-in redirect hint does. A missing refresh token or cached token is a rejection too, so serve stops with the login command instead of retrying forever. The sign-in redirect hint says to restart the server. Fix the test comments that contradicted their assertions. Co-authored-by: Isaac <no-reply@databricks.com>
Startup and refresh failures for a profile pinned to a config file now name that file in the login command, as the sign-in redirect does. The restart step moves to its own line, so copying the login command does not copy a trailing comma into the profile name. LoginCommand is shared by the hints. The token-error helper is a named function, not a closure. Co-authored-by: Isaac <no-reply@databricks.com>
On macOS the temporary config path is under a symlink, which ResolveConfigFile resolves. The expectation uses the resolved path. Co-authored-by: Isaac <no-reply@databricks.com>
This branch has not been deployed
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 that adds the hidden
databricks aitools mcpcommand group. It builds on #7540 and addsaitools 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.--outputand a log file on stdout are refused.mcp addstill exits 1 on a binding failure.libs/aitools/mcp/proxy:Authenticatemay returnErrSkipRequestto skip the session DELETE.cmd/root:ExitStatusError, whichExitStatushonors.Executecloses the log file and restores the default logger and standardlogoutput on return, also after a panic.libs/testserver: the fake MCP endpoint answers 404 for unknown services and matches names without regard to case.Why
Each entry that
mcp addwrites runsaitools 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.Decisions to review
invalid_grantorinvalid_client, or the CLI's U2M client reporting an invalid refresh token. Everything else fails only its request, including network errors, timeouts, 5xx responses, and 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. The cost is that an unclassified error keeps failing requests instead of stopping serve.databricks auth login --profile P --host B, keeps sending its token to the host serve was bound to. The command's doc comment says so.--log-file stdoutworks on a Unix terminal. Windows refuses it even in a terminal, because a console is not a regular file there.--agentis accepted and left out of the User-Agent, since a later release may write agents this binary does not know.Tests
go test -raceoncmd/aitools,cmd/root,libs/aitoolsandlibs/testserver, also through the repo's gotestsum runner.cmd/root: the stdout refusal and check, including a closed stderr; logger restore after a panic and a normal return.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 while serve runs to stdin close (exit 0).TestCredentialRejectedchecks each error shape.serve-passthroughchecks each stdout line is one JSON-RPC message;serve-binding-errorschecks exit 2 and the stderr text.Not tested: a real token refresh end to end, because the fake cannot fail one. The typed U2M case has no exported constructor, so the tests do not reach it. Windows: only
go vetand a test build ran, so the console behavior is from reading the code.This pull request and its description were written by Isaac.