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

Function ri_index_capture

tests/test_index_resilience.c:83–110  ·  view source on GitHub ↗

Index the files already written under lp->tmpdir through the production MCP * flow, capturing the raw response. Returns the opened graph store (NULL on * failure). Mirrors repro_harness.h's rh_open_indexed but keeps the response so * we can assert on skipped_count / skipped[] / logfile. */

Source from the content-addressed store, hash-verified

81 * failure). Mirrors repro_harness.h's rh_open_indexed but keeps the response so
82 * we can assert on skipped_count / skipped[] / logfile. */
83static cbm_store_t *ri_index_capture(RProj *lp, char **out_resp) {
84 lp->project = cbm_project_name_from_path(lp->tmpdir);
85 if (!lp->project) {
86 return NULL;
87 }
88 const char *home = getenv("HOME");
89 if (!home) {
90 home = "/tmp";
91 }
92 char cache_dir[512];
93 snprintf(cache_dir, sizeof(cache_dir), "%s/.cache/codebase-memory-mcp", home);
94 cbm_mkdir(cache_dir);
95 snprintf(lp->dbpath, sizeof(lp->dbpath), "%s/%s.db", cache_dir, lp->project);
96 unlink(lp->dbpath);
97 lp->srv = cbm_mcp_server_new(NULL);
98 if (!lp->srv) {
99 return NULL;
100 }
101 char args[700];
102 snprintf(args, sizeof(args), "{\"repo_path\":\"%s\"}", lp->tmpdir);
103 char *resp = cbm_mcp_handle_tool(lp->srv, "index_repository", args);
104 if (out_resp) {
105 *out_resp = resp;
106 } else if (resp) {
107 free(resp);
108 }
109 return cbm_store_open_path(lp->dbpath);
110}
111
112/* ── Tests ──────────────────────────────────────────────────────── */
113

Callers 1

Calls 4

cbm_mcp_server_newFunction · 0.85
cbm_mcp_handle_toolFunction · 0.85
cbm_store_open_pathFunction · 0.85

Tested by

no test coverage detected