@@ -392,9 +392,13 @@ static const tool_def_t TOOLS[] = {
392392 "structure at a glance. Includes 'clusters': Leiden community detection over the call/import "
393393 "graph, surfacing the de-facto modules (each with a label, member count, cohesion score, "
394394 "representative top_nodes, and the packages/edge_types that bind it) — use these to grasp "
395- "the real architectural seams, which often cut across the folder layout." ,
396- "{\"type\":\"object\",\"properties\":{\"project\":{\"type\":\"string\"},\"aspects\":{\"type\":"
397- "\"array\",\"items\":{\"type\":\"string\"}}},\"required\":[\"project\"]}" },
395+ "the real architectural seams, which often cut across the folder layout. Optional path scopes "
396+ "analysis to nodes under that directory prefix (file_path)." ,
397+ "{\"type\":\"object\",\"properties\":{\"project\":{\"type\":\"string\"},\"path\":{\"type\":"
398+ "\"string\",\"description\":\"Optional directory prefix to scope architecture (e.g. "
399+ "apps/hoa)\"},"
400+ "\"aspects\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"required\":[\"project\"]"
401+ "}" },
398402
399403 {"search_code" ,
400404 "Graph-augmented code search. Finds text patterns via grep, then enriches results with "
@@ -1918,12 +1922,14 @@ static void append_cross_repo_summary(yyjson_mut_doc *doc, yyjson_mut_val *root,
19181922
19191923static char * handle_get_architecture (cbm_mcp_server_t * srv , const char * args ) {
19201924 char * project = cbm_mcp_get_string_arg (args , "project" );
1925+ char * scope_path = cbm_mcp_get_string_arg (args , "path" );
19211926 cbm_store_t * store = resolve_store (srv , project );
19221927 REQUIRE_STORE (store , project );
19231928
19241929 char * not_indexed = verify_project_indexed (store , project );
19251930 if (not_indexed ) {
19261931 free (project );
1932+ free (scope_path );
19271933 return not_indexed ;
19281934 }
19291935
@@ -1963,14 +1969,17 @@ static char *handle_get_architecture(cbm_mcp_server_t *srv, const char *args) {
19631969 /* Counts-only: this handler renders label/type counts but never property
19641970 * keys, and full key discovery json_each-scans every row (seconds-to-
19651971 * minutes on multi-million-node graphs). */
1966- cbm_store_get_schema_counts (store , project , & schema );
1972+ cbm_store_get_schema_counts_scoped (store , project , scope_path , & schema );
19671973
19681974 cbm_architecture_info_t arch = {0 };
1969- cbm_store_get_architecture (store , project , aspects_strs_count > 0 ? aspects_strs : NULL ,
1970- aspects_strs_count , & arch );
1975+ cbm_store_get_architecture (store , project , scope_path ,
1976+ aspects_strs_count > 0 ? aspects_strs : NULL , aspects_strs_count ,
1977+ & arch );
19711978
1972- int node_count = cbm_store_count_nodes (store , project );
1973- int edge_count = cbm_store_count_edges (store , project );
1979+ int node_count = cbm_store_count_nodes_scoped (store , project , scope_path );
1980+ int edge_count = cbm_store_count_edges_scoped (store , project , scope_path );
1981+ char norm_path [CBM_SZ_512 ];
1982+ bool path_scoped = cbm_store_normalize_arch_path (scope_path , norm_path , sizeof (norm_path ));
19741983
19751984 yyjson_mut_doc * doc = yyjson_mut_doc_new (NULL );
19761985 yyjson_mut_val * root = yyjson_mut_obj (doc );
@@ -1979,6 +1988,15 @@ static char *handle_get_architecture(cbm_mcp_server_t *srv, const char *args) {
19791988 if (project ) {
19801989 yyjson_mut_obj_add_str (doc , root , "project" , project );
19811990 }
1991+ if (path_scoped ) {
1992+ yyjson_mut_obj_add_str (doc , root , "path" , norm_path );
1993+ int root_nodes = cbm_store_count_nodes (store , project );
1994+ int root_edges = cbm_store_count_edges (store , project );
1995+ yyjson_mut_obj_add_int (doc , root , "root_total_nodes" , root_nodes );
1996+ yyjson_mut_obj_add_int (doc , root , "root_total_edges" , root_edges );
1997+ yyjson_mut_obj_add_int (doc , root , "scoped_total_nodes" , node_count );
1998+ yyjson_mut_obj_add_int (doc , root , "scoped_total_edges" , edge_count );
1999+ }
19822000 yyjson_mut_obj_add_int (doc , root , "total_nodes" , node_count );
19832001 yyjson_mut_obj_add_int (doc , root , "total_edges" , edge_count );
19842002
@@ -2194,6 +2212,7 @@ static char *handle_get_architecture(cbm_mcp_server_t *srv, const char *args) {
21942212 yyjson_doc_free (aspects_doc );
21952213 }
21962214 free (project );
2215+ free (scope_path );
21972216
21982217 char * result = cbm_mcp_text_result (json , false);
21992218 free (json );
0 commit comments