Repository navigation
Description
Summary
mcpproxy connect opencode (and the Connect Clients flow) fails on a fresh OpenCode installation because recent OpenCode versions bootstrap their global config as opencode.jsonc, while mcpproxy only recognizes opencode.json. OpenCode is then reported as not installed, and an explicit connect is refused.
Environment
- MCPProxy v0.52.0 (personal) darwin/arm64 (tray app + bundled CLI)
- OpenCode 1.18.8 (Homebrew), macOS
- Fresh OpenCode setup: first run auto-created
~/.config/opencode/withopencode.jsonccontaining only the$schemastub — noopencode.jsonanywhere
Reproduction
$ opencode --version
1.18.8
$ ls ~/.config/opencode/
.gitignore node_modules opencode.jsonc package-lock.json package.json
$ mcpproxy connect opencode
Error: OpenCode config file /Users/user/.config/opencode/opencode.json does not exist
The status/UI side has the same blind spot: OpenCode shows Exists: false (treated as not installed), so the Connect Clients flow offers no working path either.
Root cause
internal/connect/clients.go — ConfigPath("opencode", …) returns only the .json variant:
case "opencode":
...
return filepath.Join(homeDir, ".config", "opencode", "opencode.json")internal/connect/connect.go — Connect() has an opencode-specific existence gate on that single path, so a .jsonc-only installation can never connect:
if client.ID == "opencode" {
if _, err := os.Stat(cfgPath); os.IsNotExist(err) {
return nil, fmt.Errorf("OpenCode config file %s does not exist", cfgPath)
}
}GetAllStatus() / GetStatus() use os.Stat on the same single path, so detection reports OpenCode as absent.
Meanwhile OpenCode itself probes and merges three global config files (from its own log, v1.18.8):
loading path=~/.config/opencode/config.json
loading path=~/.config/opencode/opencode.json
loading path=~/.config/opencode/opencode.jsonc
and its bootstrap creates opencode.jsonc, not opencode.json. So on any freshly installed OpenCode, mcpproxy's single-path assumption never matches.
Suggested fix
In ConfigPath (or an opencode-specific resolver), probe the candidates OpenCode actually loads — opencode.json, opencode.jsonc (and possibly config.json) — and target the one that exists; keep opencode.json as the default for the create-new case.
Two details worth handling:
- Detection:
Exists/installed status should be true if any of the candidate files exists. - Write target: prefer writing into the file that already exists. Writing a new
opencode.jsonnext to an existingopencode.jsonctechnically works today (OpenCode merges both, and the stub.jsonchas nomcpkey), but it is fragile:.jsoncis loaded after.json, so anymcp.mcpproxyentry the user later adds/edits in.jsoncsilently shadows the one mcpproxy wrote — and the user ends up with two config files disagreeing about the same server..jsoncaccepts plain JSON output, so writing into it is safe as long as existing comments are preserved or the file is comment-free (the bootstrap stub is).
Workaround
Manually add the entry to ~/.config/opencode/opencode.jsonc:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"mcpproxy": {
"type": "remote",
"url": "http://127.0.0.1:8080/mcp",
"enabled": true
}
}
}
Activity
fix(connect): harden opencode jsonc handling per Codex review round 1
fix(connect): propagate alternate-candidate errors in opencode discon…
Dumbris commentedon Jul 28, 2026
Fix up in #923 (Codex-reviewed, auto-merge armed pending CI).
Implementation notes vs. the suggested fix:
opencode.jsonc→opencode.json(preferring.jsoncsince it shadows.jsonfor the same keys);opencode.jsonstays the default for the create-new case. Detection (Exists/status) is true if either exists.config.jsonwas left out deliberately — current OpenCode docs direct users toopencode.json(c); the legacy file can be added later if reports surface..jsoncparsing tolerates//and/* */comments plus trailing commas (string-aware; unterminated block comments are a parse error, not silently accepted)..jsoncthat actually uses comments (re-serializing would strip them) with a manual-edit hint — the comment-free bootstrap stub, i.e. the reported case, rewrites cleanly.opencode.jsonand a later OpenCode upgrade bootstrapsopencode.jsonc, disconnect finds the entry in the other candidate and undo restores the file its backup actually came from.fix(connect): recognize OpenCode's opencode.jsonc global config (#923)
Dumbris commentedon Jul 29, 2026
Fixed in #923 (commit 6692231), released on
main.mcpproxy connect opencodeand the Connect Clients flow now recognize OpenCode'sopencode.jsoncglobal config alongsideopencode.json, so a fresh OpenCode install is detected instead of being reported as not installed.fix(connect): close JSONC comment-guard TOCTOU in connect/disconnect
fix(connect): close JSONC comment-guard TOCTOU in connect/disconnect
fix(connect): close JSONC comment-guard TOCTOU in connect/disconnect (#…
fix(connect): keep string contents when stripping trailing commas (#1768