mcp.c: add missing parameter descriptions for name_pattern, qn_pattern, sort_by, function_name

Previous behavior: name_pattern and qn_pattern had no JSON schema description
in either classic or streamlined tool mode — AI clients saw only
{"type":"string"} with no hint that the field accepts regex or auto-converts
glob wildcards. sort_by in streamlined mode had the enum but no description
of what each value means. function_name in trace_call_path said only
"Function name to trace" with no mention of case-insensitive fallback.

What changed:
- src/mcp/mcp.c TOOLS[] (classic mode, line 287): name_pattern and qn_pattern
  gain description: "Regex pattern on symbol name. Glob wildcards (*tool*,
  foo?) auto-convert to regex."
- src/mcp/mcp.c TOOLS[] (classic mode, line 329): trace_call_path tool
  description adds "Matches exact name first, then falls back to
  case-insensitive search if not found." function_name param gains
  "Case-insensitive fallback if exact match not found."
- src/mcp/mcp.c STREAMLINED_TOOLS[] (line 447): same name_pattern/qn_pattern
  descriptions. sort_by gains description: "Sort order: relevance (PageRank,
  default), name, degree (edge weight), calls (function calls in+out),
  linkrank (link-based rank)."
- src/mcp/mcp.c STREAMLINED_TOOLS[] (line 472): same trace_call_path
  description and function_name param updates.

Why: After fixing three bugs (sort_by validation, glob auto-convert,
trace_call_path fuzzy fallback) in commit 77352a7, the tool schemas served
to AI clients did not describe the new behaviors. AI agents would still
write .*tool.* instead of *tool* (not knowing glob works), not know what
sort_by values mean in streamlined mode, and not know that function_name
matching is case-insensitive.

Testable: codebase-memory-mcp cli tools/list shows updated descriptions.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
This commit is contained in:
Andrew Hundt
2026-04-04 01:44:37 -04:00
parent 6026fa6647
commit ab58abf0f8
+21 -7
View File
@@ -284,7 +284,10 @@ static const tool_def_t TOOLS[] = {
"precise results in one call. When has_more=true, use offset+limit to paginate. "
"Use mode=summary for quick codebase overview without individual results.",
"{\"type\":\"object\",\"properties\":{\"project\":{\"type\":\"string\"},\"label\":{\"type\":"
"\"string\"},\"name_pattern\":{\"type\":\"string\"},\"qn_pattern\":{\"type\":\"string\"},"
"\"string\"},\"name_pattern\":{\"type\":\"string\",\"description\":\"Regex pattern on symbol "
"name. Glob wildcards (*tool*, foo?) auto-convert to regex.\"},"
"\"qn_pattern\":{\"type\":\"string\",\"description\":\"Regex pattern on qualified name. "
"Glob wildcards auto-convert to regex.\"},"
"\"file_pattern\":{\"type\":\"string\"},\"relationship\":{\"type\":\"string\"},\"min_degree\":"
"{\"type\":\"integer\"},\"max_degree\":{\"type\":\"integer\"},\"exclude_entry_points\":{"
"\"type\":\"boolean\"},\"include_connected\":{\"type\":\"boolean\"},\"limit\":{\"type\":"
@@ -324,9 +327,12 @@ static const tool_def_t TOOLS[] = {
{"trace_call_path",
"Trace function call paths — who calls a function and what it calls. Use INSTEAD OF grep when "
"finding callers, dependencies, or impact analysis. Shows candidates array when function name "
"finding callers, dependencies, or impact analysis. Matches exact name first, then falls back "
"to case-insensitive search if not found. Shows candidates array when function name "
"is ambiguous. Results are deduplicated (cycles don't inflate counts).",
"{\"type\":\"object\",\"properties\":{\"function_name\":{\"type\":\"string\"},\"project\":{"
"{\"type\":\"object\",\"properties\":{\"function_name\":{\"type\":\"string\","
"\"description\":\"Function name to trace. Case-insensitive fallback if exact match not found."
"\"},\"project\":{"
"\"type\":\"string\"},\"direction\":{\"type\":\"string\",\"enum\":[\"inbound\",\"outbound\","
"\"both\"],\"default\":\"both\"},\"depth\":{\"type\":\"integer\",\"default\":3},\"max_results"
"\":{\"type\":\"integer\",\"description\":\"Max nodes per direction (configurable via "
@@ -441,9 +447,15 @@ static const tool_def_t STREAMLINED_TOOLS[] = {
"'dep'/'deps' (dependencies only), 'dep.pandas' (specific dep), glob patterns.\"},"
"\"cypher\":{\"type\":\"string\",\"description\":\"Cypher query for complex multi-hop "
"patterns. When provided, other filter params are ignored. Add LIMIT.\"},"
"\"label\":{\"type\":\"string\"},\"name_pattern\":{\"type\":\"string\"},"
"\"qn_pattern\":{\"type\":\"string\"},\"file_pattern\":{\"type\":\"string\"},"
"\"sort_by\":{\"type\":\"string\",\"enum\":[\"relevance\",\"name\",\"degree\",\"calls\",\"linkrank\"]},"
"\"label\":{\"type\":\"string\"},"
"\"name_pattern\":{\"type\":\"string\",\"description\":\"Regex pattern on symbol name. "
"Glob wildcards (*tool*, foo?) auto-convert to regex.\"},"
"\"qn_pattern\":{\"type\":\"string\",\"description\":\"Regex pattern on qualified name. "
"Glob wildcards auto-convert to regex.\"},"
"\"file_pattern\":{\"type\":\"string\"},"
"\"sort_by\":{\"type\":\"string\",\"enum\":[\"relevance\",\"name\",\"degree\",\"calls\",\"linkrank\"],"
"\"description\":\"Sort order: relevance (PageRank, default), name, degree (edge weight), "
"calls (function calls in+out), linkrank (link-based rank).\"},"
"\"mode\":{\"type\":\"string\",\"enum\":[\"full\",\"summary\"]},"
"\"compact\":{\"type\":\"boolean\"},\"include_dependencies\":{\"type\":\"boolean\"},"
"\"limit\":{\"type\":\"integer\"},\"offset\":{\"type\":\"integer\"},"
@@ -460,11 +472,13 @@ static const tool_def_t STREAMLINED_TOOLS[] = {
"Trace function call paths — who calls a function and what it calls. "
"Use for impact analysis, understanding callers, and finding dependencies. "
"Auto-indexes the project on first use if not already indexed. "
"Matches exact name first, then falls back to case-insensitive search if not found. "
"Results sorted by PageRank within each hop level. depth < 1 clamped to 1. "
"direction must be inbound, outbound, or both (invalid values return error). "
"Read codebase://architecture for key functions to start tracing from.",
"{\"type\":\"object\",\"properties\":{"
"\"function_name\":{\"type\":\"string\",\"description\":\"Function name to trace\"},"
"\"function_name\":{\"type\":\"string\",\"description\":\"Function name to trace. "
"Case-insensitive fallback if exact match not found.\"},"
"\"project\":{\"type\":\"string\"},"
"\"direction\":{\"type\":\"string\",\"enum\":[\"inbound\",\"outbound\",\"both\"]},"
"\"depth\":{\"type\":\"integer\",\"default\":3},"