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

Function handle_query_graph

src/mcp/mcp.c:6053–6338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6051}
6052
6053static char *handle_query_graph(cbm_mcp_server_t *srv, const char *args) {
6054 char *query = cbm_mcp_get_string_arg(args, "query");
6055 char *project = get_project_arg(args);
6056 cbm_store_t *store = resolve_store(srv, project);
6057 int visible_limit = cbm_mcp_get_int_arg(args, "max_rows", 200);
6058 if (visible_limit == 0 || visible_limit > MCP_QUERY_MAX_VISIBLE_ROWS) {
6059 /* compatibility: max_rows=0 used to mean engine default */
6060 visible_limit = MCP_QUERY_MAX_VISIBLE_ROWS;
6061 } else if (visible_limit < 0) {
6062 visible_limit = 1;
6063 }
6064 int requested_offset = cbm_mcp_get_int_arg(args, "offset", 0);
6065 int row_offset = requested_offset;
6066 if (row_offset < 0) {
6067 row_offset = 0;
6068 }
6069 char *cursor_arg = cbm_mcp_get_string_arg(args, "cursor");
6070
6071 /* graph="missed" (#963): run the SAME cypher against the derived
6072 * miss-graph view (shadow project "<project>::missed") instead of the
6073 * code graph — file structure of not-fully-indexed files only. */
6074 char *graph_arg = cbm_mcp_get_string_arg(args, "graph");
6075 bool missed_graph = graph_arg && strcmp(graph_arg, "missed") == 0;
6076 free(graph_arg);
6077
6078 if (!query) {
6079 free(cursor_arg);
6080 free(project);
6081 return cbm_mcp_text_result("query is required", true);
6082 }
6083 if (missed_graph && !project) {
6084 free(cursor_arg);
6085 free(query);
6086 return cbm_mcp_text_result("project is required when graph=\"missed\"", true);
6087 }
6088 if (!store) {
6089 char *_err = build_project_list_error("project not found or not indexed");
6090 char *_res = cbm_mcp_text_result(_err, true);
6091 free(_err);
6092 free(cursor_arg);
6093 free(project);
6094 free(query);
6095 return _res;
6096 }
6097
6098 char *not_indexed = verify_project_indexed(store, project);
6099 if (not_indexed) {
6100 free(cursor_arg);
6101 free(project);
6102 free(query);
6103 return not_indexed;
6104 }
6105
6106 char covproj[CBM_SZ_512];
6107 const char *cypher_project = project;
6108 if (missed_graph) {
6109 cbm_store_coverage_shadow_project(covproj, sizeof(covproj), project);
6110 cypher_project = covproj;

Callers 1

dispatch_toolFunction · 0.85

Calls 15

cbm_mcp_get_string_argFunction · 0.85
get_project_argFunction · 0.85
resolve_storeFunction · 0.85
cbm_mcp_get_int_argFunction · 0.85
cbm_mcp_text_resultFunction · 0.85
build_project_list_errorFunction · 0.85
verify_project_indexedFunction · 0.85
cbm_store_generationFunction · 0.85
query_graph_params_hashFunction · 0.85
cbm_cypher_executeFunction · 0.85

Tested by

no test coverage detected