Repository navigation
Add MCP server config writers for coding agents - #7539
Draft
simonfaltum wants to merge 6 commits into
Draft
simonfaltum wants to merge 6 commits into
simonfaltum wants to merge 6 commits into
Conversation
Collaborator
✅ Integration test reportCommit: 07cc225
Top 7 slowest tests (at least 2 minutes):
|
Add a per-agent description of where each coding agent keeps its user-scope MCP server entries, and the writers that add, remove and list the entries this CLI owns without touching anything else in the file. - libs/aitools/mcpconfig: Spec (path, format, root key, entry shape, ownership). - libs/aitools/agents: MCP spec for seven agents, nil for the others; SupportsMCP and MCPAgents. - libs/aitools/mcp/agentconfig: Upsert, Remove and Read over JSON and TOML config files. Writes are atomic, keep the file mode, write through symlinks, and skip the write when the entry already matches. Files that cannot be parsed are refused and left untouched. Entries not written by this CLI are refused unless forced. JSON keeps key order and the bytes of values it does not change. TOML is decoded and re-encoded, so comments are dropped on any rewrite. Co-authored-by: Isaac <no-reply@databricks.com>
JSON and JSONC entries are changed with hujson patches, so comments, trailing commas, a leading BOM and the bytes of everything else are kept. TOML entries are changed as text: only the lines of the server's own tables are replaced or removed, and the edited text is decoded and checked before it is written. Upsert refuses a command that is not named databricks, since such an entry could not be recognized later. A symlink whose target is missing is refused rather than replaced. OpenCode prefers an existing opencode.jsonc. Co-authored-by: Isaac <no-reply@databricks.com>
JSON: a comment on the previous member's line stays there when a member is added. An empty table gets its closing brace on its own line. A file with only comments and an empty object keeps its comments. Removing the last member keeps a strict file strict and keeps a trailing comma that was there. Inserted text uses the file's line ending. Upsert updates an entry this CLI wrote only in the keys the builders write, so keys the user added (for example disabled or enabled) survive a re-add. An entry that differs only in those keys is not rewritten. --force still replaces a foreign entry as a whole. Antigravity entries no longer write disabled: false, since the key is optional. Upsert refuses a server name outside [A-Za-z0-9_-] and says whether the command or the args are wrong. Error messages show paths with forward slashes. Tests set the agent overrides on the context instead of the process environment. Co-authored-by: Isaac <no-reply@databricks.com>
- Update sets only the launch keys (command, args, env, environment, type). Other keys are kept, and defaults such as Copilot's tools list are written only on first add. An entry whose launch keys match is not rewritten. - JSON updates patch the changed launch keys in place, so the other members keep their bytes. Numbers in user values are decoded with UseNumber. - JSON duplicate member names on the root and server path are refused as ErrConfigInvalid. - TOML table headers are found with multi-line strings protected, using localenv's helper, now exported as ProtectMultilineStrings. Quoted keys are parsed, so a quoted "genie.x" is not "genie", and a header-like line inside a string is text. - Removing a table keeps one blank line between its neighbours, and removing the first server leaves no blank first line. - Remove checks the server name as Upsert does. - The OpenCode path returns stat errors other than not-exist. - New config directories are created 0700. - Smaller fixes: top-level JSON error wording, IsUnmanaged comment, mcpconfig.IsDatabricksBinary, BOM strip via bytes.CutPrefix, ValidServerName without a package-level regexp, and a Windows-safe path assertion in toml_test. Co-authored-by: Isaac <no-reply@databricks.com>
Update only what the CLI owns in an existing entry. Launch keys are the ones the agent's builder writes, so a key the builder never writes (type, for most agents) is kept. In env tables only DATABRICKS_CONFIG_FILE is the CLI's, and user variables are kept. Compare TOML edits as TOML text, so inf and nan in an unrelated table no longer block an edit. Add blank-line layout that keeps one blank line before a new server and restores the file's own bytes when the server is removed again. Refuse OpenCode when both opencode.json and opencode.jsonc exist, and treat a dangling opencode.jsonc link as the file to edit, so the write is refused. Keep CRLF on the newlines hujson writes for a new member. Collapse the TOML set/update/remove wrappers into one put, and fix the test comments and assertions flagged in review. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
simonfaltum
force-pushed
the
aitools-mcp/01-agentconfig
branch
from
November 13, 2026 15:05
6f07e48 to
07cc225
Compare
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 adds the layer that knows where each coding agent keeps its MCP server entries, and writes one entry without changing anything else in the file. No command uses it yet.Changes
libs/aitools/mcp/agentconfigaddsUpsert,RemoveandRead. Writes are atomic, keep the file mode, and are skipped when the entry already matches.forceis set. It also refuses a server name outside[A-Za-z0-9_-], and a command or args that would make the entry unrecognizable later.env, onlyDATABRICKS_CONFIG_FILEis the CLI's.libs/aitools/agentsgives seven agents an MCP spec: Claude Code, Codex, Cursor, Copilot CLI, Gemini CLI, OpenCode and Antigravity.libs/localenvexportsProtectMultilineStrings, renamed with no behavior change.Why
Each agent keeps MCP servers in a different file and shape. A user's agent config must keep its other settings, so the writer keeps comments and layout outside the entry it changes, and refuses any file it cannot parse.
Decisions to review
toolslist they narrowed. The alternative replaces the whole entry.opencode.jsonandopencode.jsoncpresent is refused, and the OpenCode entry uses the current docs' form:mcp.servers, variables underenvironment, noenabledkey.~/.claude.jsonis written without a lock. Claude Code takes none, so a write it makes between our read and rename would be lost. The window is milliseconds.Tests
TestRoundTripPerAgentwrites, rewrites and removes an entry for each agent, on fixtures with unrelated keys. It also passes with CRLF fixtures.go test -race ./libs/aitools/... ./libs/localenv/... ./libs/testserver/,go test ./cmd/aitools/..., theTestAccept/cmd/aitoolsandTestAccept/localenvacceptance tests,GOOS=windowsandGOOS=darwin go vet, golangci-lint (0 issues), and./task checks.How to review
Read
writer.go(Upsert,keepUserKeys,mergeEnv) andtoml.go(put,dropTable,appendBlock) closely.json.gois patch plumbing over hujson.This pull request and its description were written by Isaac.