@infino-ai/mcp-server 0.10.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -201,6 +201,7 @@ All configuration is via environment variables — there are no config files and
201
201
  | `INFINO_MCP_EMBED_API_KEY` | No | — | API key for the `openai` provider. Sent as both `Authorization: Bearer` and `api-key`, so one value works for OpenAI and Azure OpenAI. Omit to call an unauthenticated or ambient-identity endpoint. |
202
202
  | `INFINO_MCP_EMBED_MODEL` | No | `Xenova/all-MiniLM-L6-v2` (local) · `text-embedding-3-small` (openai) | The embedding model. For `local`, a Hugging Face feature-extraction model; for `openai`, the model/deployment name. **Must match the model that produced the table's stored vectors** — and therefore its vector-index dimension (e.g. `text-embedding-3-small` is 1536-dim; the default local model is 384-dim). |
203
203
  | `INFINO_MCP_VALIDATE` | No | _off_ | When set (`1`/`true`/`yes`), probes the object store at startup so bad credentials or an unreachable bucket fail then instead of on the first search. |
204
+ | `INFINO_MCP_SNIPPET_CHARS` | No | _off_ (full text) | Deployment default for search snippets: cut the text column of every search hit to this many characters (then `…`). Set it when rows are whole documents rather than chunks, so an agent scanning many hits doesn't pull every document into its context. A per-call `snippetChars` overrides it; `0` means full text. Only the searched text column is cut. |
204
205
 
205
206
  Cloud credentials are read from the standard provider environment variables — the server maps them to the store's config and introduces no credential vars of its own. Omit them entirely to use ambient cloud identity (an IAM instance role or Azure managed identity).
206
207
 
@@ -275,9 +276,9 @@ the data.
275
276
 
276
277
  | Tool | Arguments | What it does |
277
278
  | --- | --- | --- |
278
- | `infino_semantic_search` | `table`, `query`, `k`, `column?`, `vectorColumn?`, `columns?`, `filter?` | Find passages by **meaning** — embeds the query with a local model (no key) and ranks by vector similarity. Handles paraphrase and synonyms. Optional `filter` (`{column, query, mode?}`) restricts the ranking to rows whose keyword column matches first (a pushdown pre-filter). Optional `columns` chooses which fields each hit returns (e.g. a path + line range to cite); defaults to the text column, with `_id` and `score` always included. |
279
- | `infino_keyword_search` | `table`, `query`, `k`, `column?`, `columns?` | BM25 full-text search — for exact terms, identifiers, error codes, product names. |
280
- | `infino_hybrid_search` | `table`, `query`, `k`, `column?`, `vectorColumn?`, `columns?` | **Fused** keyword + semantic search in one ranking pass — BM25 over the text column combined with vector similarity, so rows matching the literal terms *and* the meaning rank highest. |
279
+ | `infino_semantic_search` | `table`, `query`, `k`, `column?`, `vectorColumn?`, `snippetChars?`, `columns?`, `filter?` | Find passages by **meaning** — embeds the query with a local model (no key) and ranks by vector similarity. Handles paraphrase and synonyms. `score` is a **distance** (lower is closer). Optional `filter` (`{column, query, mode?}`) restricts the ranking to rows whose keyword column matches first (a pushdown pre-filter). Optional `columns` chooses which fields each hit returns (e.g. a path + line range to cite); defaults to the text column, with `_id` and `score` always included. |
280
+ | `infino_keyword_search` | `table`, `query`, `k`, `column?`, `snippetChars?`, `columns?` | BM25 full-text search — for exact terms, identifiers, error codes, product names. `score` is a relevance (higher is better). |
281
+ | `infino_hybrid_search` | `table`, `query`, `k`, `column?`, `vectorColumn?`, `snippetChars?`, `columns?` | **Fused** keyword + semantic search in one ranking pass — BM25 over the text column combined with vector similarity, so rows matching the literal terms *and* the meaning rank highest. `score` is the fused rank (higher is better). |
281
282
  | `infino_token_match` | `table`, `query`, `column?`, `mode?`, `limit?` | Unranked keyword filter — the set of rows whose text column contains the token(s). Use when you need the matches, not a relevance order. |
282
283
  | `infino_exact_match` | `table`, `value`, `column?`, `limit?` | Unranked exact-equality filter over an indexed column (tag, status, id string). |
283
284
  | `infino_count` | `table`, `query`, `column?`, `mode?` | Count how many rows match a keyword query, without fetching them — a fast tally over the text column. For the matching rows use `infino_keyword_search` or `infino_token_match`. |
@@ -288,6 +289,8 @@ the data.
288
289
  | `infino_update_documents` | `table`, `predicate`, `documents` | Replace the rows matching a SQL predicate with new documents, 1:1 (missing vectors are embedded). Durable storage only. **Only when `INFINO_MCP_ENABLE_WRITES` is set.** |
289
290
  | `infino_delete_documents` | `table`, `predicate` | Delete the rows matching a SQL predicate. Durable storage only. **Only when `INFINO_MCP_ENABLE_WRITES` is set.** |
290
291
 
292
+ Search hits carry the **full text column** by default, like other vector-store servers. When rows are whole documents rather than pre-chunked passages, set `INFINO_MCP_SNIPPET_CHARS` (for example `300`) so hits carry a snippet instead and an agent can scan many hits without pulling every document into its context; a per-call `snippetChars` overrides the deployment default, and `0` means full text. Only the searched text column is cut, never ids or other projected columns; read any single hit in full with `infino_sql`. Every search response also carries `score_kind`, stating whether its `score` is a distance (semantic: lower is closer) or a relevance (keyword and hybrid: higher is better).
293
+
291
294
  The engine's search table functions (`bm25_search`, `vector_search`, `hybrid_search`, …) are not callable from `infino_sql` — retrieval goes through the dedicated search tools above, which embed and project for you. `infino_sql` is for filters, joins, and aggregates.
292
295
 
293
296
  ---
package/dist/index.js CHANGED
@@ -302,11 +302,60 @@ function searchProjection(columns, textCol) {
302
302
  const base = columns && columns.length > 0 ? columns : textCol ? [textCol] : [];
303
303
  return [...new Set([...base, "_id", "score"])];
304
304
  }
