| 4523 | } |
| 4524 | |
| 4525 | static int cbm_upsert_grok_mcp(const char *binary_path, const char *config_path) { |
| 4526 | if (!binary_path || !config_path) { |
| 4527 | return CLI_ERR; |
| 4528 | } |
| 4529 | char escaped[CLI_BUF_8K]; |
| 4530 | if (cbm_toml_escape_basic_string(binary_path, escaped, sizeof(escaped)) != 0) { |
| 4531 | return CLI_ERR; |
| 4532 | } |
| 4533 | /* Grok spawns stdio servers with the full parent environment (verified |
| 4534 | * against grok 1.0.5), so unlike Codex (#1562) nothing has to be |
| 4535 | * forwarded: CBM_CACHE_DIR and CBM_RUNTIME_DIR reach the server as-is. */ |
| 4536 | char block[CLI_BUF_8K]; |
| 4537 | int written = |
| 4538 | snprintf(block, sizeof(block), GROK_CMM_SECTION "\ncommand = \"%s\"\nargs = []\n", escaped); |
| 4539 | if (written < 0 || (size_t)written >= sizeof(block) || |
| 4540 | cbm_remove_grok_legacy_mcp(config_path) != 0) { |
| 4541 | return CLI_ERR; |
| 4542 | } |
| 4543 | return cbm_toml_upsert_managed_block(config_path, GROK_MCP_BEGIN, GROK_MCP_END, block) == 0 |
| 4544 | ? CLI_OK |
| 4545 | : CLI_ERR; |
| 4546 | } |
| 4547 | |
| 4548 | static int cbm_remove_grok_mcp_owned(const char *binary_path, const char *config_path) { |
| 4549 | (void)binary_path; |
nothing calls this directly
no test coverage detected