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

import { z } from 'zod';

import type { Store } from '../data/store-repository.js';
import { searchEndpoints } from '../data/store-repository.js';
import { embed } from '../services/embedding-service.js';

export const searchInputShape = {
  query: z.string().min(1).describe('Natural-language description of the operation you need'),
  limit: z.number().int().min(1).max(20).default(5).describe('Maximum number of results'),
};

/**
 * 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.
 */
export async function searchOperations(store: Store, query: string, limit = 5) {
  const queryEmbedding = await embed(query);
  return searchEndpoints(store, queryEmbedding, limit);
}
