@infino-ai/mcp-server 0.4.0 → 0.7.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 +41 -8
- package/dist/index.js +124 -55
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
An [MCP](https://modelcontextprotocol.io) server for [Infino](https://github.com/infino-ai/infino) — it lets an AI agent run **keyword**, **semantic**, **hybrid**, and **SQL** retrieval over your data on object storage, from any MCP-compatible client (Claude Code, Claude Desktop, Cursor, VS Code, and others). Published on npm as [`@infino-ai/mcp-server`](https://www.npmjs.com/package/@infino-ai/mcp-server) and listed on the [official MCP Registry](https://registry.modelcontextprotocol.io) as `io.github.infino-ai/mcp-server` (which propagates to catalogs like Smithery, Glama, and PulseMCP).
|
|
8
8
|
|
|
9
|
-
- **
|
|
9
|
+
- **Local embeddings, no key.** Semantic search embeds queries with a local model — nothing leaves the machine for embedding.
|
|
10
10
|
- **Read-only by default.** Writes and full SQL are opt-in behind a single environment flag.
|
|
11
|
-
- **
|
|
11
|
+
- **Local or hosted.** Point it at a local path, your own bucket (S3, Azure, or any S3-compatible store), or a hosted Infino Cloud endpoint with an API key.
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -39,7 +39,7 @@ An [MCP](https://modelcontextprotocol.io) server for [Infino](https://github.com
|
|
|
39
39
|
|
|
40
40
|
- **Node.js ≥ 18** (the server runs as a Node process over stdio).
|
|
41
41
|
- **An MCP-compatible client** (Claude Code, Claude Desktop, Cursor, VS Code, …).
|
|
42
|
-
- **Data reachable by Infino** — a local directory,
|
|
42
|
+
- **Data reachable by Infino** — a local directory, a bucket with credentials available in the environment, or a hosted Infino Cloud endpoint with an API key (see [Storage backends](#storage-backends)).
|
|
43
43
|
- On first run the server downloads the local embedding model (~90 MB) once and caches it; subsequent runs are offline for embedding.
|
|
44
44
|
|
|
45
45
|
---
|
|
@@ -58,6 +58,21 @@ The server is launched by your MCP client over stdio — you don't run it direct
|
|
|
58
58
|
}
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
+
To serve a **hosted Infino Cloud** database instead, point `INFINO_MCP_URI` at
|
|
62
|
+
the `https://<host>/<database>` endpoint and supply your API key — everything
|
|
63
|
+
else (the tools, the read-only default) is identical:
|
|
64
|
+
|
|
65
|
+
```jsonc
|
|
66
|
+
{
|
|
67
|
+
"command": "npx",
|
|
68
|
+
"args": ["-y", "@infino-ai/mcp-server"],
|
|
69
|
+
"env": {
|
|
70
|
+
"INFINO_MCP_URI": "https://api.platform.infino.ai/my-database",
|
|
71
|
+
"INFINO_API_KEY": "inf_…"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
61
76
|
The sections below show the exact place each client expects this block.
|
|
62
77
|
|
|
63
78
|
---
|
|
@@ -178,7 +193,8 @@ All configuration is via environment variables — there are no config files and
|
|
|
178
193
|
|
|
179
194
|
| Variable | Required | Default | Description |
|
|
180
195
|
| --- | --- | --- | --- |
|
|
181
|
-
| `INFINO_MCP_URI` | No | `~/.infino/mcp` (persistent) | Data to serve: a local path (`/Users/me/.infino/memory`)
|
|
196
|
+
| `INFINO_MCP_URI` | No | `~/.infino/mcp` (persistent) | Data to serve: a local path (`/Users/me/.infino/memory`), a bucket URI (`s3://…`, `az://…`), or a hosted endpoint (`https://<host>/<database>`, Infino Cloud). 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. |
|
|
197
|
+
| `INFINO_API_KEY` | With a hosted URI | — | API key (`inf_…`) for a hosted `https://` endpoint. Required when `INFINO_MCP_URI` is an `https://` URI; ignored for local and object-storage connections. |
|
|
182
198
|
| `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
199
|
| `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
200
|
| `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`. |
|
|
@@ -207,6 +223,7 @@ The model must match what produced the stored vectors — a mismatch yields mean
|
|
|
207
223
|
| AWS S3 | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` (+ `AWS_SESSION_TOKEN`, `AWS_REGION` if used) |
|
|
208
224
|
| S3-compatible (R2/MinIO/B2) | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` **and** `AWS_ENDPOINT_URL` |
|
|
209
225
|
| Azure Blob | `AZURE_STORAGE_ACCOUNT`, `AZURE_STORAGE_KEY` |
|
|
226
|
+
| Infino Cloud (hosted) | `INFINO_API_KEY` — no object-storage credentials needed (the platform owns the storage) |
|
|
210
227
|
|
|
211
228
|
### Storage backends
|
|
212
229
|
|
|
@@ -235,8 +252,23 @@ The model must match what produced the stored vectors — a mismatch yields mean
|
|
|
235
252
|
"AZURE_STORAGE_ACCOUNT": "…",
|
|
236
253
|
"AZURE_STORAGE_KEY": "…"
|
|
237
254
|
}
|
|
255
|
+
|
|
256
|
+
// Infino Cloud (hosted) — the database is the last path segment
|
|
257
|
+
"env": {
|
|
258
|
+
"INFINO_MCP_URI": "https://api.platform.infino.ai/my-database",
|
|
259
|
+
"INFINO_API_KEY": "inf_…"
|
|
260
|
+
}
|
|
238
261
|
```
|
|
239
262
|
|
|
263
|
+
On a hosted connection the search, SQL, and (when enabled) write tools all
|
|
264
|
+
behave exactly as they do locally — the only difference is where the data
|
|
265
|
+
lives. Compaction and garbage collection are handled server-side, so they are
|
|
266
|
+
not exposed as client operations. Note that semantic and hybrid search still
|
|
267
|
+
embed queries **locally** in this server, so `INFINO_MCP_EMBED_MODEL` must match
|
|
268
|
+
the model that produced the hosted table's stored vectors (see the OpenAI /
|
|
269
|
+
Azure OpenAI note above) — this matters especially when someone else ingested
|
|
270
|
+
the data.
|
|
271
|
+
|
|
240
272
|
---
|
|
241
273
|
|
|
242
274
|
## Tools
|
|
@@ -262,11 +294,11 @@ The engine's search table functions (`bm25_search`, `vector_search`, `hybrid_sea
|
|
|
262
294
|
|
|
263
295
|
## Security & data handling
|
|
264
296
|
|
|
265
|
-
This server
|
|
297
|
+
This server runs locally, beside the client, and keeps data and credentials on the user's machine.
|
|
266
298
|
|
|
267
|
-
- **Local execution.** It runs as a subprocess of your MCP client over stdio
|
|
268
|
-
- **No data sent for embedding.** Query and document embedding uses a local model — text is never sent to a third-party embedding API. There is no API key to provision or leak.
|
|
269
|
-
- **Credentials stay in the environment.** Storage credentials are read from
|
|
299
|
+
- **Local execution, no inbound listener.** It runs as a subprocess of your MCP client over stdio and opens no network listener. In the default local/bucket mode it contacts no remote service. When `INFINO_MCP_URI` is a hosted `https://` endpoint, it makes **outbound** TLS calls to that endpoint to serve searches, SQL, and (if enabled) writes — so the data in those requests reaches the hosted service you configured, and nothing else.
|
|
300
|
+
- **No data sent for embedding.** Query and document embedding uses a local model — text is never sent to a third-party embedding API. There is no embedding API key to provision or leak. (This holds in both local and hosted mode: only the resulting query vector, not the raw text of the embed input, is sent to a hosted endpoint.)
|
|
301
|
+
- **Credentials stay in the environment.** Storage credentials (`AWS_*`/`AZURE_*`) and the hosted API key (`INFINO_API_KEY`) are read from environment variables and used only to reach the store or endpoint you configured. They are never logged or returned in tool output.
|
|
270
302
|
- **Read-only by default.** Without `INFINO_MCP_ENABLE_WRITES`, the write tool is not even advertised to the agent, and `infino_sql` rejects anything but a single `SELECT`/`WITH`. Enable writes deliberately, and prefer scoping the server to data the agent is allowed to modify.
|
|
271
303
|
- **Least privilege.** Point `INFINO_MCP_URI` at the narrowest dataset the task needs, and supply storage credentials scoped to that bucket/prefix.
|
|
272
304
|
|
|
@@ -288,6 +320,7 @@ If you change `INFINO_MCP_EMBED_MODEL`, the table's vector index must match the
|
|
|
288
320
|
| `INFINO_MCP_URI is required` | The env var isn't reaching the subprocess. In GUI clients, env must be inside the server's `env` block (the process won't inherit your shell). |
|
|
289
321
|
| `add_documents` not available | `INFINO_MCP_ENABLE_WRITES` isn't set, or the client wasn't restarted after setting it. |
|
|
290
322
|
| Slow first query | One-time embedding-model download (~90 MB). Subsequent runs use the cache. |
|
|
323
|
+
| Auth error against a hosted `https://` URI | `INFINO_API_KEY` is missing, wrong, or lacks access to that database. Confirm the key (`inf_…`) and that the URI's last path segment is a database you can reach. |
|
|
291
324
|
| Dimension / vector errors on semantic search | The table's vector index doesn't match the embedding model's dimension. Re-ingest, or set `INFINO_MCP_EMBED_MODEL` to the model the index was built with. |
|
|
292
325
|
| `… in SQL isn't supported from the server yet` | You called a search table function inside `infino_sql`. Use `infino_semantic_search` / `infino_keyword_search` instead. |
|
|
293
326
|
|
package/dist/index.js
CHANGED
|
@@ -18,10 +18,13 @@ import { embed, embedderInfo } from "./embedding.js";
|
|
|
18
18
|
// --- connection (env-configured, opened once at startup) -------------------
|
|
19
19
|
//
|
|
20
20
|
// The agent never manages connections: the server is pointed at the data via
|
|
21
|
-
// INFINO_MCP_URI
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
21
|
+
// INFINO_MCP_URI, which selects the backend by its scheme:
|
|
22
|
+
// - a local path or an s3://|az:// bucket → an embedded catalog opened
|
|
23
|
+
// in-process, with credentials from the standard AWS_*/AZURE_* variables
|
|
24
|
+
// (AWS S3 uses the default endpoint; for an S3-compatible store — Cloudflare
|
|
25
|
+
// R2, MinIO, Backblaze B2 — set AWS_ENDPOINT_URL alongside the AWS_* keys);
|
|
26
|
+
// - an https://<host>/<database> URI → the hosted Infino Cloud service,
|
|
27
|
+
// authenticated with an API key (INFINO_API_KEY).
|
|
25
28
|
// When INFINO_MCP_URI is unset, default to a durable per-user directory so a
|
|
26
29
|
// fresh install persists across restarts with no configuration. Fall back to
|
|
27
30
|
// an ephemeral in-process catalog if that directory can't be created (a
|
|
@@ -34,7 +37,8 @@ function defaultUri() {
|
|
|
34
37
|
mkdirSync(dir, { recursive: true });
|
|
35
38
|
console.error(`INFINO_MCP_URI not set — using ${dir} (persistent; read-only until ` +
|
|
36
39
|
"INFINO_MCP_ENABLE_WRITES is set). Set INFINO_MCP_URI to point at your " +
|
|
37
|
-
"own path
|
|
40
|
+
"own path, an s3://|az:// bucket, or a hosted https://<host>/<database> " +
|
|
41
|
+
"endpoint.");
|
|
38
42
|
return dir;
|
|
39
43
|
}
|
|
40
44
|
catch (err) {
|
|
@@ -45,11 +49,18 @@ function defaultUri() {
|
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
const uri = process.env.INFINO_MCP_URI ?? defaultUri();
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
52
|
+
// A hosted (Infino Cloud) target is an https:// URI that carries the database
|
|
53
|
+
// in its path (https://<host>/<database>); any other scheme is an embedded
|
|
54
|
+
// catalog on a local path or an object-storage bucket. The two authenticate
|
|
55
|
+
// differently — a hosted connection with an API key, an embedded one with the
|
|
56
|
+
// object store's own AWS_*/AZURE_* variables — so the scheme selects which
|
|
57
|
+
// credential we hand to connect below.
|
|
58
|
+
const isHosted = /^https?:\/\//i.test(uri);
|
|
59
|
+
// For an embedded catalog, infino reads no credentials from the environment, so
|
|
60
|
+
// gather the standard provider variables here and hand them to connect as
|
|
61
|
+
// storageOptions, keyed by object_store's aws_*/azure_* config strings. Leaving
|
|
62
|
+
// them all unset falls back to ambient cloud identity (an IAM instance role or
|
|
63
|
+
// Azure managed identity). These are ignored for a hosted connection.
|
|
53
64
|
const storageOptions = {};
|
|
54
65
|
const addStorageOption = (key, value) => {
|
|
55
66
|
if (value)
|
|
@@ -74,12 +85,33 @@ if (s3Endpoint) {
|
|
|
74
85
|
// Azure Blob.
|
|
75
86
|
addStorageOption("azure_storage_account_name", process.env.AZURE_STORAGE_ACCOUNT);
|
|
76
87
|
addStorageOption("azure_storage_account_key", process.env.AZURE_STORAGE_KEY);
|
|
88
|
+
// API key for a hosted (https://) connection. The binding also reads
|
|
89
|
+
// INFINO_API_KEY on its own, but we pass it explicitly so the credential path
|
|
90
|
+
// is visible here and we can warn on an obvious misconfiguration.
|
|
91
|
+
const apiKey = process.env.INFINO_API_KEY;
|
|
77
92
|
// Opt into a connect-time probe so bad credentials or an unreachable bucket
|
|
78
93
|
// fail at startup instead of on the first search.
|
|
79
94
|
const validate = ["1", "true", "yes"].includes((process.env.INFINO_MCP_VALIDATE ?? "").toLowerCase());
|
|
80
95
|
const connectOptions = {};
|
|
81
|
-
if (
|
|
82
|
-
|
|
96
|
+
if (isHosted) {
|
|
97
|
+
// Hosted (Infino Cloud): authenticate with the API key; the platform owns the
|
|
98
|
+
// storage, so the object-store credentials don't apply.
|
|
99
|
+
if (apiKey) {
|
|
100
|
+
connectOptions.apiKey = apiKey;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
console.error("INFINO_MCP_URI is a hosted https:// endpoint but INFINO_API_KEY is not " +
|
|
104
|
+
"set — requests will likely be rejected with an authentication error.");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
if (Object.keys(storageOptions).length > 0)
|
|
109
|
+
connectOptions.storageOptions = storageOptions;
|
|
110
|
+
if (apiKey) {
|
|
111
|
+
console.error("INFINO_API_KEY is set but INFINO_MCP_URI is not a hosted https:// " +
|
|
112
|
+
"endpoint — the key is ignored for local and object-storage connections.");
|
|
113
|
+
}
|
|
114
|
+
}
|
|
83
115
|
if (validate)
|
|
84
116
|
connectOptions.validate = true;
|
|
85
117
|
let db;
|
|
@@ -97,6 +129,41 @@ const writesEnabled = ["1", "true", "yes"].includes((process.env.INFINO_MCP_ENAB
|
|
|
97
129
|
// `_id` comes back as a bigint, which JSON can't serialize — render it as a string.
|
|
98
130
|
const toText = (value) => JSON.stringify(value, (_k, v) => (typeof v === "bigint" ? v.toString() : v), 2);
|
|
99
131
|
const ok = (value) => ({ content: [{ type: "text", text: toText(value) }] });
|
|
132
|
+
// Wall-clock of a synchronous engine call, so results can carry the true engine
|
|
133
|
+
// time (`took_ms`) — this excludes query embedding and the MCP/stdio transport,
|
|
134
|
+
// which the client can't isolate from its own round-trip timing.
|
|
135
|
+
function timed(fn) {
|
|
136
|
+
const t0 = performance.now();
|
|
137
|
+
const value = fn();
|
|
138
|
+
return { value, tookMs: Math.round((performance.now() - t0) * 1000) / 1000 };
|
|
139
|
+
}
|
|
140
|
+
const PLACEHOLDER = /\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g;
|
|
141
|
+
// Substitute `{{name}}` placeholders in a SQL string with a query vector: embed
|
|
142
|
+
// each `embeds[name]` text with the server's embedder and inline it as a
|
|
143
|
+
// comma-separated float literal. This is what lets the vector_search /
|
|
144
|
+
// hybrid_search TVFs run from SQL (the engine itself never embeds). The
|
|
145
|
+
// injected values are model-generated floats, so there's no injection surface;
|
|
146
|
+
// a referenced placeholder with no supplied text is a hard error.
|
|
147
|
+
async function applyEmbeds(sql, embeds) {
|
|
148
|
+
const referenced = new Set();
|
|
149
|
+
for (const m of sql.matchAll(PLACEHOLDER))
|
|
150
|
+
referenced.add(m[1]);
|
|
151
|
+
if (referenced.size === 0)
|
|
152
|
+
return sql;
|
|
153
|
+
if (!embeds) {
|
|
154
|
+
throw new Error(`query has placeholder(s) {{${[...referenced].join("}}, {{")}}} but no 'embed' map was provided`);
|
|
155
|
+
}
|
|
156
|
+
const literals = new Map();
|
|
157
|
+
for (const name of referenced) {
|
|
158
|
+
const text = embeds[name];
|
|
159
|
+
if (typeof text !== "string" || text.length === 0) {
|
|
160
|
+
throw new Error(`no 'embed' text supplied for placeholder {{${name}}}`);
|
|
161
|
+
}
|
|
162
|
+
const vec = await embed(text);
|
|
163
|
+
literals.set(name, `'${Array.from(vec).join(",")}'`);
|
|
164
|
+
}
|
|
165
|
+
return sql.replace(PLACEHOLDER, (full, name) => literals.get(name) ?? full);
|
|
166
|
+
}
|
|
100
167
|
const fail = (message) => ({
|
|
101
168
|
content: [{ type: "text", text: message }],
|
|
102
169
|
isError: true,
|
|
@@ -123,31 +190,18 @@ async function embedRows(handle, rows) {
|
|
|
123
190
|
}
|
|
124
191
|
// Search table functions are routed to the dedicated search tools instead of
|
|
125
192
|
// infino_sql. This is now a usability policy, not a technical limit: search
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
//
|
|
133
|
-
//
|
|
134
|
-
// do work through query_sql now, but the typed retrieval tools are the
|
|
135
|
-
// intended interface (they handle embedding and projection), so free-form
|
|
136
|
-
// SQL is kept to filters/joins/aggregates and retrieval goes through them.
|
|
137
|
-
// - The read-only restriction (single statement, must start with SELECT/WITH)
|
|
138
|
-
// is policy, gated by the same INFINO_MCP_ENABLE_WRITES switch as
|
|
139
|
-
// infino_add_documents. Off → read-only only, so the default install can't
|
|
140
|
-
// write through SQL. On → any single statement (DDL/DML) is allowed, which
|
|
141
|
-
// makes the binding's querySql fully reachable.
|
|
193
|
+
// Guard for infino_sql. The engine's search TVFs (bm25_search / vector_search /
|
|
194
|
+
// hybrid_search / token_match / exact_match) ARE allowed here — they compose
|
|
195
|
+
// with GROUP BY / joins / aggregates, which is the point of exposing SQL. The
|
|
196
|
+
// vector TVFs need a query vector, which applyEmbeds() supplies from {{name}}
|
|
197
|
+
// placeholders. The one restriction is the read-only policy (single statement,
|
|
198
|
+
// must start with SELECT/WITH), gated by the same INFINO_MCP_ENABLE_WRITES
|
|
199
|
+
// switch as infino_add_documents: off → read-only, so the default install can't
|
|
200
|
+
// write through SQL; on → any single statement (DDL/DML) is allowed.
|
|
142
201
|
function guardSql(sql, allowWrites) {
|
|
143
202
|
const stripped = sql.trim().replace(/;\s*$/, "");
|
|
144
203
|
if (stripped.includes(";"))
|
|
145
204
|
throw new Error("only a single statement is allowed");
|
|
146
|
-
const tvf = SEARCH_TVFS.find((fn) => new RegExp(`\\b${fn}\\s*\\(`, "i").test(stripped));
|
|
147
|
-
if (tvf) {
|
|
148
|
-
throw new Error(`${tvf}() isn't available through infino_sql — use the dedicated retrieval tools (infino_keyword_search, ` +
|
|
149
|
-
`infino_semantic_search, infino_hybrid_search) instead. infino_sql is for filters, joins, and aggregates over your tables.`);
|
|
150
|
-
}
|
|
151
205
|
if (!allowWrites && !/^(select|with)\b/i.test(stripped)) {
|
|
152
206
|
throw new Error("only read-only SELECT / WITH queries are allowed (set INFINO_MCP_ENABLE_WRITES to permit DDL/DML through SQL)");
|
|
153
207
|
}
|
|
@@ -251,8 +305,8 @@ server.registerTool("infino_semantic_search", {
|
|
|
251
305
|
const textCol = column ?? inferTextColumn(handle);
|
|
252
306
|
const vector = await embed(query);
|
|
253
307
|
const projection = searchProjection(columns, textCol);
|
|
254
|
-
const results = handle.vectorSearch(vecCol, vector, k, { projection, filter });
|
|
255
|
-
return ok({ table, query, results });
|
|
308
|
+
const { value: results, tookMs } = timed(() => handle.vectorSearch(vecCol, vector, k, { projection, filter }));
|
|
309
|
+
return ok({ table, query, results, took_ms: tookMs });
|
|
256
310
|
}
|
|
257
311
|
catch (err) {
|
|
258
312
|
return fail(`semantic_search failed: ${err.message}`);
|
|
@@ -285,8 +339,8 @@ server.registerTool("infino_keyword_search", {
|
|
|
285
339
|
if (!col) {
|
|
286
340
|
return fail(`keyword_search: no text column found in '${table}' — pass 'column' explicitly.`);
|
|
287
341
|
}
|
|
288
|
-
const results = handle.bm25Search(col, query, k, { projection: searchProjection(columns, col) });
|
|
289
|
-
return ok({ table, column: col, query, results });
|
|
342
|
+
const { value: results, tookMs } = timed(() => handle.bm25Search(col, query, k, { projection: searchProjection(columns, col) }));
|
|
343
|
+
return ok({ table, column: col, query, results, took_ms: tookMs });
|
|
290
344
|
}
|
|
291
345
|
catch (err) {
|
|
292
346
|
return fail(`keyword_search failed: ${err.message}`);
|
|
@@ -319,10 +373,10 @@ server.registerTool("infino_hybrid_search", {
|
|
|
319
373
|
if (!vecCol)
|
|
320
374
|
return fail(`hybrid_search: no vector column in '${table}' — pass 'vectorColumn'.`);
|
|
321
375
|
const vector = await embed(query);
|
|
322
|
-
const results = handle.hybridSearch(textCol, query, vecCol, vector, k, {
|
|
376
|
+
const { value: results, tookMs } = timed(() => handle.hybridSearch(textCol, query, vecCol, vector, k, {
|
|
323
377
|
projection: searchProjection(columns, textCol),
|
|
324
|
-
});
|
|
325
|
-
return ok({ table, query, results });
|
|
378
|
+
}));
|
|
379
|
+
return ok({ table, query, results, took_ms: tookMs });
|
|
326
380
|
}
|
|
327
381
|
catch (err) {
|
|
328
382
|
return fail(`hybrid_search failed: ${err.message}`);
|
|
@@ -355,8 +409,8 @@ server.registerTool("infino_token_match", {
|
|
|
355
409
|
const col = column ?? inferTextColumn(handle);
|
|
356
410
|
if (!col)
|
|
357
411
|
return fail(`token_match: no text column in '${table}' — pass 'column'.`);
|
|
358
|
-
const rows = handle.tokenMatch(col, query, { mode, projection: [col, "_id"] });
|
|
359
|
-
return ok({ table, column: col, query, matched: rows.length, results: rows.slice(0, limit) });
|
|
412
|
+
const { value: rows, tookMs } = timed(() => handle.tokenMatch(col, query, { mode, projection: [col, "_id"] }));
|
|
413
|
+
return ok({ table, column: col, query, matched: rows.length, results: rows.slice(0, limit), took_ms: tookMs });
|
|
360
414
|
}
|
|
361
415
|
catch (err) {
|
|
362
416
|
return fail(`token_match failed: ${err.message}`);
|
|
@@ -385,8 +439,8 @@ server.registerTool("infino_exact_match", {
|
|
|
385
439
|
const col = column ?? inferTextColumn(handle);
|
|
386
440
|
if (!col)
|
|
387
441
|
return fail(`exact_match: no column found in '${table}' — pass 'column'.`);
|
|
388
|
-
const rows = handle.exactMatch(col, value, { projection: [col, "_id"] });
|
|
389
|
-
return ok({ table, column: col, value, matched: rows.length, results: rows.slice(0, limit) });
|
|
442
|
+
const { value: rows, tookMs } = timed(() => handle.exactMatch(col, value, { projection: [col, "_id"] }));
|
|
443
|
+
return ok({ table, column: col, value, matched: rows.length, results: rows.slice(0, limit), took_ms: tookMs });
|
|
390
444
|
}
|
|
391
445
|
catch (err) {
|
|
392
446
|
return fail(`exact_match failed: ${err.message}`);
|
|
@@ -416,8 +470,8 @@ server.registerTool("infino_count", {
|
|
|
416
470
|
if (!col) {
|
|
417
471
|
return fail(`count: no text column found in '${table}' — pass 'column' explicitly.`);
|
|
418
472
|
}
|
|
419
|
-
const count = handle.count(col, query, { mode });
|
|
420
|
-
return ok({ table, column: col, query, count });
|
|
473
|
+
const { value: count, tookMs } = timed(() => handle.count(col, query, { mode }));
|
|
474
|
+
return ok({ table, column: col, query, count, took_ms: tookMs });
|
|
421
475
|
}
|
|
422
476
|
catch (err) {
|
|
423
477
|
return fail(`count failed: ${err.message}`);
|
|
@@ -425,21 +479,35 @@ server.registerTool("infino_count", {
|
|
|
425
479
|
});
|
|
426
480
|
server.registerTool("infino_sql", {
|
|
427
481
|
title: "SQL over Infino",
|
|
428
|
-
description: "Use for structural or analytical questions — counts, GROUP BY, joins, aggregates, filtering by
|
|
429
|
-
"
|
|
430
|
-
"
|
|
431
|
-
"
|
|
482
|
+
description: "Use for structural or analytical questions — counts, GROUP BY, joins, aggregates, filtering by column value — " +
|
|
483
|
+
"returning result rows. The engine's search functions are callable as table-valued relations, so a single query " +
|
|
484
|
+
"can rank AND aggregate: bm25_search('table','text_col','terms', k) — also bm25_search_prefix / token_match / " +
|
|
485
|
+
"exact_match — need no embedding. vector_search('table','vec_col', {{q}}, k) and " +
|
|
486
|
+
"hybrid_search('table','text_col','terms','vec_col', {{q}}, k) need a query vector: put a {{name}} placeholder " +
|
|
487
|
+
"where the vector goes and pass embed:{\"name\":\"query text\"} — the server embeds the text and substitutes the " +
|
|
488
|
+
"vector in. Example: SELECT path, SUM(end_line - start_line + 1) AS lines FROM " +
|
|
489
|
+
"bm25_search('docs','body','error timeout', 300) GROUP BY path ORDER BY lines DESC. " +
|
|
432
490
|
(writesEnabled
|
|
433
491
|
? "Any single statement is allowed (including DDL/DML), since INFINO_MCP_ENABLE_WRITES is set."
|
|
434
492
|
: "Read-only: a single SELECT / WITH statement; DDL/DML is rejected."),
|
|
435
493
|
inputSchema: {
|
|
436
494
|
query: writesEnabled
|
|
437
|
-
? z.string().describe("A single SQL statement.")
|
|
438
|
-
: z
|
|
495
|
+
? z.string().describe("A single SQL statement. May use search TVFs and {{name}} vector placeholders.")
|
|
496
|
+
: z
|
|
497
|
+
.string()
|
|
498
|
+
.describe("A single read-only SELECT or WITH statement. May use search TVFs and {{name}} vector placeholders."),
|
|
499
|
+
embed: z
|
|
500
|
+
.record(z.string())
|
|
501
|
+
.optional()
|
|
502
|
+
.describe("Map of placeholder name -> query text. Each text is embedded with the server's embedder and its vector " +
|
|
503
|
+
"is substituted for every {{name}} in the query — required to use vector_search / hybrid_search. " +
|
|
504
|
+
'E.g. {"q":"error timeout"} fills {{q}}.'),
|
|
439
505
|
},
|
|
440
|
-
}, async ({ query }) => {
|
|
506
|
+
}, async ({ query, embed: embeds }) => {
|
|
441
507
|
try {
|
|
442
|
-
|
|
508
|
+
const sql = await applyEmbeds(query, embeds);
|
|
509
|
+
const { value: rows, tookMs } = timed(() => db.querySql(guardSql(sql, writesEnabled)));
|
|
510
|
+
return ok({ rows, took_ms: tookMs });
|
|
443
511
|
}
|
|
444
512
|
catch (err) {
|
|
445
513
|
return fail(`sql failed: ${err.message}`);
|
|
@@ -523,4 +591,5 @@ if (writesEnabled) {
|
|
|
523
591
|
// stderr so they never corrupt the JSON-RPC stream on stdout.
|
|
524
592
|
const transport = new StdioServerTransport();
|
|
525
593
|
await server.connect(transport);
|
|
526
|
-
console.error(`infino MCP server ready on stdio (uri: ${uri},
|
|
594
|
+
console.error(`infino MCP server ready on stdio (uri: ${uri}, mode: ${isHosted ? "hosted" : "embedded"}, ` +
|
|
595
|
+
`writes: ${writesEnabled ? "on" : "off"}, embedder: ${embedderInfo()})`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infino-ai/mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.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,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@huggingface/transformers": "^4.2.0",
|
|
52
|
-
"@infino-ai/infino": "^0.
|
|
52
|
+
"@infino-ai/infino": "^0.3.0",
|
|
53
53
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
54
54
|
"zod": "^3.23.0"
|
|
55
55
|
},
|