@@ -3850,8 +3850,11 @@ int cbm_upsert_codex_mcp(const char *binary_path, const char *config_path) {
38503850}
38513851
38523852int cbm_remove_codex_mcp(const char *config_path) {
3853+ /* #2228: only our table goes; foreign tables found between the markers
3854+ * (Codex Desktop appends below a block that ends the file) stay. */
38533855 if (!config_path ||
3854- cbm_toml_remove_managed_block(config_path, CODEX_MCP_BEGIN, CODEX_MCP_END) != 0) {
3856+ cbm_toml_remove_managed_block_owned(config_path, CODEX_MCP_BEGIN, CODEX_MCP_END,
3857+ CODEX_CMM_SECTION "\n") != 0) {
38553858 return CLI_ERR;
38563859 }
38573860 return cbm_remove_codex_legacy_mcp(config_path) >= 0 ? CLI_OK : CLI_ERR;
@@ -4475,7 +4478,8 @@ static int cbm_upsert_grok_mcp(const char *binary_path, const char *config_path)
44754478static int cbm_remove_grok_mcp_owned(const char *binary_path, const char *config_path) {
44764479 (void)binary_path;
44774480 if (!config_path ||
4478- cbm_toml_remove_managed_block(config_path, GROK_MCP_BEGIN, GROK_MCP_END) != 0) {
4481+ cbm_toml_remove_managed_block_owned(config_path, GROK_MCP_BEGIN, GROK_MCP_END,
4482+ GROK_CMM_SECTION "\n") != 0) {
44794483 return CLI_ERR;
44804484 }
44814485 return cbm_remove_grok_legacy_mcp(config_path) >= 0 ? CLI_OK : CLI_ERR;
@@ -5041,7 +5045,8 @@ static int cbm_upsert_kimi_context_hook(const char *config_path, const char *bin
50415045}
50425046
50435047static int cbm_remove_kimi_context_hook(const char *config_path) {
5044- return cbm_toml_remove_managed_block(config_path, KIMI_HOOK_BEGIN, KIMI_HOOK_END) == 0
5048+ return cbm_toml_remove_managed_block_owned(config_path, KIMI_HOOK_BEGIN, KIMI_HOOK_END,
5049+ "[[hooks]]\n") == 0
50455050 ? CLI_OK
50465051 : CLI_ERR;
50475052}
0 commit comments