@infino-ai/mcp-server 0.2.0 → 0.4.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
@@ -180,11 +180,28 @@ All configuration is via environment variables — there are no config files and
180
180
  | --- | --- | --- | --- |
181
181
  | `INFINO_MCP_URI` | No | `~/.infino/mcp` (persistent) | Data to serve: a local path (`/Users/me/.infino/memory`) or a bucket URI (`s3://…`, `az://…`). If unset, a durable per-user directory (`~/.infino/mcp`) is used so data persists across restarts; it falls back to an ephemeral in-process catalog (`memory://`) only if that directory can't be created. |
182
182
  | `INFINO_MCP_ENABLE_WRITES` | No | _off_ | When set (`1`/`true`/`yes`), exposes `infino_add_documents` **and** lets `infino_sql` run DDL/DML. Omit for a strictly read-only server. |
183
- | `INFINO_MCP_EMBED_MODEL` | No | `Xenova/all-MiniLM-L6-v2` | Hugging Face feature-extraction model used for embedding. Must match the table's vector index dimension (default model is 384-dim). |
183
+ | `INFINO_MCP_EMBED_PROVIDER` | No | `local` | Embedding provider: `local` (Hugging Face transformers.js, no key, nothing leaves the machine) or `openai` (any OpenAI-compatible `/embeddings` endpoint — OpenAI, Azure OpenAI's `/openai/v1` surface, or a compatible server). Inferred as `openai` when `INFINO_MCP_EMBED_BASE_URL` is set. |
184
+ | `INFINO_MCP_EMBED_BASE_URL` | With `openai` | — | Base URL of the OpenAI-compatible embeddings API, e.g. `https://api.openai.com/v1` or `https://<resource>.openai.azure.com/openai/v1`. The server POSTs to `<base>/embeddings`. |
185
+ | `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. |
186
+ | `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). |
184
187
  | `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. |
185
188
 
186
189
  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).
187
190
 
191
+ **Serving a catalog embedded with OpenAI / Azure OpenAI.** If your tables were vectorized with a hosted embedding model rather than the local default, point the server at that same model so query and document vectors align:
192
+
193
+ ```jsonc
194
+ "env": {
195
+ "INFINO_MCP_URI": "s3://my-bucket/infino",
196
+ "INFINO_MCP_EMBED_PROVIDER": "openai",
197
+ "INFINO_MCP_EMBED_BASE_URL": "https://my-resource.openai.azure.com/openai/v1",
198
+ "INFINO_MCP_EMBED_API_KEY": "…",
199
+ "INFINO_MCP_EMBED_MODEL": "text-embedding-3-small"
200
+ }
201
+ ```
202
+
203
+ The model must match what produced the stored vectors — a mismatch yields meaningless similarity or a dimension error. Keyword and SQL search are unaffected by the embedder.
204
+
188
205
  | Backend | Credentials |
189
206
  | --- | --- |
190
207
  | AWS S3 | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` (+ `AWS_SESSION_TOKEN`, `AWS_REGION` if used) |
@@ -226,9 +243,9 @@ Cloud credentials are read from the standard provider environment variables —
226
243
 
227
244
  | Tool | Arguments | What it does |
228
245
  | --- | --- | --- |
229
- | `infino_semantic_search` | `table`, `query`, `k`, `column?`, `vectorColumn?`, `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). |
230
- | `infino_keyword_search` | `table`, `query`, `k`, `column?` | BM25 full-text search — for exact terms, identifiers, error codes, product names. |
231
- | `infino_hybrid_search` | `table`, `query`, `k`, `column?`, `vectorColumn?` | **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. |
246
+ | `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. |
247
+ | `infino_keyword_search` | `table`, `query`, `k`, `column?`, `columns?` | BM25 full-text search — for exact terms, identifiers, error codes, product names. |
248
+ | `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. |
232
249
  | `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. |
233
250
  | `infino_exact_match` | `table`, `value`, `column?`, `limit?` | Unranked exact-equality filter over an indexed column (tag, status, id string). |
234
251
  | `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`. |
package/dist/embedding.js CHANGED
@@ -3,16 +3,39 @@
3
3
  //
4
4
  // Server-side embedding. infino is bring-your-own-vectors (the engine doesn't
5
5
  // embed) and an agent can't produce a query vector — so the server turns text
6
- // into vectors for semantic search.
6
+ // into vectors for semantic search. The server embeds both queries and, when
7
+ // writes are enabled, ingested documents with the SAME model, so they align.
7
8
  //
