Skip to content

fix(opencode): doctor ignores global config, lists 0 servers#36

Open
Sereinxm wants to merge 1 commit into
RodrigoTomeES:mainfrom
Sereinxm:fix/opencode-global-config
Open

fix(opencode): doctor ignores global config, lists 0 servers#36
Sereinxm wants to merge 1 commit into
RodrigoTomeES:mainfrom
Sereinxm:fix/opencode-global-config

Conversation

@Sereinxm

@Sereinxm Sereinxm commented Jul 7, 2026

Copy link
Copy Markdown

Problem

getmcp doctor reports OpenCode as installed and "config file is valid", but lists zero servers from it — even when the user has 6+ servers configured in `~/.config/opencode/opencode.jsonc`.

Example output before fix:

```
◆ OpenCode: config file is valid
└ 2 warning(s) found. 9 check(s) passed. ← OpenCode servers missing
```

Root cause

The OpenCode generator declares `globalConfigPaths: null` while its `detectInstalled()` checks for `~/.config/opencode`:

```ts
// packages/generators/src/opencode.ts
configPaths: "opencode.json", // relative path
globalConfigPaths: null, // ← no global path declared
// ...
detectInstalled(): boolean {
return safeExistsSync(join(configHome, "opencode")); // ← but checks global dir
}
```

Because `globalConfigPaths` is `null`:

  1. `supportsBothScopes(app)` returns `false` → OpenCode treated as single-scope.
  2. `detectApps()` only resolves the relative `opencode.json` (which usually does not exist in CWD).
  3. `doctor` reads a non-existent file → `readConfigFile` returns `{}` → `listServersInConfig` returns `[]`.
  4. The report shows "config file is valid" (an empty object parses fine) while silently ignoring the user's real global config.

This contradicts the OpenCode docs, which state global settings live in `~/.config/opencode/opencode.jsonc`.

Fix

1. `packages/generators/src/opencode.ts` — declare the real global config paths:

```ts
globalConfigPaths: {
darwin: "/.config/opencode/opencode.jsonc",
win32: "%AppData%/opencode/opencode.jsonc",
linux: "
/.config/opencode/opencode.jsonc",
},
```

2. `packages/cli/src/detect.ts` — for dual-scope apps, when the project config doesn't exist but the global one does, point `configPath` at the global file. This makes `doctor` / `list` reflect the config the user is actually using. Also benefits Claude Code users who only keep `~/.claude.json`.

3. `packages/cli/tests/detect.test.ts` — move `opencode` from single-scope to dual-scope assertion list.

Verification

Locally, after the fix:

```
$ getmcp doctor
▲ "exa" is not in the registry and not tracked
│ Configured in: opencode
▲ "semble" is not in the registry and not tracked
│ Configured in: opencode
... (4 more servers now detected)
◆ "codebase-memory-mcp" is configured in 2 apps
└ 7 warning(s) found. 10 check(s) passed.
```

All 6 OpenCode servers are now detected (previously 0).

Testing

  • `npx vitest run` → 730 passed, 2 skipped (unchanged)
  • `npm run lint` → passes
  • `npx oxlint` / `npx oxfmt --check` → clean

Scope of change

```
packages/cli/src/detect.ts | 16 +++++++++++++++-
packages/cli/tests/detect.test.ts | 4 ++--
packages/generators/src/opencode.ts | 12 +++++++++++-
3 files changed, 28 insertions(+), 4 deletions(-)
```

No public API changes. The `detectApps()` fallback to global only triggers when the project file is absent — `add` / `remove` commands, which always resolve scope explicitly, are unaffected.

The OpenCode generator declared `globalConfigPaths: null` while its
`detectInstalled()` checked for `~/.config/opencode`. As a result,
`getmcp doctor` marked OpenCode as installed but always read the
relative `opencode.json` path (which usually does not exist),
returning an empty config and listing zero servers.

This was especially confusing because the report said
"OpenCode: config file is valid" while silently ignoring the user's
real `~/.config/opencode/opencode.jsonc`.

Two changes:

1. `packages/generators/src/opencode.ts`
   Declare `globalConfigPaths` pointing at
   `~/.config/opencode/opencode.jsonc` (darwin/linux) and
   `%AppData%/opencode/opencode.jsonc` (win32), matching the OpenCode
   documented global config location.

2. `packages/cli/src/detect.ts`
   For dual-scope apps, when the project config file does not exist but
   the global one does, point `configPath` at the global file. This
   makes `doctor`/`list` reflect the config the user is actually
   using. Also benefits Claude Code users who only keep `~/.claude.json`.

Tests updated to classify OpenCode as dual-scope. Verified locally:
`getmcp doctor` now lists all 6 configured servers (previously 0).
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the rodrigotomees' projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant