Skip to content

fix(mocactl): write both of IBM Bob's MCP config filenames - #677

Merged
pdettori merged 3 commits into
mainfrom
fix/676-bob-mcp-config
Nov 3, 2026
Merged

pdettori merged 3 commits into
mainfrom
fix/676-bob-mcp-config

Conversation

@mrsabath

@mrsabath mrsabath commented Nov 2, 2026

Copy link
Copy Markdown
Member

Fixes #676 (issue 2), and documents issues 1, 3 and 4 from that report.

The bug

sbx up wrote Bob's MCP server entry to .bob/settings.json. Bob 2.0.9 reads .bob/mcp.json —
the file bob mcp add writes at its default workspace scope — and ignores settings.json
entirely. The result was a silent no-op that looked like success:

$ mocactl sbx up
configured Claude Code, OpenCode and IBM Bob: ..., .bob/settings.json, ...

$ mocactl sbx doctor | grep 'agent config'
ok - agent config: ... IBM Bob use the sandbox MCP server ...

$ bob mcp list
No MCP servers configured

The file's contents were correct. Only the name was wrong, so nothing on the mocactl side could
tell. doctor could not catch it either: it verifies the server is present in the file it expects
to have written, not that the client reads that file.

Bob then ran with no sandbox tools — which, since up cannot deny Bob's local tools, meant it ran
on the laptop.

The fix

Write both filenames. Which one a given Bob reads depends on its version, and this cannot be
determined at up time: up runs before Bob is necessarily installed, and shelling out to
bob --version would make agent configuration depend on the agent being present and on parsing its
output. Both files are two-key JSON naming the same server, so the redundant one costs a few bytes.

doctor now passes when either file carries the server. Requiring both would fail a repository
that is working fine — including one where the developer ran bob mcp add by hand and so has only
mcp.json.

The change threads the second file through the existing machinery: conflict detection, the writer,
directory creation, the .sbx/agent-config.json record and sbx rm's take-back.

Documentation

Testing against Bob 2.0.9 found the guide's Bob section describes a CLI that version does not have.
Corrected, with the specifics:

Guide said Bob 2.0.9
bob "prompt" too many arguments; use -p or run
bob --auth-method sso no such flag; BOB_API_KEY, or log in via bob chat
bob mcp list → ✓ sandbox … - Connected sandbox: mocactl sbx mcp | enabled | stdio | workspace
bob -s for its own sandbox not in --help

Added, because they are steps a reader hits and the guide did not mention:

  • bob mcp add needs -- before stdio arguments, or it errors
  • bob run refuses an untrusted folder; the trust level is choosable in bob chat
  • bob mcp list reports configured state, not a live connection. /mcp inside bob chat is what
    confirms the server actually started
  • the templates carry only the Pi toolchain (bash, git, Python 3, ripgrep, curl) and the VM
    has no network, so a build or test run needs a language the template has. The guide's example
    prompt for every agent is "run the test suite and fix what fails", which cannot work in this
    repository: pnpm -r test has no Node and go test has no Go

The one worth reading

