// Bitbucket Data Center MCP server — generated by mcpify. Do not hand-edit.

use rusqlite::Connection;

use crate::data::store::search_endpoints;
use crate::services::embedding_service::embed;

/// 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.
pub fn search_operations(
    conn: &Connection,
    query: &str,
    limit: usize,
) -> anyhow::Result<serde_json::Value> {
    let query_embedding = embed(query)?;
    let results = search_endpoints(conn, &query_embedding, limit)?;
    Ok(serde_json::to_value(results)?)
}
