Repository navigation
Add and remove agent MCP entries through the agent's own CLI - #7595
Draft
simonfaltum wants to merge 14 commits into
Draft
simonfaltum wants to merge 14 commits into
simonfaltum wants to merge 14 commits into
Conversation
Contributor
|
Commit: Regression test reportSelected 19 changed tests (limit=20, 0 not selected) 19 tests: regression=19 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-remove-agent-clis: 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): 14 more failure details omitted, see the full report in the run. |
Collaborator
✅ Integration test reportCommit: 1c32739
Top 14 slowest tests (at least 2 minutes):
|
simonfaltum
force-pushed
the
aitools-mcp/08b-agent-clis
branch
from
November 13, 2026 09:48
7122f6a to
93e536b
Compare
simonfaltum
force-pushed
the
aitools-mcp/08-challenge
branch
from
November 13, 2026 15:05
1abf7d0 to
6b41591
Compare
simonfaltum
force-pushed
the
aitools-mcp/08b-agent-clis
branch
from
November 13, 2026 15:06
3ed1398 to
8cca61b
Compare
simonfaltum
force-pushed
the
aitools-mcp/08b-agent-clis
branch
from
November 16, 2026 12:47
8cca61b to
50318b1
Compare
simonfaltum
force-pushed
the
aitools-mcp/08-challenge
branch
from
November 16, 2026 12:47
6b41591 to
48208cf
Compare
simonfaltum
force-pushed
the
aitools-mcp/08b-agent-clis
branch
from
November 16, 2026 13:19
50318b1 to
f46d6a0
Compare
simonfaltum
force-pushed
the
aitools-mcp/08-challenge
branch
from
November 16, 2026 13:19
48208cf to
922dad8
Compare
simonfaltum
force-pushed
the
aitools-mcp/08b-agent-clis
branch
from
November 16, 2026 13:32
f46d6a0 to
d049189
Compare
simonfaltum
force-pushed
the
aitools-mcp/08-challenge
branch
2 times, most recently
from
November 16, 2026 14:49
7e7f6c7 to
865e2f5
Compare
simonfaltum
force-pushed
the
aitools-mcp/08b-agent-clis
branch
2 times, most recently
from
November 16, 2026 15:14
6955d59 to
84abb41
Compare
simonfaltum
force-pushed
the
aitools-mcp/08-challenge
branch
from
November 16, 2026 15:53
0952a73 to
1f42a46
Compare
simonfaltum
force-pushed
the
aitools-mcp/08b-agent-clis
branch
2 times, most recently
from
November 17, 2026 10:52
190f3cb to
fdc9d71
Compare
simonfaltum
force-pushed
the
aitools-mcp/08-challenge
branch
from
November 17, 2026 10:52
1f42a46 to
d94c24d
Compare
simonfaltum
force-pushed
the
aitools-mcp/08b-agent-clis
branch
from
November 17, 2026 11:21
fdc9d71 to
fc23170
Compare
simonfaltum
force-pushed
the
aitools-mcp/08-challenge
branch
from
November 17, 2026 12:02
0fb469a to
8237caa
Compare
simonfaltum
force-pushed
the
aitools-mcp/08b-agent-clis
branch
from
November 17, 2026 12:02
fc23170 to
0d214eb
Compare
simonfaltum
force-pushed
the
aitools-mcp/08-challenge
branch
from
November 17, 2026 12:36
8237caa to
32552ca
Compare
simonfaltum
force-pushed
the
aitools-mcp/08b-agent-clis
branch
from
November 17, 2026 12:36
0d214eb to
2a05c5e
Compare
aitools mcp add and remove now change the Claude Code, Codex CLI, Gemini CLI and Copilot CLI entries through each agent's own mcp commands, with a read-back of the agent's config file. The agent CLI runner, resolver and stderr helper live in agents, and the installer's plugin probe reuses agents.ResolveBinary. The installer keeps its timeout-aware runner and stderr helper. Co-authored-by: Isaac <no-reply@databricks.com>
The read-only check from card 01 ran only before the direct write, and removeDirect had no agent to name in the error. The agent's own CLI writes the config file itself, so a read-only file was still changed through it. Upsert and RemoveAt now check the file before the CLI runs, and removeDirect takes the agent, so both paths refuse a read-only file. Tests that used Remove now call RemoveAt, which replaced it here. Co-authored-by: Isaac <no-reply@databricks.com>
Card 04 now leaves error_category out of a successful aitools mcp add document, so the add outputs in this card's golden lose the "error_category": "TYPE_UNSPECIFIED" line. Co-authored-by: Isaac <no-reply@databricks.com>
RemoveAt takes a context in this card, so the inline-table test that card 01 added and card 05 moved to RemoveAt passes t.Context(). Co-authored-by: Isaac <no-reply@databricks.com>
RemoveAt takes a context in this card, so the TOML array test that card 01 added and card 05 moved to RemoveAt passes t.Context(). Co-authored-by: Isaac <no-reply@databricks.com>
Card 05 moved Upsert's comparison into mergeLaunch, which compares the launch keys as they are. An agent's CLI may write an empty env table where the spec writes none, and this card's launchOf drops it, so an entry the CLI wrote reads as unchanged. mergeLaunch now uses launchOf, so Upsert and the list status agree with that again. Co-authored-by: Isaac <no-reply@databricks.com>
codex mcp add and codex mcp remove rewrite every [mcp_servers.*] table of the user's config. On a real config with 11 servers, one round trip dropped the default enabled = true keys, collapsed multi-line arrays, turned 10 into 10.0 and converted CRLF to LF. The direct writer edits only the server's own tables, so Codex now always uses it for add and remove. Claude Code, Gemini CLI and Copilot CLI keep their own CLI. Co-authored-by: Isaac <no-reply@databricks.com>
Card 01 now leaves the --agents hint to the commands, so the writer refuses with "<file> is read-only; make it writable" and ErrReadOnly. Co-authored-by: Isaac <no-reply@databricks.com>
simonfaltum
force-pushed
the
aitools-mcp/08-challenge
branch
from
November 17, 2026 15:11
32552ca to
bb76f49
Compare
simonfaltum
force-pushed
the
aitools-mcp/08b-agent-clis
branch
from
November 17, 2026 15:11
2a05c5e to
1c32739
Compare
Codex has no add or remove command in its spec now, so the CLI path never reads HomeEnv for it. Codex's config path reads CODEX_HOME itself, and mcpHomeEnvs still lists it. The Claude and Gemini MCP specs name their home variable with the constants this change introduced, instead of repeating the literal. Co-authored-by: Isaac <no-reply@databricks.com>
Codex is written directly, so no acceptance test runs its CLI. The stand-in now fails any command it is given, so a regression back to codex mcp fails the test instead of only changing the output. The Copilot handler, which shared the function, is renamed to say so. Co-authored-by: Isaac <no-reply@databricks.com>
Go quotes an argument that has a tab, and an empty argument as "", and cmd.exe strips the outer quotes of a batch file's command line, so both reach the shim garbled. batchSafe now refuses them like the other characters it refuses. Co-authored-by: Isaac <no-reply@databricks.com>
The comment over the Claude and Gemini home variables described Codex and Copilot, and the test comment said a Codex CLI on PATH runs, which it no longer does. Co-authored-by: Isaac <no-reply@databricks.com>
A rewrite that keeps the inode of an executable can make macOS kill it on exec, once the kernel has cached the old signature. The fake CLIs are now written beside their path and renamed over it. Co-authored-by: Isaac <no-reply@databricks.com>
The test drives the read-only refusal through Upsert and RemoveAt, not through cliPath, so the old name pointed at the wrong function. 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 the stack that adds the hidden
databricks aitools mcpcommand group; its parent is #7553.aitools mcp addandremovenow change the Claude Code, Codex CLI, Gemini CLI and Copilot CLI configs through each agent's own MCP command, when that CLI is on PATH.Changes
claude mcp add-json --scope user,codex mcp add,gemini mcp add --scope user,copilot mcp add --tools *). Afterwards the config file holds the entry asked for, whatever the exit status: a differing entry is replaced, and a missing one is added directly.removeruns the CLI's remove for an entry we wrote, when the agent reads that file now. A CLI failure, or an entry left behind, falls back to the direct writer. Symlinked configs and names that start with-always use the direct writer.Why
The agent's own CLI writes its config with its own locking and layout, for example while a running Claude Code session rewrites
.claude.json, and when an agent changes its file format its CLI follows, where a copy in this repo would not.Decisions to review
mcp addandmcp removerewrite the[mcp_servers.*]tables in Codex's own serialization. With Codex CLI 0.167.1 in a temporaryCODEX_HOME, a comment after a value and an unknown key in another server's table were dropped. The direct writer re-renders only the server it writes, so comments inside that server's tables are lost on either path..cmdshim gets only arguments without spaces, double quotes orcmd.exespecial characters. Other arguments use the direct writer.Tests
libs/aitools/agentscovers argv per agent, including a Windows path with spaces.agentconfig/cli_test.gocovers each outcome of an add, symlinks, dash names and the timeout.libs/processcoversWithoutEnv, which ignores case on Windows.acceptance/cmd/aitools/mcp/add-remove-agent-cliscovers each agent's argv and the files it wrote../task test-exp-aitoolspasses withBROWSERunset and withBROWSER=none.-inprocessmode, which already fails on the base for these tests.This pull request and its description were written by Isaac.