From 9206ec59fa7bd73296030fd6531d59ad64c91907 Mon Sep 17 00:00:00 2001 From: cr0ss Date: Thu, 9 Jul 2026 12:36:06 +0200 Subject: [PATCH] MCP search: return top-K nearest, drop hard similarity floor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 0.15 minSimilarity floor dropped valid matches (even an exact name query returned nothing) because 384-dim embeddings compress cosine scores. Return the top-K ranked results and let the agent judge relevance — correct behavior for a small personal contact store. --- app/api/mcp/[transport]/route.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/api/mcp/[transport]/route.ts b/app/api/mcp/[transport]/route.ts index 789dc7a..2b5dd1b 100644 --- a/app/api/mcp/[transport]/route.ts +++ b/app/api/mcp/[transport]/route.ts @@ -30,7 +30,10 @@ const handler = createMcpHandler( }, async ({ query, limit }) => { const embedding = await generateEmbedding(query); - const results = await searchContacts(embedding, limit ?? 5); + // Return the top-K nearest (ranked best-first) with no hard similarity + // floor — the agent judges relevance. A fixed threshold drops valid + // matches because the 384-dim embeddings compress cosine scores. + const results = await searchContacts(embedding, limit ?? 5, 0); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }], };