mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-09 09:11:00 +08:00
mcp: fix summary mode aggregation limit + add pagination hint
Summary mode bug: by_label only counted 50 results (the default limit) instead of all symbols. Fix: override effective_limit to 10000 when mode=summary so aggregation covers representative sample. Pagination: when has_more=true, add pagination_hint field: "Use offset:50 and limit:50 for next page (13818 total)" This guides LLMs to use offset/limit for progressive exploration. Verified on RTK codebase (45,388 symbols): - Summary mode: 1,317 bytes with accurate label counts - Default search: pagination_hint present when has_more=true - All 2064 tests pass Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
This commit is contained in:
+14
-2
@@ -818,12 +818,16 @@ static char *handle_search_graph(cbm_mcp_server_t *srv, const char *args) {
|
||||
int min_degree = cbm_mcp_get_int_arg(args, "min_degree", -1);
|
||||
int max_degree = cbm_mcp_get_int_arg(args, "max_degree", -1);
|
||||
|
||||
/* Summary mode needs all results for accurate aggregation */
|
||||
bool is_summary_early = search_mode && strcmp(search_mode, "summary") == 0;
|
||||
int effective_limit = is_summary_early ? 10000 : limit;
|
||||
|
||||
cbm_search_params_t params = {
|
||||
.project = project,
|
||||
.label = label,
|
||||
.name_pattern = name_pattern,
|
||||
.file_pattern = file_pattern,
|
||||
.limit = limit,
|
||||
.limit = effective_limit,
|
||||
.offset = offset,
|
||||
.min_degree = min_degree,
|
||||
.max_degree = max_degree,
|
||||
@@ -913,7 +917,15 @@ static char *handle_search_graph(cbm_mcp_server_t *srv, const char *args) {
|
||||
yyjson_mut_arr_add_val(results, item);
|
||||
}
|
||||
yyjson_mut_obj_add_val(doc, root, "results", results);
|
||||
yyjson_mut_obj_add_bool(doc, root, "has_more", out.total > offset + out.count);
|
||||
bool more = out.total > offset + out.count;
|
||||
yyjson_mut_obj_add_bool(doc, root, "has_more", more);
|
||||
if (more) {
|
||||
char hint[128];
|
||||
snprintf(hint, sizeof(hint),
|
||||
"Use offset:%d and limit:%d for next page (%d total)",
|
||||
offset + out.count, limit, (int)out.total);
|
||||
yyjson_mut_obj_add_strcpy(doc, root, "pagination_hint", hint);
|
||||
}
|
||||
}
|
||||
|
||||
char *json = yy_doc_to_str(doc);
|
||||
|
||||
Reference in New Issue
Block a user