@infino-ai/mcp-server 0.1.1 → 0.2.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 +16 -11
- package/dist/index.js +98 -44
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ An [MCP](https://modelcontextprotocol.io) server for [Infino](https://github.com
|
|
|
8
8
|
|
|
9
9
|
- **No API 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
|
-
- **Bring your own storage.** Point it at a local path or your own bucket (S3,
|
|
11
|
+
- **Bring your own storage.** Point it at a local path or your own bucket (S3, Azure, or any S3-compatible store).
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -46,7 +46,7 @@ An [MCP](https://modelcontextprotocol.io) server for [Infino](https://github.com
|
|
|
46
46
|
|
|
47
47
|
## Quick start
|
|
48
48
|
|
|
49
|
-
The server is launched by your MCP client over stdio — you don't run it directly in normal use. Every client config follows the same shape: command `npx -y @infino-ai/mcp-server`, with configuration supplied via environment variables. Set `INFINO_MCP_URI` to the data you want to serve — a local path or a bucket URI. If it's omitted, the server
|
|
49
|
+
The server is launched by your MCP client over stdio — you don't run it directly in normal use. Every client config follows the same shape: command `npx -y @infino-ai/mcp-server`, with configuration supplied via environment variables. Set `INFINO_MCP_URI` to the data you want to serve — a local path or a bucket URI. If it's omitted, the server uses a durable per-user directory (`~/.infino/mcp`) so data persists across restarts; point `INFINO_MCP_URI` at your own path or bucket to serve existing data.
|
|
50
50
|
|
|
51
51
|
```jsonc
|
|
52
52
|
{
|
|
@@ -178,19 +178,17 @@ All configuration is via environment variables — there are no config files and
|
|
|
178
178
|
|
|
179
179
|
| Variable | Required | Default | Description |
|
|
180
180
|
| --- | --- | --- | --- |
|
|
181
|
-
| `INFINO_MCP_URI` | No | `
|
|
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_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). |
|
|
184
|
-
| `
|
|
185
|
-
| `INFINO_MCP_S3_REGION` | No | `auto` | Region to send with a custom S3 endpoint. |
|
|
184
|
+
| `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. |
|
|
186
185
|
|
|
187
|
-
Cloud credentials are read from the standard provider environment variables — the server
|
|
186
|
+
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).
|
|
188
187
|
|
|
189
188
|
| Backend | Credentials |
|
|
190
189
|
| --- | --- |
|
|
191
|
-
| AWS S3 | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` (+ `AWS_SESSION_TOKEN` if used) |
|
|
192
|
-
| S3-compatible (R2/MinIO/B2) | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` **and** `
|
|
193
|
-
| Google Cloud Storage | `GOOGLE_APPLICATION_CREDENTIALS` (or ambient ADC) |
|
|
190
|
+
| AWS S3 | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` (+ `AWS_SESSION_TOKEN`, `AWS_REGION` if used) |
|
|
191
|
+
| S3-compatible (R2/MinIO/B2) | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` **and** `AWS_ENDPOINT_URL` |
|
|
194
192
|
| Azure Blob | `AZURE_STORAGE_ACCOUNT`, `AZURE_STORAGE_KEY` |
|
|
195
193
|
|
|
196
194
|
### Storage backends
|
|
@@ -209,11 +207,17 @@ Cloud credentials are read from the standard provider environment variables —
|
|
|
209
207
|
// S3-compatible (Cloudflare R2 / MinIO / Backblaze B2) — custom endpoint
|
|
210
208
|
"env": {
|
|
211
209
|
"INFINO_MCP_URI": "s3://my-bucket/infino",
|
|
212
|
-
"
|
|
213
|
-
"INFINO_MCP_S3_REGION": "auto",
|
|
210
|
+
"AWS_ENDPOINT_URL": "https://<account>.r2.cloudflarestorage.com",
|
|
214
211
|
"AWS_ACCESS_KEY_ID": "…",
|
|
215
212
|
"AWS_SECRET_ACCESS_KEY": "…"
|
|
216
213
|
}
|
|
214
|
+
|
|
215
|
+
// Azure Blob
|
|
216
|
+
"env": {
|
|
217
|
+
"INFINO_MCP_URI": "az://my-container/infino",
|
|
218
|
+
"AZURE_STORAGE_ACCOUNT": "…",
|
|
219
|
+
"AZURE_STORAGE_KEY": "…"
|
|
220
|
+
}
|
|
217
221
|
```
|
|
218
222
|
|
|
219
223
|
---
|
|
@@ -227,6 +231,7 @@ Cloud credentials are read from the standard provider environment variables —
|
|
|
227
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. |
|
|
228
232
|
| `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. |
|
|
229
233
|
| `infino_exact_match` | `table`, `value`, `column?`, `limit?` | Unranked exact-equality filter over an indexed column (tag, status, id string). |
|
|
234
|
+
| `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`. |
|
|
230
235
|
| `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. |
|
|
231
236
|
| `infino_list_tables` | — | List the tables in the connected catalog. |
|
|
232
237
|
| `infino_describe_table` | `table` | Column names and types for a table. |
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
// keyword (BM25), semantic (local-embedding vector), and hybrid (fused)
|
|
8
8
|
// search, unranked token/exact match, and read-only SQL; document writes
|
|
9
9
|
// (add/update/delete) and full SQL are opt-in behind INFINO_MCP_ENABLE_WRITES.
|
|
10
|
+
import { mkdirSync } from "node:fs";
|
|
11
|
+
import { homedir } from "node:os";
|
|
12
|
+
import { join } from "node:path";
|
|
10
13
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
11
14
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
12
15
|
import { z } from "zod";
|
|
@@ -15,39 +18,70 @@ import { embed, embedderInfo } from "./embedding.js";
|
|
|
15
18
|
// --- connection (env-configured, opened once at startup) -------------------
|
|
16
19
|
//
|
|
17
20
|
// The agent never manages connections: the server is pointed at the data via
|
|
18
|
-
// INFINO_MCP_URI (a local path, or the user's own s3://|
|
|
19
|
-
//
|
|
20
|
-
// S3-compatible store (Cloudflare R2,
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
// INFINO_MCP_URI (a local path, or the user's own s3://|az:// bucket).
|
|
22
|
+
// Credentials come from the standard AWS_*/AZURE_* environment variables. AWS
|
|
23
|
+
// S3 uses the default endpoint; for any S3-compatible store (Cloudflare R2,
|
|
24
|
+
// MinIO, Backblaze B2, …) set AWS_ENDPOINT_URL alongside the AWS_* keys.
|
|
25
|
+
// When INFINO_MCP_URI is unset, default to a durable per-user directory so a
|
|
26
|
+
// fresh install persists across restarts with no configuration. Fall back to
|
|
27
|
+
// an ephemeral in-process catalog if that directory can't be created (a
|
|
28
|
+
// sandboxed or read-only host, or a registry health-check spawn): the server
|
|
29
|
+
// must always start — a hard exit would leave it permanently "unhealthy".
|
|
30
|
+
// Real deployments set INFINO_MCP_URI to their own path or an s3://|az:// URI.
|
|
31
|
+
function defaultUri() {
|
|
32
|
+
const dir = join(homedir(), ".infino", "mcp");
|
|
33
|
+
try {
|
|
34
|
+
mkdirSync(dir, { recursive: true });
|
|
35
|
+
console.error(`INFINO_MCP_URI not set — using ${dir} (persistent; read-only until ` +
|
|
36
|
+
"INFINO_MCP_ENABLE_WRITES is set). Set INFINO_MCP_URI to point at your " +
|
|
37
|
+
"own path or an s3://|az:// bucket.");
|
|
38
|
+
return dir;
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
console.error(`INFINO_MCP_URI not set and ${dir} is not writable ` +
|
|
42
|
+
`(${err.message}) — serving an ephemeral in-process ` +
|
|
43
|
+
"catalog (memory://).");
|
|
44
|
+
return "memory://";
|
|
45
|
+
}
|
|
32
46
|
}
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
47
|
+
const uri = process.env.INFINO_MCP_URI ?? defaultUri();
|
|
48
|
+
// infino reads no credentials from the environment, so gather the standard
|
|
49
|
+
// provider variables here and hand them to connect as storageOptions, keyed
|
|
50
|
+
// by object_store's aws_*/azure_* config strings. Leaving them all unset
|
|
51
|
+
// falls back to ambient cloud identity (an IAM instance role or Azure managed
|
|
52
|
+
// identity).
|
|
53
|
+
const storageOptions = {};
|
|
54
|
+
const addStorageOption = (key, value) => {
|
|
55
|
+
if (value)
|
|
56
|
+
storageOptions[key] = value;
|
|
57
|
+
};
|
|
58
|
+
// S3, and S3-compatible stores (Cloudflare R2 / MinIO / Backblaze B2) via a
|
|
59
|
+
// custom endpoint.
|
|
60
|
+
addStorageOption("aws_access_key_id", process.env.AWS_ACCESS_KEY_ID);
|
|
61
|
+
addStorageOption("aws_secret_access_key", process.env.AWS_SECRET_ACCESS_KEY);
|
|
62
|
+
addStorageOption("aws_session_token", process.env.AWS_SESSION_TOKEN);
|
|
63
|
+
addStorageOption("aws_region", process.env.AWS_REGION);
|
|
64
|
+
const s3Endpoint = process.env.AWS_ENDPOINT_URL;
|
|
37
65
|
if (s3Endpoint) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (!
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
endpoint: s3Endpoint,
|
|
46
|
-
region: process.env.INFINO_MCP_S3_REGION ?? "auto",
|
|
47
|
-
accessKey,
|
|
48
|
-
secretKey,
|
|
49
|
-
};
|
|
66
|
+
storageOptions.aws_endpoint = s3Endpoint;
|
|
67
|
+
// A custom endpoint needs a region; default to "auto" (what R2 expects).
|
|
68
|
+
if (!storageOptions.aws_region)
|
|
69
|
+
storageOptions.aws_region = "auto";
|
|
70
|
+
// object_store rejects a plain-HTTP endpoint unless HTTP is allowed.
|
|
71
|
+
if (s3Endpoint.startsWith("http://"))
|
|
72
|
+
storageOptions.aws_allow_http = "true";
|
|
50
73
|
}
|
|
74
|
+
// Azure Blob.
|
|
75
|
+
addStorageOption("azure_storage_account_name", process.env.AZURE_STORAGE_ACCOUNT);
|
|
76
|
+
addStorageOption("azure_storage_account_key", process.env.AZURE_STORAGE_KEY);
|
|
77
|
+
// Opt into a connect-time probe so bad credentials or an unreachable bucket
|
|
78
|
+
// fail at startup instead of on the first search.
|
|
79
|
+
const validate = ["1", "true", "yes"].includes((process.env.INFINO_MCP_VALIDATE ?? "").toLowerCase());
|
|
80
|
+
const connectOptions = {};
|
|
81
|
+
if (Object.keys(storageOptions).length > 0)
|
|
82
|
+
connectOptions.storageOptions = storageOptions;
|
|
83
|
+
if (validate)
|
|
84
|
+
connectOptions.validate = true;
|
|
51
85
|
let db;
|
|
52
86
|
try {
|
|
53
87
|
db = connect(uri, connectOptions);
|
|
@@ -67,12 +101,6 @@ const fail = (message) => ({
|
|
|
67
101
|
content: [{ type: "text", text: message }],
|
|
68
102
|
isError: true,
|
|
69
103
|
});
|
|
70
|
-
// SQL literal / identifier quoting. The hybrid_search tool builds SQL from
|
|
71
|
-
// caller-supplied table/column names and query text, so every interpolated
|
|
72
|
-
// value is escaped: string args become single-quoted literals, column names
|
|
73
|
-
// become double-quoted identifiers.
|
|
74
|
-
const sqlStr = (s) => `'${s.replace(/'/g, "''")}'`;
|
|
75
|
-
const sqlIdent = (s) => `"${s.replace(/"/g, '""')}"`;
|
|
76
104
|
// When the caller doesn't name a column, search the first UTF-8 text column in
|
|
77
105
|
// the table's schema. (A table can have several; an explicit `column` overrides.)
|
|
78
106
|
function inferTextColumn(table) {
|
|
@@ -270,14 +298,9 @@ server.registerTool("infino_hybrid_search", {
|
|
|
270
298
|
if (!vecCol)
|
|
271
299
|
return fail(`hybrid_search: no vector column in '${table}' — pass 'vectorColumn'.`);
|
|
272
300
|
const vector = await embed(query);
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const cols = [sqlIdent(textCol), "_id", "score"].join(", ");
|
|
277
|
-
const sql = `SELECT ${cols} FROM hybrid_search(` +
|
|
278
|
-
`${sqlStr(table)}, ${sqlStr(textCol)}, ${sqlStr(query)}, ` +
|
|
279
|
-
`${sqlStr(vecCol)}, ${sqlStr(vector.join(","))}, ${k})`;
|
|
280
|
-
const results = db.querySql(sql);
|
|
301
|
+
const results = handle.hybridSearch(textCol, query, vecCol, vector, k, {
|
|
302
|
+
projection: [textCol, "_id", "score"],
|
|
303
|
+
});
|
|
281
304
|
return ok({ table, query, results });
|
|
282
305
|
}
|
|
283
306
|
catch (err) {
|
|
@@ -348,6 +371,37 @@ server.registerTool("infino_exact_match", {
|
|
|
348
371
|
return fail(`exact_match failed: ${err.message}`);
|
|
349
372
|
}
|
|
350
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
|
+
});
|
|
351
405
|
server.registerTool("infino_sql", {
|
|
352
406
|
title: "SQL over Infino",
|
|
353
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.2.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.0",
|
|
54
54
|
"zod": "^3.23.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|