fix(search): cap path_prefixes at the MCP tool; widen path filter tests

Round 2 review follow-ups:
- Add Field(max_length=20) to the nc_semantic_search path_prefixes param so
  an LLM client can't build an unbounded OR-filter (mirrors the cap the
  Astrolabe PHP controller applies on the UI path).
- Note in normalize_path_prefixes that the two-pass collect-then-strip is
  deliberate (the `if path_prefix:` guard is truthy for whitespace-only
  input; the strip pass is what drops it).
- Tests: exercise build_base_filter_conditions with 3 folders (guards the
  list comprehension) and parametrize the no-path case over None, empty
  list, and blank-only inputs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-06-03 13:10:14 +02:00
co-authored by Claude Opus 4.8
parent cd243ed6c3
commit ea108140ab
3 changed files with 29 additions and 6 deletions
+2
View File
@@ -102,11 +102,13 @@ def configure_semantic_tools(mcp: FastMCP):
path_prefixes: Annotated[
list[str] | None,
Field(
max_length=20,
description=(
"Restrict to files under any of these folders/paths "
"(e.g. ['/Projects/Reports', '/Shared/Specs']). Folders are "
"OR-ed together. Matches the file_path of indexed files "
"only, so setting it implicitly limits results to files. "
"Capped at 20 folders to bound the OR-filter width. "
"None or empty = no path filter."
),
),