fix(search): cap path_prefixes server-side; unify Iterable typing
Round 3 review follow-ups: - Enforce the folder cap (MAX_PATH_PREFIXES=20) inside normalize_path_prefixes so the REST/viz endpoints are bounded too, not just the MCP tool's Field and the PHP client. Single server-side enforcement point; the MCP tool's Field(max_length=...) now references the same constant. - Widen the SearchAlgorithm ABC and both concrete implementations' path_prefixes param to Iterable[str] | None, matching the widening of build_base_filter_conditions from the prior round. - Add a normalize_path_prefixes cap test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
ea108140ab
commit
9c0c6a0c50
@@ -33,6 +33,7 @@ from nextcloud_mcp_server.observability.metrics import (
|
||||
instrument_tool,
|
||||
)
|
||||
from nextcloud_mcp_server.search.access_filter import (
|
||||
MAX_PATH_PREFIXES,
|
||||
list_accessible_owners,
|
||||
normalize_path_prefixes,
|
||||
)
|
||||
@@ -102,14 +103,14 @@ def configure_semantic_tools(mcp: FastMCP):
|
||||
path_prefixes: Annotated[
|
||||
list[str] | None,
|
||||
Field(
|
||||
max_length=20,
|
||||
max_length=MAX_PATH_PREFIXES,
|
||||
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."
|
||||
f"Capped at {MAX_PATH_PREFIXES} folders to bound the "
|
||||
"OR-filter width. None or empty = no path filter."
|
||||
),
|
||||
),
|
||||
] = None,
|
||||
|
||||
Reference in New Issue
Block a user