Skip to content

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.

fix(mcp): cap search_graph default limit to 200 (was 500K) (#231)

amitmynd9425b99fd5c2
diff --git a/src/mcp/mcp.c b/src/mcp/mcp.c
index 71f8e7234..0db5554d2 100644
--- a/src/mcp/mcp.c
+++ b/src/mcp/mcp.c
@@ -304,7 +304,7 @@ static const tool_def_t TOOLS[] = {
"that score well on ALL keywords. Requires moderate/full index mode. Results appear in the "
"'semantic_results' field (separate from 'results').\"},\"limit\":{\"type\":"
"\"integer\",\"description\":\"Max results. Default: "
- "unlimited\"},\"offset\":{\"type\":\"integer\",\"default\":0}},\"required\":[\"project\"]}"},
+ "200\"},\"offset\":{\"type\":\"integer\",\"default\":0}},\"required\":[\"project\"]}"},
{"query_graph",
"Execute a Cypher query against the knowledge graph for complex multi-hop patterns, "
@@ -1389,7 +1389,8 @@ static char *handle_search_graph(cbm_mcp_server_t *srv, const char *args) {
char *relationship = cbm_mcp_get_string_arg(args, "relationship");
bool exclude_entry_points = cbm_mcp_get_bool_arg(args, "exclude_entry_points");
bool include_connected = cbm_mcp_get_bool_arg(args, "include_connected");
- int limit = cbm_mcp_get_int_arg(args, "limit", MCP_HALF_SEC_US);
+ enum { SEARCH_DEFAULT_LIMIT = 200 };
+ int limit = cbm_mcp_get_int_arg(args, "limit", SEARCH_DEFAULT_LIMIT);
int offset = cbm_mcp_get_int_arg(args, "offset", 0);
int min_degree = cbm_mcp_get_int_arg(args, "min_degree", CBM_NOT_FOUND);
int max_degree = cbm_mcp_get_int_arg(args, "max_degree", CBM_NOT_FOUND);
diff --git a/src/store/store.c b/src/store/store.c
index b9070f1ed..8f89e778f 100644
--- a/src/store/store.c
+++ b/src/store/store.c
@@ -2304,7 +2304,8 @@ int cbm_store_search(cbm_store_t *s, const cbm_search_params_t *params, cbm_sear
snprintf(count_sql, sizeof(count_sql), "SELECT COUNT(*) FROM (%s)", sql);
/* Add ORDER BY + LIMIT */
- int limit = params->limit > 0 ? params->limit : ST_HALF_SEC;
+ enum { ST_DEFAULT_SEARCH_LIMIT = 200 };
+ int limit = params->limit > 0 ? params->limit : ST_DEFAULT_SEARCH_LIMIT;
int offset = params->offset;
const char *name_col = has_degree_filter ? "name" : "n.name";
char order_limit[CBM_SZ_128];