@infino-ai/mcp-server 0.1.2 → 0.3.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 +19 -1
- package/dist/embedding.js +74 -10
- package/dist/index.js +34 -14
- package/package.json +2 -2
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
|
-
| `
|
|
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) |
|
|
@@ -231,6 +248,7 @@ Cloud credentials are read from the standard provider environment variables —
|
|
|
231
248
|
| `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. |
|
|
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). |
|
|
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`. |
|
|
234
252
|
| `infino_sql` | `query` | SQL for counts, filters, joins, aggregates. Read-only (single `SELECT`/`WITH`) by default; accepts any single statement when `INFINO_MCP_ENABLE_WRITES` is set. |
|
|
235
253
|
| `infino_list_tables` | — | List the tables in the connected catalog. |
|
|
236
254
|
| `infino_describe_table` | `table` | Column names and types for a table. |
|
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
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
//
|
|
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
|
|
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
|
@@ -101,12 +101,6 @@ const fail = (message) => ({
|
|
|
101
101
|
content: [{ type: "text", text: message }],
|
|
102
102
|
isError: true,
|
|
103
103
|
});
|
|
104
|
-
// SQL literal / identifier quoting. The hybrid_search tool builds SQL from
|
|
105
|
-
// caller-supplied table/column names and query text, so every interpolated
|
|
106
|
-
// value is escaped: string args become single-quoted literals, column names
|
|
107
|
-
// become double-quoted identifiers.
|
|
108
|
-
const sqlStr = (s) => `'${s.replace(/'/g, "''")}'`;
|
|
109
|
-
const sqlIdent = (s) => `"${s.replace(/"/g, '""')}"`;
|
|
110
104
|
// When the caller doesn't name a column, search the first UTF-8 text column in
|
|
111
105
|
// the table's schema. (A table can have several; an explicit `column` overrides.)
|
|
112
106
|
function inferTextColumn(table) {
|
|
@@ -304,14 +298,9 @@ server.registerTool("infino_hybrid_search", {
|
|
|
304
298
|
if (!vecCol)
|
|
305
299
|
return fail(`hybrid_search: no vector column in '${table}' — pass 'vectorColumn'.`);
|
|
306
300
|
const vector = await embed(query);
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const cols = [sqlIdent(textCol), "_id", "score"].join(", ");
|
|
311
|
-
const sql = `SELECT ${cols} FROM hybrid_search(` +
|
|
312
|
-
`${sqlStr(table)}, ${sqlStr(textCol)}, ${sqlStr(query)}, ` +
|
|
313
|
-
`${sqlStr(vecCol)}, ${sqlStr(vector.join(","))}, ${k})`;
|
|
314
|
-
const results = db.querySql(sql);
|
|
301
|
+
const results = handle.hybridSearch(textCol, query, vecCol, vector, k, {
|
|
302
|
+
projection: [textCol, "_id", "score"],
|
|
303
|
+
});
|
|
315
304
|
return ok({ table, query, results });
|
|
316
305
|
}
|
|
317
306
|
catch (err) {
|
|
@@ -382,6 +371,37 @@ server.registerTool("infino_exact_match", {
|
|
|
382
371
|
return fail(`exact_match failed: ${err.message}`);
|
|
383
372
|
}
|
|
384
373
|
});
|
|
374
|
+
server.registerTool("infino_count", {
|
|
375
|
+
title: "Count keyword matches",
|
|
376
|
+
description: "Use when you only need HOW MANY rows match a keyword query, not the rows themselves — a fast tally over a text " +
|
|
377
|
+
"column, without fetching or ranking. Cheaper than infino_keyword_search when a number is all you need (e.g. " +
|
|
378
|
+
"'how many docs mention X'). For the matching rows use infino_keyword_search or infino_token_match.",
|
|
379
|
+
inputSchema: {
|
|
380
|
+
table: z.string().describe("Table to search."),
|
|
381
|
+
query: z.string().describe("Query terms, matched as literal tokens."),
|
|
382
|
+
column: z
|
|
383
|
+
.string()
|
|
384
|
+
.optional()
|
|
385
|
+
.describe("Text column to search; inferred from the table schema when omitted."),
|
|
386
|
+
mode: z
|
|
387
|
+
.enum(["or", "and"])
|
|
388
|
+
.optional()
|
|
389
|
+
.describe("Match any token ('or', the default) or every token ('and')."),
|
|
390
|
+
},
|
|
391
|
+
}, async ({ table, query, column, mode }) => {
|
|
392
|
+
try {
|
|
393
|
+
const handle = db.openTable(table);
|
|
394
|
+
const col = column ?? inferTextColumn(handle);
|
|
395
|
+
if (!col) {
|
|
396
|
+
return fail(`count: no text column found in '${table}' — pass 'column' explicitly.`);
|
|
397
|
+
}
|
|
398
|
+
const count = handle.count(col, query, { mode });
|
|
399
|
+
return ok({ table, column: col, query, count });
|
|
400
|
+
}
|
|
401
|
+
catch (err) {
|
|
402
|
+
return fail(`count failed: ${err.message}`);
|
|
403
|
+
}
|
|
404
|
+
});
|
|
385
405
|
server.registerTool("infino_sql", {
|
|
386
406
|
title: "SQL over Infino",
|
|
387
407
|
description: "Use for structural or analytical questions — counts, GROUP BY, joins, aggregates, filtering by exact column " +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infino-ai/mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@huggingface/transformers": "^4.2.0",
|
|
52
|
+
"@infino-ai/infino": "^0.1.2",
|
|
52
53
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
53
|
-
"@infino-ai/infino": "^0.1.1",
|
|
54
54
|
"zod": "^3.23.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|