handle empty search
This commit is contained in:
parent
8a87ba1a4d
commit
3c3d15fcb2
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue