handle empty search

This commit is contained in:
Gamosoft 2026-03-23 17:49:05 +01:00
parent 8a87ba1a4d
commit 3c3d15fcb2
2 changed files with 9 additions and 1 deletions

View File

@ -1245,6 +1245,14 @@ async def search(
if not config['search']['enabled']: if not config['search']['enabled']:
raise HTTPException(status_code=403, detail="Search is disabled") raise HTTPException(status_code=403, detail="Search is disabled")
# Handle empty query gracefully
if not q or not q.strip():
return {
"results": [],
"query": q,
"message": "No search term provided"
}
results = search_notes(config['storage']['notes_dir'], q) results = search_notes(config['storage']['notes_dir'], q)
# Run plugin hooks # Run plugin hooks

View File

@ -206,7 +206,7 @@ class MCPServer:
def _tool_search_notes(self, args: dict) -> str: def _tool_search_notes(self, args: dict) -> str:
"""Search notes by query.""" """Search notes by query."""
query = args.get("query", "") query = args.get("query", "").strip()
max_results = args.get("max_results") max_results = args.get("max_results")
if not query: if not query: