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

Function openhands_update_profile_refs

src/cli/cli.c:9747–9775  ·  view source on GitHub ↗

Register or unregister our server against every existing OpenHands agent * profile's mcp_server_refs array (#1826). A missing agent-profiles/ * directory is a silent no-op in both directions — install must never invent * it, and uninstall has nothing to undo there. Only *.json entries are * touched; a profile directory may hold arbitrary notes alongside profiles. */

Source from the content-addressed store, hash-verified

9745 * it, and uninstall has nothing to undo there. Only *.json entries are
9746 * touched; a profile directory may hold arbitrary notes alongside profiles. */
9747static void openhands_update_profile_refs(const char *profiles_dir, bool installing, bool dry_run) {
9748 cbm_dir_t *d = cbm_opendir(profiles_dir);
9749 if (!d) {
9750 return;
9751 }
9752 cbm_dirent_t *ent;
9753 while ((ent = cbm_readdir(d)) != NULL) {
9754 if (strcmp(ent->name, ".") == 0 || strcmp(ent->name, "..") == 0 ||
9755 !cbm_filename_has_suffix(ent->name, ".json")) {
9756 continue;
9757 }
9758 char profile_path[CLI_BUF_1K];
9759 snprintf(profile_path, sizeof(profile_path), "%s/%s", profiles_dir, ent->name);
9760 struct stat state;
9761 if (stat(profile_path, &state) != 0 || !S_ISREG(state.st_mode) || dry_run) {
9762 continue;
9763 }
9764 int result = installing ? cbm_json_like_add_unique_string(profile_path, "mcp_server_refs",
9765 CBM_DEFAULT_MCP_SERVER_NAME)
9766 : cbm_json_like_remove_string(profile_path, "mcp_server_refs",
9767 CBM_DEFAULT_MCP_SERVER_NAME);
9768 if (result != CLI_OK) {
9769 record_agent_config_error(
9770 !installing, "OpenHands",
9771 installing ? "profile_refs_install" : "profile_refs_uninstall", profile_path);
9772 }
9773 }
9774 cbm_closedir(d);
9775}
9776
9777/* Install MCP configs for editor-based agents (Zed, KiloCode, VS Code, OpenClaw). */
9778static void install_editor_agent_configs(const cbm_detected_agents_t *agents, const char *home,

Callers 2

Calls 8

cbm_opendirFunction · 0.85
cbm_readdirFunction · 0.85
cbm_filename_has_suffixFunction · 0.85
cbm_closedirFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected