Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
fix(mcp): keep #2134 root-owner reuse out of cross-repo mode; portable test path
Martin Vogel1f0daaa91525
diff --git a/src/mcp/mcp.c b/src/mcp/mcp.cindex 0aa52d91d..836009b99 100644--- a/src/mcp/mcp.c+++ b/src/mcp/mcp.c@@ -11517,6 +11517,21 @@ static char *handle_index_repository(cbm_mcp_server_t *srv, const char *args) {return cbm_mcp_text_result(boundary_err, true);}+ if (mode_str && strcmp(mode_str, "cross-repo-intelligence") == 0) {+ if (async_mode) {+ index_args_free(repo_path, mode_str, name_override);+ return cbm_mcp_text_result(+ "async is not supported for mode cross-repo-intelligence (it runs no index job)",+ true);+ }+ char *result = handle_cross_repo_mode(srv, repo_path, name_override, args);+ index_args_free(repo_path, mode_str, name_override);+ return result;+ }++ /* #2134 applies to re-indexing only. Cross-repo mode reads an existing+ * source index and never writes one; adopting a root owner there could+ * turn one of its own named targets into the source. */if ((!name_override || !name_override[0]) && repo_path && repo_path[0]) {char *owner = NULL;char *owner_error = NULL;@@ -11534,18 +11549,6 @@ static char *handle_index_repository(cbm_mcp_server_t *srv, const char *args) {}}- if (mode_str && strcmp(mode_str, "cross-repo-intelligence") == 0) {- if (async_mode) {- index_args_free(repo_path, mode_str, name_override);- return cbm_mcp_text_result(- "async is not supported for mode cross-repo-intelligence (it runs no index job)",- true);- }- char *result = handle_cross_repo_mode(srv, repo_path, name_override, args);- index_args_free(repo_path, mode_str, name_override);- return result;- }-cbm_index_resource_policy_t resource_policy;char policy_error[CBM_SZ_256] = {0};if (!load_index_policy(srv, args, &resource_policy, policy_error, sizeof(policy_error))) {diff --git a/tests/test_mcp.c b/tests/test_mcp.cindex 6b197a6cd..4e23a8625 100644--- a/tests/test_mcp.c+++ b/tests/test_mcp.c@@ -8622,9 +8622,9 @@ TEST(tool_index_repository_reuses_existing_project_for_root_issue2134) {if (!cbm_mkdtemp(repo) || !cbm_mkdtemp(cache)) {FAIL("mkdtemp failed");}- char canonical_repo[CBM_SZ_1K];- if (!realpath(repo, canonical_repo)) {- FAIL("realpath failed");+ char canonical_repo[CBM_SZ_4K]; /* cbm_canonical_path needs >= 4096 bytes */+ if (!cbm_canonical_path(repo, canonical_repo, sizeof(canonical_repo))) {+ FAIL("cbm_canonical_path failed");}const char *saved_cache = getenv("CBM_CACHE_DIR");char *saved_cache_copy = saved_cache ? cbm_strdup(saved_cache) : NULL;