"""{{ display_name }} MCP server — generated by mcpify. Do not hand-edit.

Semantic similarity lookup matching a natural-language query against
candidate API operations (PRD §1.5) — so an LLM never needs the full
OpenAPI spec in context to find the right operation.
"""

from __future__ import annotations

from dataclasses import asdict
from typing import Any

import aiosqlite

from ..data.store import search_endpoints
from ..services.embedding_service import embed


async def search_operations(
    conn: aiosqlite.Connection, query: str, limit: int
) -> list[dict[str, Any]]:
    query_embedding = embed(query)
    results = await search_endpoints(conn, query_embedding, limit)
    return [asdict(result) for result in results]
