"""MCP tool for semantic search across Fable notes and tasks."""
from __future__ import annotations

from typing import Any

from fable_mcp.client import FableClient


async def search(
    client: FableClient,
    *,
    q: str,
    content_type: str = "all",
    limit: int = 10,
) -> dict[str, Any]:
    """Semantic search over notes and/or tasks.

    Args:
        q: Search query string.
        content_type: One of "note", "task", or "all" (default).
        limit: Maximum number of results to return.

    Returns:
        Dict with "results" list and "total" count.
        Each result has: id, title, body, is_task, tags, similarity.
    """
    params: dict[str, Any] = {"q": q, "limit": limit}
    if content_type != "all":
        params["content_type"] = content_type
    return await client.get("/api/search", params=params)