8
- // Embedding is LOCAL: a Hugging Face transformers.js model (all-MiniLM-L6-v2,
9
- // 384-dim by default) downloaded once, with no API key and no per-query
10
- // network. The server embeds both ingested documents (infino_add_documents)
11
- // and queries with the same model, so they always align. Override the model
12
- // with INFINO_MCP_EMBED_MODEL (any HF feature-extraction model); the table's
13
- // vector index must match its dimension.
14
- const MODEL = process.env.INFINO_MCP_EMBED_MODEL ?? "Xenova/all-MiniLM-L6-v2";
15
- // Lazily load the pipeline once and reuse it; the first call downloads + caches the model.
9
+ // Two providers, selected by environment:
10
+ //
11
+ // • local (default) — a Hugging Face transformers.js model
12
+ // (all-MiniLM-L6-v2, 384-dim) downloaded once, no API key, no per-query
13
+ // network. Override the model with INFINO_MCP_EMBED_MODEL.
14
+ //
15
+ // • openai — any OpenAI-compatible /embeddings endpoint (OpenAI, Azure
16
+ // OpenAI's /openai/v1 surface, or a self-hosted compatible server). Use
17
+ // this to serve a catalog whose vectors were produced by that same
18
+ // provider/model — e.g. a table embedded with text-embedding-3-small
19
+ // (1536-dim). Set INFINO_MCP_EMBED_BASE_URL (+ INFINO_MCP_EMBED_API_KEY,
20
+ // INFINO_MCP_EMBED_MODEL).
21
+ //
22
+ // Whichever provider you use, its model MUST match the model that produced the
23
+ // table's stored vectors (and the vector index's dimension), or semantic /
24
+ // hybrid search returns meaningless results (or errors on a dimension mismatch).
25
+ const PROVIDER = (process.env.INFINO_MCP_EMBED_PROVIDER ?? "").toLowerCase();
26
+ const BASE_URL = process.env.INFINO_MCP_EMBED_BASE_URL;
27
+ const API_KEY = process.env.INFINO_MCP_EMBED_API_KEY;
28
+ // Resolve the provider: explicit INFINO_MCP_EMBED_PROVIDER wins; otherwise a
29
+ // base URL implies the remote provider; otherwise local.
30
+ const USE_REMOTE = PROVIDER === "openai" ||
31
+ PROVIDER === "azure" ||
32
+ (PROVIDER === "" && typeof BASE_URL === "string" && BASE_URL.length > 0);
33
+ const LOCAL_MODEL_DEFAULT = "Xenova/all-MiniLM-L6-v2";
34
+ const REMOTE_MODEL_DEFAULT = "text-embedding-3-small";
35
+ const MODEL = process.env.INFINO_MCP_EMBED_MODEL ??
36
+ (USE_REMOTE ? REMOTE_MODEL_DEFAULT : LOCAL_MODEL_DEFAULT);
37
+ // Lazily load the local pipeline once and reuse it; the first call downloads +
38
+ // caches the model. Never imported when a remote provider is configured.
16
39
  let pipe = null;
