Skip to content

Commit ea65a25

Browse files
author
Your Name
committed
feat(mcp): expose BM25 query and sort_by params in search_graph schema
The search_graph handler already supports FTS5 BM25 full-text search via a 'query' parameter and sort control via 'sort_by', but neither was declared in the tool's inputSchema. AI agents calling search_graph had no way to discover or use these parameters. Adds to inputSchema: - query: BM25 full-text search with structural boosting (Function/Method +10, Route +8, Class +5, high-fan-in +3). Filters out File/Folder/Module/ Variable/Project noise. Tokenizes input as OR terms for broad matching. - sort_by: 'relevance' (default with query), 'name', 'file_path' Updates tool description to document both search modes: (1) query='terms' for ranked full-text discovery (2) name_pattern='regex' for exact pattern matching
1 parent 22408ed commit ea65a25

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

src/mcp/mcp.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,25 @@ static const tool_def_t TOOLS[] = {
236236
{"search_graph",
237237
"Search the code knowledge graph for functions, classes, routes, and variables. Use INSTEAD "
238238
"OF grep/glob when finding code definitions, implementations, or relationships. Returns "
239-
"precise results in one call.",
240-
"{\"type\":\"object\",\"properties\":{\"project\":{\"type\":\"string\"},\"label\":{\"type\":"
241-
"\"string\"},\"name_pattern\":{\"type\":\"string\"},\"qn_pattern\":{\"type\":\"string\"},"
242-
"\"file_pattern\":{\"type\":\"string\"},\"relationship\":{\"type\":\"string\"},\"min_degree\":"
243-
"{\"type\":\"integer\"},\"max_degree\":{\"type\":\"integer\"},\"exclude_entry_points\":{"
244-
"\"type\":\"boolean\"},\"include_connected\":{\"type\":\"boolean\"},\"limit\":{\"type\":"
245-
"\"integer\",\"description\":\"Max results. Default: "
239+
"precise results in one call. Two modes: (1) query='search terms' for BM25 ranked full-text "
240+
"search with structural boosting (recommended for discovery and conceptual search), "
241+
"(2) name_pattern='regex' for exact pattern matching.",
242+
"{\"type\":\"object\",\"properties\":{\"project\":{\"type\":\"string\"},"
243+
"\"query\":{\"type\":\"string\",\"description\":\"Natural language or keyword search using "
244+
"BM25 full-text ranking. Searches function names, class names, qualified names, and file "
245+
"paths. Results ranked by relevance with structural boosting (Functions/Methods +10, "
246+
"Routes +8, Classes +5, high-fan-in +3). Filters out noise nodes (File/Folder/Module/"
247+
"Variable). Example: 'session management' or 'error handling'. When provided, name_pattern "
248+
"is ignored.\"},"
249+
"\"label\":{\"type\":\"string\"},\"name_pattern\":{\"type\":\"string\"},"
250+
"\"qn_pattern\":{\"type\":\"string\"},"
251+
"\"file_pattern\":{\"type\":\"string\"},\"relationship\":{\"type\":\"string\"},"
252+
"\"min_degree\":{\"type\":\"integer\"},\"max_degree\":{\"type\":\"integer\"},"
253+
"\"exclude_entry_points\":{\"type\":\"boolean\"},\"include_connected\":{\"type\":"
254+
"\"boolean\"},"
255+
"\"sort_by\":{\"type\":\"string\",\"description\":\"Sort by: relevance (default with "
256+
"query), name, file_path\"},"
257+
"\"limit\":{\"type\":\"integer\",\"description\":\"Max results. Default: "
246258
"unlimited\"},\"offset\":{\"type\":\"integer\",\"default\":0}},\"required\":[\"project\"]}"},
247259

248260
{"query_graph",

0 commit comments

Comments
 (0)