Skip to content

Commit 5743e1a

Browse files
authored
fix: opencode MCP config format (#134)
Fixes OpenCode config to match their documented format: - `"enabled": true` - `"type": "local"` - `"command": ["path"]` (array, not string) Thanks @chitralverma for the fix and test coverage!
1 parent 6d4d324 commit 5743e1a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/cli/cli.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,11 @@ int cbm_upsert_opencode_mcp(const char *binary_path, const char *config_path) {
13141314
yyjson_mut_obj_remove_key(mcp, "codebase-memory-mcp");
13151315

13161316
yyjson_mut_val *entry = yyjson_mut_obj(mdoc);
1317-
yyjson_mut_obj_add_str(mdoc, entry, "command", binary_path);
1317+
yyjson_mut_obj_add_bool(mdoc, entry, "enabled", true);
1318+
yyjson_mut_obj_add_str(mdoc, entry, "type", "local");
1319+
yyjson_mut_val *cmd_arr = yyjson_mut_arr(mdoc);
1320+
yyjson_mut_arr_add_str(mdoc, cmd_arr, binary_path);
1321+
yyjson_mut_obj_add_val(mdoc, entry, "command", cmd_arr);
13181322
yyjson_mut_obj_add_val(mdoc, mcp, "codebase-memory-mcp", entry);
13191323

13201324
int rc = write_json_file(config_path, mdoc);

tests/test_cli.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,11 @@ TEST(cli_upsert_opencode_mcp_fresh) {
15701570
ASSERT_NOT_NULL(data);
15711571
ASSERT(strstr(data, "codebase-memory-mcp") != NULL);
15721572
ASSERT(strstr(data, "/usr/local/bin/codebase-memory-mcp") != NULL);
1573+
ASSERT(strstr(data, "\"enabled\":true") != NULL || strstr(data, "\"enabled\": true") != NULL);
1574+
/* command must be emitted as an array, not a string */
1575+
ASSERT(strstr(data, "\"command\":[") != NULL || strstr(data, "\"command\": [") != NULL);
1576+
/* type must be explicitly set to \"local\" */
1577+
ASSERT(strstr(data, "\"type\":\"local\"") != NULL || strstr(data, "\"type\": \"local\"") != NULL);
15731578

15741579
test_rmdir_r(tmpdir);
15751580
PASS();

0 commit comments

Comments
 (0)