17
40
  function getPipe() {
18
41
  if (!pipe) {
@@ -23,8 +46,39 @@ function getPipe() {
23
46
  }
24
47
  return pipe;
25
48
  }
26
- /** Embed one text into a vector with the local model. */
49
+ /** Embed one text via an OpenAI-compatible /embeddings endpoint. */
50
+ async function embedRemote(text) {
51
+ if (!BASE_URL) {
52
+ throw new Error("INFINO_MCP_EMBED_BASE_URL is required when INFINO_MCP_EMBED_PROVIDER is 'openai'.");
53
+ }
54
+ const url = `${BASE_URL.replace(/\/$/, "")}/embeddings`;
55
+ const headers = { "content-type": "application/json" };
56
+ // Send both auth styles so one config works for OpenAI (Authorization:
57
+ // Bearer) and Azure OpenAI's v1 surface (api-key); each ignores the other.
58
+ if (API_KEY) {
59
+ headers["authorization"] = `Bearer ${API_KEY}`;
60
+ headers["api-key"] = API_KEY;
61
+ }
62
+ const res = await fetch(url, {
63
+ method: "POST",
64
+ headers,
65
+ body: JSON.stringify({ model: MODEL, input: text }),
66
+ });
67
+ if (!res.ok) {
68
+ const detail = await res.text().catch(() => "");
69
+ throw new Error(`embeddings request failed: HTTP ${res.status} ${detail.slice(0, 300)}`);
70
+ }
71
+ const body = (await res.json());
72
+ const vector = body?.data?.[0]?.embedding;
73
+ if (!Array.isArray(vector)) {
74
+ throw new Error("embeddings response did not contain data[0].embedding");
75
+ }
76
+ return Array.from(vector, Number);
77
+ }
78
+ /** Embed one text into a vector with the configured provider. */
27
79
  export async function embed(text) {
80
+ if (USE_REMOTE)
81
+ return embedRemote(text);
28
82
  const extractor = await getPipe();
29
83
  // Mean-pool token vectors and L2-normalize → one sentence embedding.
30
84
  const output = await extractor(text, { pooling: "mean", normalize: true });
@@ -32,5 +86,15 @@ export async function embed(text) {
32
86
  }
33
87
  /** Human-readable description of the embedder, for the startup log. */
34
88
  export function embedderInfo() {
89
+ if (USE_REMOTE) {
90
+ let host = BASE_URL ?? "?";
91
+ try {
92
+ host = new URL(BASE_URL).host;
93
+ }
94
+ catch {
95
+ /* keep raw value if not a valid URL */
96
+ }
97
+ return `remote ${MODEL} @ ${host}${API_KEY ? "" : " (no key)"}`;
98
+ }
35
99
  return `local ${MODEL} (no key)`;
36
100
  }
package/dist/index.js CHANGED
@@ -203,6 +203,15 @@ server.registerTool("infino_describe_table", {
203
203
  return fail(`describe_table failed: ${err.message}`);
204
204
  }
205
205
  });
206
+ // Build the returned-column projection for a search hit. A caller-supplied
207
+ // `columns` list is honored so clients can retrieve the fields they need
208
+ // (e.g. a path + line range to cite), with `_id` and `score` always appended
209
+ // so every hit keeps its id and ranking score. Defaults to the (searched)
210
+ // text column plus `_id`/`score`.
211
+ function searchProjection(columns, textCol) {
212
+ const base = columns && columns.length > 0 ? columns : textCol ? [textCol] : [];
213
+ return [...new Set([...base, "_id", "score"])];
214
+ }
206
215
  server.registerTool("infino_semantic_search", {
207
216
  title: "Semantic (vector) search",
208
217
  description: "Use when searching for a concept by meaning and the exact wording is unknown — this retrieves paraphrases and " +
@@ -217,6 +226,10 @@ server.registerTool("infino_semantic_search", {
217
226
  k: z.number().int().positive().max(100).default(10).describe("Maximum results."),
218
227
  column: z.string().optional().describe("Text column to return with each hit; inferred if omitted."),
219
228
  vectorColumn: z.string().optional().describe("Vector column to search; inferred if omitted."),
229
+ columns: z
230
+ .array(z.string())
231
+ .optional()
232
+ .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."),
220
233
  filter: z
221
234
  .object({
222
235
  column: z.string().describe("Keyword-indexed (FTS) column the predicate applies to."),
@@ -229,7 +242,7 @@ server.registerTool("infino_semantic_search", {
229
242
  .optional()
230
243
  .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)."),
231
244
  },
232
- }, async ({ table, query, k, column, vectorColumn, filter }) => {
245
+ }, async ({ table, query, k, column, vectorColumn, columns, filter }) => {
233
246
  try {
234
247
  const handle = db.openTable(table);
235
248
  const vecCol = vectorColumn ?? inferVectorColumn(handle);
@@ -237,7 +250,7 @@ server.registerTool("infino_semantic_search", {
237
250
  return fail(`semantic_search: no vector column in '${table}' — pass 'vectorColumn'.`);
238
251
  const textCol = column ?? inferTextColumn(handle);
239
252
  const vector = await embed(query);
240
- const projection = textCol ? [textCol, "_id", "score"] : ["_id", "score"];
253
+ const projection = searchProjection(columns, textCol);
241
254
  const results = handle.vectorSearch(vecCol, vector, k, { projection, filter });
242
255
  return ok({ table, query, results });
243
256
  }
@@ -260,15 +273,19 @@ server.registerTool("infino_keyword_search", {
260
273
  .string()
261
274
  .optional()
262
275
  .describe("Text column to search; inferred from the table schema when omitted."),
276
+ columns: z
277
+ .array(z.string())
278
+ .optional()
279
+ .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."),
263
280
  },
264
- }, async ({ table, query, k, column }) => {
281
+ }, async ({ table, query, k, column, columns }) => {
265
282
  try {
266
283
  const handle = db.openTable(table);
267
284
  const col = column ?? inferTextColumn(handle);
268
285
  if (!col) {
269
286
  return fail(`keyword_search: no text column found in '${table}' — pass 'column' explicitly.`);
270
287
  }
271
- const results = handle.bm25Search(col, query, k, { projection: [col, "_id", "score"] });
288
+ const results = handle.bm25Search(col, query, k, { projection: searchProjection(columns, col) });
272
289
  return ok({ table, column: col, query, results });
273
290
  }
274
291
  catch (err) {
@@ -287,8 +304,12 @@ server.registerTool("infino_hybrid_search", {
287
304
  k: z.number().int().positive().max(100).default(10).describe("Maximum results."),
288
305
  column: z.string().optional().describe("Text column for the keyword half; inferred if omitted."),
289
306
  vectorColumn: z.string().optional().describe("Vector column for the semantic half; inferred if omitted."),
307
+ columns: z
308
+ .array(z.string())
309
+ .optional()
310
+ .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."),
290
311
  },
291
- }, async ({ table, query, k, column, vectorColumn }) => {
312
+ }, async ({ table, query, k, column, vectorColumn, columns }) => {
292
313
  try {
293
314
  const handle = db.openTable(table);
294
315
  const textCol = column ?? inferTextColumn(handle);
@@ -299,7 +320,7 @@ server.registerTool("infino_hybrid_search", {
299
320
  return fail(`hybrid_search: no vector column in '${table}' — pass 'vectorColumn'.`);
300
321
  const vector = await embed(query);
301
322
  const results = handle.hybridSearch(textCol, query, vecCol, vector, k, {
302
- projection: [textCol, "_id", "score"],
323
+ projection: searchProjection(columns, textCol),
303
324
  });
304
325
  return ok({ table, query, results });
305
326
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infino-ai/mcp-server",
3
- "version": "0.2.0",
3
+ "version": "0.4.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",