| 1035 | /* ── Zed MCP (context_servers with command + args) ────────────── */ |
| 1036 | |
| 1037 | int cbm_install_zed_mcp(const char *binary_path, const char *config_path) { |
| 1038 | if (!binary_path || !config_path) { |
| 1039 | return CLI_ERR; |
| 1040 | } |
| 1041 | |
| 1042 | yyjson_mut_doc *mdoc = yyjson_mut_doc_new(NULL); |
| 1043 | if (!mdoc) { |
| 1044 | return CLI_ERR; |
| 1045 | } |
| 1046 | |
| 1047 | yyjson_doc *doc = read_json_file(config_path); |
| 1048 | yyjson_mut_val *root; |
| 1049 | if (doc) { |
| 1050 | root = yyjson_val_mut_copy(mdoc, yyjson_doc_get_root(doc)); |
| 1051 | yyjson_doc_free(doc); |
| 1052 | } else { |
| 1053 | root = yyjson_mut_obj(mdoc); |
| 1054 | } |
| 1055 | if (!root) { |
| 1056 | yyjson_mut_doc_free(mdoc); |
| 1057 | return CLI_ERR; |
| 1058 | } |
| 1059 | yyjson_mut_doc_set_root(mdoc, root); |
| 1060 | |
| 1061 | yyjson_mut_val *servers = yyjson_mut_obj_get(root, "context_servers"); |
| 1062 | if (!servers || !yyjson_mut_is_obj(servers)) { |
| 1063 | servers = yyjson_mut_obj(mdoc); |
| 1064 | yyjson_mut_obj_add_val(mdoc, root, "context_servers", servers); |
| 1065 | } |
| 1066 | |
| 1067 | yyjson_mut_obj_remove_key(servers, "codebase-memory-mcp"); |
| 1068 | |
| 1069 | yyjson_mut_val *entry = yyjson_mut_obj(mdoc); |
| 1070 | yyjson_mut_obj_add_str(mdoc, entry, "command", binary_path); |
| 1071 | yyjson_mut_val *args = yyjson_mut_arr(mdoc); |
| 1072 | yyjson_mut_arr_add_str(mdoc, args, ""); |
| 1073 | yyjson_mut_obj_add_val(mdoc, entry, "args", args); |
| 1074 | yyjson_mut_obj_add_val(mdoc, servers, "codebase-memory-mcp", entry); |
| 1075 | |
| 1076 | int rc = write_json_file(config_path, mdoc); |
| 1077 | yyjson_mut_doc_free(mdoc); |
| 1078 | return rc; |
| 1079 | } |
| 1080 | |
| 1081 | int cbm_remove_zed_mcp(const char *config_path) { |
| 1082 | if (!config_path) { |
no test coverage detected