"""Admin tools: application log access (requires admin API key)."""
from __future__ import annotations

from fable_mcp.client import FableClient


async def get_app_logs(
    client: FableClient,
    category: str = "error",
    limit: int = 20,
    search: str | None = None,
) -> dict:
    """Fetch application logs from Fable. Requires an admin-scoped API key.

    category: "error" | "audit" | "usage" | "generation" (default: "error")
    """
    params: dict = {"category": category, "limit": limit}
    if search:
        params["search"] = search
    return await client.get("/api/admin/logs", params=params)
