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

Function cbm_install_vscode_mcp

src/cli/cli.c:961–1001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

959/* ── VS Code MCP (servers key with type:stdio) ────────────────── */
960
961int cbm_install_vscode_mcp(const char *binary_path, const char *config_path) {
962 if (!binary_path || !config_path) {
963 return CLI_ERR;
964 }
965
966 yyjson_mut_doc *mdoc = yyjson_mut_doc_new(NULL);
967 if (!mdoc) {
968 return CLI_ERR;
969 }
970
971 yyjson_doc *doc = read_json_file(config_path);
972 yyjson_mut_val *root;
973 if (doc) {
974 root = yyjson_val_mut_copy(mdoc, yyjson_doc_get_root(doc));
975 yyjson_doc_free(doc);
976 } else {
977 root = yyjson_mut_obj(mdoc);
978 }
979 if (!root) {
980 yyjson_mut_doc_free(mdoc);
981 return CLI_ERR;
982 }
983 yyjson_mut_doc_set_root(mdoc, root);
984
985 yyjson_mut_val *servers = yyjson_mut_obj_get(root, "servers");
986 if (!servers || !yyjson_mut_is_obj(servers)) {
987 servers = yyjson_mut_obj(mdoc);
988 yyjson_mut_obj_add_val(mdoc, root, "servers", servers);
989 }
990
991 yyjson_mut_obj_remove_key(servers, "codebase-memory-mcp");
992
993 yyjson_mut_val *entry = yyjson_mut_obj(mdoc);
994 yyjson_mut_obj_add_str(mdoc, entry, "type", "stdio");
995 yyjson_mut_obj_add_str(mdoc, entry, "command", binary_path);
996 yyjson_mut_obj_add_val(mdoc, servers, "codebase-memory-mcp", entry);
997
998 int rc = write_json_file(config_path, mdoc);
999 yyjson_mut_doc_free(mdoc);
1000 return rc;
1001}
1002
1003int cbm_remove_vscode_mcp(const char *config_path) {
1004 if (!config_path) {

Callers 1

test_cli.cFile · 0.85

Calls 2

read_json_fileFunction · 0.85
write_json_fileFunction · 0.85

Tested by

no test coverage detected