Bob prefers its own local tools unless the prompt names the sandbox's. With the server connected
and healthy, an ordinary request runs on the laptop. Naming the tool ("using the sandbox bash
tool") routes it correctly; instructing it not to use local tools does not — that was tested and
ignored. Since up cannot deny Bob's tools, prompt phrasing is the mitigation there is, so the
guide now says so in the Bob section, the agent table and troubleshooting.

The tell is the tool name in each call block: Bash (sandbox) / Edit (sandbox) are the sandbox's,
Execute Command is the laptop.

Testing

Unit:

  • 200 tests pass across sbx-agent-config, sbx-doctor and sbx-up
  • new test asserts both files are written, and that either alone satisfies doctor
  • full mocactl suite: 1637 pass. One unrelated pre-existing flake (overlay-misc.test.tsx, a 5 s
    TUI timeout) which passes in isolation and on a clean tree
  • tsc --noEmit and Prettier clean

End to end, against the real service with Bob 2.0.9 — built from this branch, fresh sandbox, no
hand-editing:

$ mocactl sbx up
configured Claude Code, OpenCode and IBM Bob: ..., .bob/settings.json, .bob/mcp.json, ...

$ ls .bob/
mcp.json    settings.json

$ bob mcp list
sandbox: mocactl sbx mcp | enabled | stdio | workspace     # no `bob mcp add` needed

Then a round trip in bob chat, prompt naming the sandbox tools. Every call was Find (sandbox),
Read (sandbox), Grep (sandbox), Bash (sandbox) or Edit (sandbox) — no Execute Command:

$ mocactl sbx pull --apply
applied the sandbox's changes to 1 file (2530 bytes of patch)
$ gofmt -l remote-worker/internal/shortdir/      # silent
$ go test ./internal/shortdir/
ok      github.com/rossoctl/moca/remote-worker/internal/shortdir  0.329s

Also

.gitignore now covers the per-developer agent wiring up writes (.bob/, .mcp.json,
opencode.json, AGENTS.md, .sbx/): it points at one developer's sandbox, differs per working
tree, and is re-merged by the next up. .claude/settings.json and CLAUDE.md are already tracked
and stay so — up merges into them inside a marked block.

Not addressed

Issue 1 (Bob's tool-selection default) and issue 4 (no Go or Node template) are documented here, not
fixed. Issue 1 may not be fixable from this side at all, since Bob exposes no way to remove a tool.
One idea worth testing: whether wording in the sbx:begin block that up writes into
CLAUDE.md/AGENTS.md, or in Bob's .bobrules, biases its tool choice toward the sandbox. If it
does, up could write it and most of the risk goes away.

Assisted-By: Claude Code

`sbx up` wrote only `.bob/settings.json`, which Bob 2.0.9 ignores: it reads
`.bob/mcp.json`, the file `bob mcp add` writes at its default `workspace`
scope. So `up` reported "configured ... IBM Bob" and `doctor` reported
`ok - agent config` while `bob mcp list` said "No MCP servers configured",
and Bob ran with no sandbox tools at all.

Which filename a given Bob reads cannot be determined from here -- `up` runs
before Bob is necessarily on `PATH`, and parsing `bob --version` would make
agent config depend on the agent -- so write both. Each is a two-key file
naming the same server, and `doctor` now passes when either one carries it:
the file that matters is whichever the installed Bob reads, and a developer
who ran `bob mcp add` by hand has only that one.

Also documents what testing against Bob 2.0.9 turned up, none of which the
guide described:

- prompts go via `-p` or `run`; a bare `bob "..."` fails
- credentials come from `BOB_API_KEY`; there is no `--auth-method`
- `bob mcp add` needs `--` before stdio arguments
- `bob run` refuses an untrusted folder
- `bob mcp list` reports configured state, not a live connection; `/mcp`
  inside `bob chat` is what confirms the server started
- Bob prefers its own local tools unless the prompt names the sandbox's, so
  a prompt that does not name them runs on the laptop with the sandbox
  connected and healthy. "Do not use any local tool" is ignored. `up` cannot
  deny Bob's tools, so this is the mitigation there is.
- the templates carry only the Pi toolchain, so a build or test run needs a
  language the template has

And gitignores the per-developer agent wiring `up` writes.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Mariusz Sabath <[email protected]>
Walking the guide through verbatim found its step 4 misleading in three ways,
all of them things a first-time reader hits:

- it used `bob run`, which is headless. Bob answered the example task by
  explaining that the package was already documented and offering to proceed
  anyway -- a question with nobody there to answer it, so nothing was written.
- the example ("add a doc comment to each exported function") can legitimately
  produce no change. `pull` then says `nothing to pull`, which reads as a
  broken round trip on a first run when it is the correct result.
- it named the `edit` tool for a task that creates a file. Bob used `write`
  instead and said why: `edit` only changes a file that already exists.

Step 4 is now `bob chat` with a task whose result is checkable -- a file that
was not there before -- and the tool list is spelled out so a reader can name
the right one, since naming the tool is the whole mitigation here.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Mariusz Sabath <[email protected]>
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 3, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing both .bob/settings.json and .bob/mcp.json is threaded consistently through every place the old single file went: conflict detection, the in-memory merge, the write loop, directory creation for sbx rm, the manifest's strict-JSON set, and doctor, which accepts either file. The new test covers both files being written and each one alone satisfying doctor, and the push-count and CFG expectations are updated to match. CI is green on 13638ee.

Two suggestions inline: anchor the new .gitignore entries to the repo root, and confirm that a hand-run bob mcp add produces an entry isBobServer accepts, because otherwise the newly checked file turns that path into a ConfigConflict.

One item outside the diff: docs/specs/2026-10-15-sbx0-internal-sandbox-service-design.md:516 still says Bob uses .bob/settings.json ("its project scope, which bob mcp add writes by default"). After this PR that is stale. Worth a one-line update so the spec and the guide agree.

Comment thread .gitignore Outdated
# sandbox, is re-merged by the next `up`, and differs per working tree (each gets its own
# sandbox). .claude/settings.json and CLAUDE.md are tracked and stay so -- `up` merges into
# them inside a marked block.
.bob/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: These patterns have no slash, so they match at any depth. AGENTS.md, .mcp.json, opencode.json, .bob/ and .sbx/ would also silently ignore a future packages/<pkg>/AGENTS.md, or a test fixture under any subdirectory, and git add would then need -f with no visible reason. up only writes these at the repository root, so anchor them: /.bob/, /.mcp.json, /opencode.json, /opencode.jsonc, /AGENTS.md, /.sbx/.

A related point: the guide (user-guide.md:411) says .sbx/ "is listed in .git/info/exclude, never in your .gitignore". That sentence is about what up writes, so this isn't wrong, but a reader of this repo will see .sbx/ in its .gitignore. A word in the comment above ("this repo also ignores them for every clone") would head off that question.


needObjects(bobMcp, ['mcpServers']);
const bobMcpHave = at(bobMcp.data, ['mcpServers', SERVER]);
if (bobMcpHave !== undefined && !isBobServer(bobMcpHave)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: This conflict check is new for .bob/mcp.json, and .bob/mcp.json is the file a developer gets from bob mcp add (which the guide now recommends as the manual fallback). isBobServer accepts only command/args/type/env. If Bob 2.0.9's bob mcp add sandbox -- mocactl sbx mcp writes any other key (for example a disabled, timeout, trust or alwaysAllow field, as some MCP clients do), then the next up in that repo stops with ConfigConflict: .bob/mcp.json mcpServers.sandbox is there and names another server. Before this PR, that same repo got through up fine. The end-to-end test in the description covers only the case where up creates the file. Could you check what bob mcp add actually writes and, if it adds keys, either allow them in isBobServer or add a test with a hand-added entry?

… update the spec

Addresses the review on #677.

- Anchor the new .gitignore patterns to the repository root (`/.bob/` and so
  on). Unanchored they matched at any depth, so a future
  packages/<pkg>/AGENTS.md or a fixture in any subdirectory would have been
  ignored silently, needing `git add -f` for no visible reason. `up` only
  writes these at the root. The comment now also says this repo ignores them
  for every clone, which the guide's "`.sbx/` is listed in .git/info/exclude,
  never in your .gitignore" would otherwise seem to contradict.

- Pin the shape of a hand-added Bob entry. Checking .bob/mcp.json is new, and
  it is the file `bob mcp add` writes -- the manual fallback the guide
  recommends -- so a repository configured that way must still get through
  `up` rather than stop with a ConfigConflict. Verified against Bob 2.0.9 in a
  fresh repository: it writes exactly `command` and `args`, with none of the
  `disabled`/`timeout`/`trust`/`alwaysAllow` fields `isBobServer` would
  reject, so no change to `isBobServer` is needed. The new test pins that, so
  a Bob that starts adding keys fails in CI rather than in a developer's
  repository.

- Update docs/specs/2026-10-15-sbx0-internal-sandbox-service-design.md, which
  still described Bob as `.bob/settings.json` only.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Mariusz Sabath <[email protected]>
@pdettori

pdettori commented Nov 3, 2026

Copy link
Copy Markdown
Member

Test report and two remaining items — verified against head c6ba1396, e2e against the live SBX0 service with Bob 2.0.9.

Verified:

  • vitest run test/sbx-agent-config.test.ts test/sbx-up.test.ts → all green in a worktree build (pi-fork built at the pinned commit), including the new writes both filenames / doctor accepts either alone and accepts the entry bob mcp add writes by hand tests.
  • tsc --noEmit clean. Full mocactl suite shows only known environmental failures (the ink TUI drift, and three sbx tests that pass in isolation — full-parallel load flakes).
  • Mutation checks: dropping bobMcp from the writes loop fails 8 tests; making doctor require both files (&& → ||) fails exactly the accepts either alone test. The fix is guarded in both directions.
  • Live, in a v0.9.0-configured repository with Bob 2.0.9: up merges cleanly over a hand-added .bob/mcp.json; deleting .bob/mcp.json (the sbx + IBM Bob 2.0.9: tool-selection default, config filename, template toolchains, guide drift #676 state) and re-running up restores it; bob mcp list then shows sandbox: mocactl sbx mcp | enabled | stdio | workspace; doctor all ok; with both Bob files removed, doctor fails with the new neither … nor … message and up restores both. A bob chat round trip with the PR build on PATH completed with sandbox-only tool calls.

Missing items:

  1. The .bob/mcp.json conflict path is untested. The stops on a conflict in %s table covers Bob only through .bob/settings.json; the new conflict check for .bob/mcp.json (a foreign sandbox server there must stop up, naming the file) has no case. Two lines mirroring the existing Bob entries close it — I ran them locally and they pass (20/20 conflict cases):

    ['.bob/mcp.json', JSON.stringify({ mcpServers: { sandbox: { command: 'other', args: [] } } }), 'mcpServers.sandbox'],
    ['.bob/mcp.json', JSON.stringify({ mcpServers: 7 }), 'mcpServers'],
  2. Ship vehicle. The breakage this fixes is in released v0.9.0: a Bob 2.x user gets configured IBM Bob and a green doctor while Bob sees no server at all. Worth deciding the release it lands in (a v0.9.1 note in the release notes, so 0.9.0 users know to re-run up after upgrading) — nothing in the PR records that.

Assisted-By: Claude Code

@pdettori
pdettori merged commit d098d08 into main Nov 3, 2026
17 checks passed
@pdettori
pdettori deleted the fix/676-bob-mcp-config branch November 3, 2026 16:03
webchang added a commit that referenced this pull request Nov 17, 2026
… up's agent config

`sbx push` has no rule of its own for the agent configuration `sbx up`
writes (.mcp.json, .claude/settings.json, opencode.json, .bob/,
CLAUDE.md, AGENTS.md): each is pushed exactly when git would list it
(tracked, or untracked and not ignored), and only .sbx/ is always left
out. #677 changed what this repository pushes as a side effect of its
.gitignore lines; this records the behavior as a decision (#683's
option A) instead of changing it.

- ADR-0049 (Proposed): the question, options A/B/C, the decision and
  why (no in-sandbox reader; the deny rules and Cortex mode act on the
  laptop; the developer's ignore rules say what stays local; pull never
  writes these files back), and the accepted costs.
- planPush's doc comment points at the ADR, as the place a skip or
  re-include rule would be added.
- Two tests in sbx-up.test.ts pin it: a repository that ignores none of
  the files pushes all seven on the next push and never .sbx/; one with
  this repository's ignore lines pushes only .claude/settings.json and
  CLAUDE.md, and a force-added AGENTS.md once it is tracked.
- The stale "pushed 14 files" comment now says why 14 holds in the
  fixture; the user guide says it in section 4 and in the section 7
  note on ignored files.

Closes #683

Assisted-By: Claude Code
Signed-off-by: Rong Chang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sbx + IBM Bob 2.0.9: tool-selection default, config filename, template toolchains, guide drift

3 participants