305
+ // Search hits carry the full text column by default. A deployment whose rows
306
+ // are whole documents rather than chunks (a 4 KB transcript per row, say) can
307
+ // set INFINO_MCP_SNIPPET_CHARS so hits carry a snippet instead: an agent
308
+ // reading 50 hits needs enough text to judge relevance, not 50 documents in
309
+ // its context, and it can read any hit in full by id afterwards. The operator
310
+ // knows the row shape; the model finds out only after paying for it once. A
311
+ // per-call `snippetChars` overrides the deployment default either way (0 =
312
+ // full text). Only the searched text column is cut; ids, paths, other
313
+ // projected columns, and scores pass through as-is.
314
+ const SNIPPET_DEFAULT = (() => {
315
+ const raw = process.env.INFINO_MCP_SNIPPET_CHARS;
316
+ if (!raw)
317
+ return 0;
318
+ const n = Number(raw);
319
+ if (!Number.isInteger(n) || n < 0) {
320
+ console.error(`INFINO_MCP_SNIPPET_CHARS must be a non-negative integer (got ${raw}); using full text`);
321
+ return 0;
322
+ }
323
+ return n;
324
+ })();
325
+ const snippetParam = z
326
+ .number()
327
+ .int()
328
+ .min(0)
329
+ .optional()
330
+ .describe("Cut the returned text column to this many characters; 0 returns the full text. " +
331
+ (SNIPPET_DEFAULT > 0
332
+ ? `This deployment defaults to ${SNIPPET_DEFAULT}. `
333
+ : "Defaults to the full text. ") +
334
+ "Pass a small value when asking for many hits, so results stay compact; read a hit in full afterwards with infino_sql.");
335
+ function snippetize(rows, textCol, limit) {
336
+ if (limit <= 0 || !textCol)
337
+ return rows;
338
+ return rows.map((row) => {
339
+ const value = row[textCol];
340
+ return typeof value === "string" && value.length > limit
341
+ ? { ...row, [textCol]: `${value.slice(0, limit)}…` }
342
+ : row;
343
+ });
344
+ }
345
+ // What a hit's `score` means differs per tool, and the direction flips: the
346
+ // engine reports vector kNN as a distance and BM25/RRF as relevance. Every
347
+ // search response says which, so a client never ranks or thresholds backwards.
348
+ const SCORE_KIND = {
349
+ semantic: "distance: lower is closer, 0 is an identical vector",
350
+ keyword: "bm25 relevance: higher is better",
351
+ hybrid: "reciprocal-rank fusion of keyword and semantic ranks: higher is better",
352
+ };
305
353
  server.registerTool("infino_semantic_search", {
306
354
  title: "Semantic (vector) search",
307
355
  description: "Use when searching for a concept by meaning and the exact wording is unknown — this retrieves paraphrases and " +
308
356
  "synonyms, not just literal matches. Embeds the query with a local model (no API key) and ranks a table's " +
309
- "embedding column by vector similarity, each hit with a score. Optional 'filter' restricts the ranking to rows " +
357
+ "embedding column by vector similarity. Each hit carries a score that is a DISTANCE (lower is closer) and the " +
358
+ "text column (full, or a snippet — see snippetChars). Optional 'filter' restricts the ranking to rows " +
310
359
  "whose keyword column matches a predicate first (a pushdown pre-filter, e.g. semantic search only within rows " +
311
360
  "tagged 'billing'). For exact terms use infino_keyword_search; when the query has both literal terms and an " +
312
361
  "intent use infino_hybrid_search.",
@@ -316,6 +365,7 @@ server.registerTool("infino_semantic_search", {
316
365
  k: z.number().int().positive().max(100).default(10).describe("Maximum results."),
317
366
  column: z.string().optional().describe("Text column to return with each hit; inferred if omitted."),
318
367
  vectorColumn: z.string().optional().describe("Vector column to search; inferred if omitted."),
368
+ snippetChars: snippetParam,
319
369
  columns: z
320
370
  .array(z.string())
321
371
  .optional()
@@ -332,7 +382,7 @@ server.registerTool("infino_semantic_search", {
332
382
  .optional()
333
383
  .describe("Pre-filter: rank the kNN only among rows whose FTS 'column' matches 'query' (a pushdown pre-filter, not a post-filter on the results)."),
334
384
  },
335
- }, async ({ table, query, k, column, vectorColumn, columns, filter }) => {
385
+ }, async ({ table, query, k, column, vectorColumn, snippetChars, columns, filter }) => {
336
386
  try {
337
387
  const handle = db.openTable(table);
338
388
  const vecCol = vectorColumn ?? inferVectorColumn(handle);
@@ -342,7 +392,13 @@ server.registerTool("infino_semantic_search", {
342
392
  const vector = await embed(query);
343
393
  const projection = searchProjection(columns, textCol);
344
394
  const { value: results, tookMs } = timed(() => handle.vectorSearch(vecCol, vector, k, { projection, filter }));
345
- return ok({ table, query, results, took_ms: tookMs });
395
+ return ok({
396
+ table,
397
+ query,
398
+ score_kind: SCORE_KIND.semantic,
399
+ results: snippetize(results, textCol, snippetChars ?? SNIPPET_DEFAULT),
400
+ took_ms: tookMs,
401
+ });
346
402
  }
347
403
  catch (err) {
348
404
  return fail(`semantic_search failed: ${errText(err)}`);
@@ -352,7 +408,8 @@ server.registerTool("infino_keyword_search", {
352
408
  title: "Keyword (BM25) search",
353
409
  description: "Use when the query is literal terms — identifiers, error codes, product names, exact phrases — and you want " +
354
410
  "results ranked by relevance. BM25 full-text search over a text column: ranks rows by how well the query's " +
355
- "tokens (and their stems) match, each with a relevance score. Matches exact tokens, not synonyms or paraphrases. " +
411
+ "tokens (and their stems) match, each with a relevance score (higher is better) and the text column (full, or " +
412
+ "a snippet — see snippetChars). Matches exact tokens, not synonyms or paraphrases. " +
356
413
  "Prefer this over SQL LIKE for known literal terms. For meaning-based search use infino_semantic_search; for " +
357
414
  "both at once use infino_hybrid_search.",
358
415
  inputSchema: {
@@ -363,12 +420,13 @@ server.registerTool("infino_keyword_search", {
363
420
  .string()
364
421
  .optional()
365
422
  .describe("Text column to search; inferred from the table schema when omitted."),
423
+ snippetChars: snippetParam,
366
424
  columns: z
367
425
  .array(z.string())
368
426
  .optional()
369
427
  .describe("Columns to return with each hit (e.g. an id, path, or line range to cite). Defaults to the searched column; '_id' and 'score' are always included."),
370
428
  },
371
- }, async ({ table, query, k, column, columns }) => {
429
+ }, async ({ table, query, k, column, snippetChars, columns }) => {
372
430
  try {
373
431
  const handle = db.openTable(table);
374
432
  const col = column ?? inferTextColumn(handle);
@@ -376,7 +434,14 @@ server.registerTool("infino_keyword_search", {
376
434
  return fail(`keyword_search: no text column found in '${table}' — pass 'column' explicitly.`);
377
435
  }
378
436
  const { value: results, tookMs } = timed(() => handle.bm25Search(col, query, k, { projection: searchProjection(columns, col) }));
379
- return ok({ table, column: col, query, results, took_ms: tookMs });
437
+ return ok({
438
+ table,
439
+ column: col,
440
+ query,
441
+ score_kind: SCORE_KIND.keyword,
442
+ results: snippetize(results, col, snippetChars ?? SNIPPET_DEFAULT),
443
+ took_ms: tookMs,
444
+ });
380
445
  }
381
446
  catch (err) {
382
447
  return fail(`keyword_search failed: ${errText(err)}`);
@@ -386,7 +451,8 @@ server.registerTool("infino_hybrid_search", {
386
451
  title: "Hybrid (keyword + semantic) search",
387
452
  description: "Use when a query carries both specific terms and an intent — you want exact-term precision without giving up " +
388
453
  "paraphrase recall. Fuses BM25 over a text column with vector similarity over the embedding column in a single " +
389
- "ranking pass, so rows matching the literal terms AND the meaning rank highest. Embeds the query with a local " +
454
+ "ranking pass, so rows matching the literal terms AND the meaning rank highest; the score is the fused rank " +
455
+ "(higher is better) and each hit carries the text column (full, or a snippet — see snippetChars). Embeds the query with a local " +
390
456
  "model (no API key). Sits between infino_keyword_search (literal only) and infino_semantic_search (meaning only).",
391
457
  inputSchema: {
392
458
  table: z.string().describe("Table to search."),
@@ -394,12 +460,13 @@ server.registerTool("infino_hybrid_search", {
394
460
  k: z.number().int().positive().max(100).default(10).describe("Maximum results."),
395
461
  column: z.string().optional().describe("Text column for the keyword half; inferred if omitted."),
396
462
  vectorColumn: z.string().optional().describe("Vector column for the semantic half; inferred if omitted."),
463
+ snippetChars: snippetParam,
397
464
  columns: z
398
465
  .array(z.string())
399
466
  .optional()
400
467
  .describe("Columns to return with each hit (e.g. an id, path, or line range to cite). Defaults to the text column; '_id' and 'score' are always included."),
401
468
  },
402
- }, async ({ table, query, k, column, vectorColumn, columns }) => {
469
+ }, async ({ table, query, k, column, vectorColumn, snippetChars, columns }) => {
403
470
  try {
404
471
  const handle = db.openTable(table);
405
472
  const textCol = column ?? inferTextColumn(handle);
@@ -412,7 +479,13 @@ server.registerTool("infino_hybrid_search", {
412
479
  const { value: results, tookMs } = timed(() => handle.hybridSearch(textCol, query, vecCol, vector, k, {
413
480
  projection: searchProjection(columns, textCol),
414
481
  }));
415
- return ok({ table, query, results, took_ms: tookMs });
482
+ return ok({
483
+ table,
484
+ query,
485
+ score_kind: SCORE_KIND.hybrid,
486
+ results: snippetize(results, textCol, snippetChars ?? SNIPPET_DEFAULT),
487
+ took_ms: tookMs,
488
+ });
416
489
  }
417
490
  catch (err) {
418
491
  return fail(`hybrid_search failed: ${errText(err)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infino-ai/mcp-server",
3
- "version": "0.10.2",
3
+ "version": "0.11.0",
4
4
  "description": "MCP server for Infino — keyword, vector, hybrid, and SQL retrieval over data on object storage, for AI agents.",
5
5
  "mcpName": "io.github.infino-ai/mcp-server",
6
6
  "license": "Apache-2.0",