MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_install_editor_mcp

Function cbm_install_editor_mcp

src/cli/cli.c:792–835  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

790/* ── Editor MCP: Cursor/Windsurf/Gemini (mcpServers key) ──────── */
791
792int cbm_install_editor_mcp(const char *binary_path, const char *config_path) {
793 if (!binary_path || !config_path) {
794 return CLI_ERR;
795 }
796
797 /* Read existing or start fresh */
798 yyjson_mut_doc *mdoc = yyjson_mut_doc_new(NULL);
799 if (!mdoc) {
800 return CLI_ERR;
801 }
802
803 yyjson_doc *doc = read_json_file(config_path);
804 yyjson_mut_val *root;
805 if (doc) {
806 root = yyjson_val_mut_copy(mdoc, yyjson_doc_get_root(doc));
807 yyjson_doc_free(doc);
808 } else {
809 root = yyjson_mut_obj(mdoc);
810 }
811 if (!root) {
812 yyjson_mut_doc_free(mdoc);
813 return CLI_ERR;
814 }
815 yyjson_mut_doc_set_root(mdoc, root);
816
817 /* Get or create mcpServers object */
818 yyjson_mut_val *servers = yyjson_mut_obj_get(root, "mcpServers");
819 if (!servers || !yyjson_mut_is_obj(servers)) {
820 servers = yyjson_mut_obj(mdoc);
821 yyjson_mut_obj_add_val(mdoc, root, "mcpServers", servers);
822 }
823
824 /* Remove existing entry if present */
825 yyjson_mut_obj_remove_key(servers, "codebase-memory-mcp");
826
827 /* Add our entry */
828 yyjson_mut_val *entry = yyjson_mut_obj(mdoc);
829 yyjson_mut_obj_add_str(mdoc, entry, "command", binary_path);
830 yyjson_mut_obj_add_val(mdoc, servers, "codebase-memory-mcp", entry);
831
832 int rc = write_json_file(config_path, mdoc);
833 yyjson_mut_doc_free(mdoc);
834 return rc;
835}
836
837int cbm_remove_editor_mcp(const char *config_path) {
838 if (!config_path) {

Callers 4

cbm_upsert_junie_mcpFunction · 0.85
test_cli.cFile · 0.85

Calls 2

read_json_fileFunction · 0.85
write_json_fileFunction · 0.85

Tested by

no test coverage detected