@infino-ai/mcp-server 0.19.0 → 0.21.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
@@ -80,14 +80,14 @@ The sections below show the exact place each client expects this block.
80
80
 
81
81
  ## Claude Code plugin (one-step install)
82
82
 
83
- For [Claude Code](https://claude.com/claude-code), this repo is also a plugin marketplace. Installing the plugin wires up the MCP server **plus** a how-to-use skill and an `/infino-search` command in one step — no JSON to edit. Inside Claude Code:
83
+ For [Claude Code](https://claude.com/claude-code), this repo is also a plugin marketplace. Installing the plugin wires up the MCP server **plus** two skills and an `/infino-search` command in one step, with no JSON to edit. Inside Claude Code:
84
84
 
85
85
  ```
86
86
  /plugin marketplace add infino-ai/infino-mcp
87
87
  /plugin install infino@infino-ai
88
88
  ```
89
89
 
90
- On enable you'll be prompted for your **Infino data URI** (`INFINO_MCP_URI`) and, for Infino Cloud, your **API key**. That's it: the `infino_*` tools, the `using-infino` skill, and `/infino-search <query>` are then available. (Other clients: use the [Client setup](#client-setup) configs below.)
90
+ On enable you'll be asked for an **Infino data URI** (`INFINO_MCP_URI`) and, for Infino Cloud, an **API key**. Both are optional: leave the URI blank to keep data in `~/.infino/mcp`. You then have the `infino_*` tools, the `using-infino` skill (how to call those tools), the `search-with-infino` skill (how to add Infino search to your own Python, Node.js or Rust code), and `/infino-search <query>`. (Other clients: use the [Client setup](#client-setup) configs below.)
91
91
 
92
92
  ---
93
93
 
@@ -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_ASK` | No | _off_ | When set (`1`/`true`/`yes`), offers `infino_ask` on an Infino Cloud account with the agent tools on. Each ask runs a model loop billed to the account. |
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
 
@@ -303,13 +304,13 @@ On an account with the agent tools on, a statement that joins tables is also hel
303
304
 
304
305
  ### Agent tools (Infino Cloud)
305
306
 
306
- On a hosted connection, the server asks Infino Cloud once at startup whether the account has the agent tools switched on (`GET /v1/account/features`). When it does, three more tools appear; otherwise, and on every local or bucket connection, they are not offered at all.
307
+ On a hosted connection, the server asks Infino Cloud once at startup whether the account has the agent tools switched on (`GET /v1/account/features`). When it does, `infino_describe_columns` and `infino_join_keys` appear, and `infino_ask` too when `INFINO_MCP_ASK` is set; otherwise, and on every local or bucket connection, they are not offered at all.
307
308
 
308
309
  | Tool | Arguments | What it does |
309
310
  | --- | --- | --- |
310
311
  | `infino_describe_columns` | `table`, `pattern`, `limit?` | A table's column entries from the card Infino Cloud computed from the table itself: type, index role, rows with a value, distinct count, range and most frequent values. `pattern` is a column name or a `*` pattern (`property_*`, `*monthly*`). For wide tables, call it before a statement names a column. |
311
312
  | `infino_join_keys` | `tables` (2 to 8) | The keys the tables join on, found on their values rather than by column name, each with its `predicate`, the `ON` clause to paste into `infino_sql`. |
312
- | `infino_ask` | `question`, `table?`, `tables?`, `k?`, `context?`, `maxWallSecs?` | A plain-language question answered by a retrieval agent on Infino Cloud, which runs the searches and SQL itself and returns the rows it found (`facts`), the statement whose rows answer the question (`statement`) and `coverage`, never a summary. Each ask runs a model loop billed to the account and takes seconds to a few minutes; when you already know the statement, use `infino_sql`. |
313
+ | `infino_ask` (with `INFINO_MCP_ASK`) | `question`, `table?`, `tables?`, `k?`, `context?`, `maxWallSecs?` | A plain-language question answered by a retrieval agent on Infino Cloud, which runs the searches and SQL itself and returns the rows it found (`facts`), the statement whose rows answer the question (`statement`) and `coverage`, never a summary. Each ask runs a model loop billed to the account and takes seconds to a few minutes; when you already know the statement, use `infino_sql`. |
313
314
 
314
315
  ### Writing data
315
316
 
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ import { joinGate, joinRefusal, withoutComments } from "./join-gate.js";
47
47
  // R2, MinIO, Backblaze B2 — set AWS_ENDPOINT_URL alongside the AWS_* keys);
48
48
  // - an https://<host>/<database> URI → the hosted Infino Cloud service,
49
49
  // authenticated with an API key (INFINO_API_KEY).
50
- // When INFINO_MCP_URI is unset, default to a durable per-user directory so a
50
+ // When INFINO_MCP_URI is unset or blank, default to a durable per-user directory so a
51
51
  // fresh install persists across restarts with no configuration. Fall back to
52
52
  // an ephemeral in-process catalog if that directory can't be created (a
53
53
  // sandboxed or read-only host, or a registry health-check spawn): the server
@@ -69,7 +69,11 @@ function defaultUri() {
69
69
  return "memory://";
70
70
  }
71
71
  }
72
- const uri = process.env.INFINO_MCP_URI ?? defaultUri();
72
+ // A blank value counts as unset. Clients that template the environment from
73
+ // optional settings, such as the Claude Code plugin's userConfig, pass an empty
74
+ // string when the user leaves the field blank, and that has to mean "use the
75
+ // default", not "open a catalog at the empty path".
76
+ const uri = process.env.INFINO_MCP_URI?.trim() || defaultUri();
73
77
  // A hosted (Infino Cloud) target is an https:// URI that carries the database
74
78
  // in its path (https://<host>/<database>); any other scheme is an embedded
75
79
  // catalog on a local path or an object-storage bucket. The two authenticate
@@ -109,10 +113,13 @@ addStorageOption("azure_storage_account_key", process.env.AZURE_STORAGE_KEY);
109
113
  // API key for a hosted (https://) connection. The binding also reads
110
114
  // INFINO_API_KEY on its own, but we pass it explicitly so the credential path
111
115
  // is visible here and we can warn on an obvious misconfiguration.
112
- const apiKey = process.env.INFINO_API_KEY;
116
+ const apiKey = process.env.INFINO_API_KEY?.trim() || undefined;
113
117
  // Opt into a connect-time probe so bad credentials or an unreachable bucket
114
118
  // fail at startup instead of on the first search.
115
119
  const validate = ["1", "true", "yes"].includes((process.env.INFINO_MCP_VALIDATE ?? "").toLowerCase());
120
+ // infino_ask runs a model loop billed to the account, so it is offered only
121
+ // when asked for, and only on an account with the agent tools on.
122
+ const askTool = ["1", "true", "yes"].includes((process.env.INFINO_MCP_ASK ?? "").toLowerCase());
116
123
  const connectOptions = {};
117
124
  if (isHosted) {
118
125
  // Hosted (Infino Cloud): authenticate with the API key; the platform owns the
@@ -1027,55 +1034,57 @@ if (agentApi && agentTools) {
1027
1034
  return fail(`join_keys failed: ${agentErr(err)}`);
1028
1035
  }
1029
1036
  });
1030
- server.registerTool("infino_ask", {
1031
- title: "Ask a question of the data: one retrieval, the rows back",
1032
- annotations: READ_ONLY,
1033
- description: "Ask a question about this database in plain language. A retrieval agent on Infino Cloud reads the " +
1034
- "tables' cards, chooses and runs the searches and SQL itself (joins included), checks the result " +
1035
- "against the question, and returns the rows it found (`facts`), the statement whose rows answer the " +
1036
- "question (`statement`), and how many rows that statement returned (`coverage`). It never writes a " +
1037
- "summary: read the rows, and reuse `statement` with infino_sql to go further. Use it for any question " +
1038
- "that is not one statement you already know how to write: where a value lives, which column holds a " +
1039
- "name, counts and rankings across tables. Several asks in one reply run at the same time. When the " +
1040
- "database holds several tables and the question is about one or a few, name them in `table` or " +
1041
- "`tables`. Each ask runs a model loop on the service: it takes seconds to a few minutes and its model " +
1042
- "calls are billed to the account, so when you already know the statement, run it with infino_sql " +
1043
- "instead. A loop that found no answer still returns, with `terminate` saying why; if an ask comes back " +
1044
- "thin, rephrase it, narrower or broader, and ask again.",
1045
- inputSchema: {
1046
- question: z
1047
- .string()
1048
- .min(1)
1049
- .describe("The question, about the data, in plain language. Its names, numbers and quoted terms are what " +
1050
- "the result is checked for, so put only the question here."),
1051
- table: z.string().min(1).optional().describe("The one table the question is about."),
1052
- tables: z
1053
- .array(z.string().min(1))
1054
- .min(1)
1055
- .max(8)
1056
- .optional()
1057
- .describe("The few tables the question is about, which the agent may join."),
1058
- k: z.number().int().min(1).max(1000).optional().describe("Rows to return at most (default 10)."),
1059
- context: z
1060
- .string()
1061
- .optional()
1062
- .describe("Anything the agent should know beside the question (a convention, a definition); not checked for."),
1063
- maxWallSecs: z
1064
- .number()
1065
- .int()
1066
- .min(10)
1067
- .max(600)
1068
- .optional()
1069
- .describe("A shorter time budget in seconds than the service's own, for a cheaper, faster ask."),
1070
- },
1071
- }, async (request) => {
1072
- try {
1073
- return ok(await agentApi.ask(request));
1074
- }
1075
- catch (err) {
1076
- return fail(`ask failed: ${agentErr(err)}`);
1077
- }
1078
- });
1037
+ if (askTool) {
1038
+ server.registerTool("infino_ask", {
1039
+ title: "Ask a question of the data: one retrieval, the rows back",
1040
+ annotations: READ_ONLY,
1041
+ description: "Ask a question about this database in plain language. A retrieval agent on Infino Cloud reads the " +
1042
+ "tables' cards, chooses and runs the searches and SQL itself (joins included), checks the result " +
1043
+ "against the question, and returns the rows it found (`facts`), the statement whose rows answer the " +
1044
+ "question (`statement`), and how many rows that statement returned (`coverage`). It never writes a " +
1045
+ "summary: read the rows, and reuse `statement` with infino_sql to go further. Use it for any question " +
1046
+ "that is not one statement you already know how to write: where a value lives, which column holds a " +
1047
+ "name, counts and rankings across tables. Several asks in one reply run at the same time. When the " +
1048
+ "database holds several tables and the question is about one or a few, name them in `table` or " +
1049
+ "`tables`. Each ask runs a model loop on the service: it takes seconds to a few minutes and its model " +
1050
+ "calls are billed to the account, so when you already know the statement, run it with infino_sql " +
1051
+ "instead. A loop that found no answer still returns, with `terminate` saying why; if an ask comes back " +
1052
+ "thin, rephrase it, narrower or broader, and ask again.",
1053
+ inputSchema: {
1054
+ question: z
1055
+ .string()
1056
+ .min(1)
1057
+ .describe("The question, about the data, in plain language. Its names, numbers and quoted terms are what " +
1058
+ "the result is checked for, so put only the question here."),
1059
+ table: z.string().min(1).optional().describe("The one table the question is about."),
1060
+ tables: z
1061
+ .array(z.string().min(1))
1062
+ .min(1)
1063
+ .max(8)
1064
+ .optional()
1065
+ .describe("The few tables the question is about, which the agent may join."),
1066
+ k: z.number().int().min(1).max(1000).optional().describe("Rows to return at most (default 10)."),
1067
+ context: z
1068
+ .string()
1069
+ .optional()
1070
+ .describe("Anything the agent should know beside the question (a convention, a definition); not checked for."),
1071
+ maxWallSecs: z
1072
+ .number()
1073
+ .int()
1074
+ .min(10)
1075
+ .max(600)
1076
+ .optional()
1077
+ .describe("A shorter time budget in seconds than the service's own, for a cheaper, faster ask."),
1078
+ },
1079
+ }, async (request) => {
1080
+ try {
1081
+ return ok(await agentApi.ask(request));
1082
+ }
1083
+ catch (err) {
1084
+ return fail(`ask failed: ${agentErr(err)}`);
1085
+ }
1086
+ });
1087
+ }
1079
1088
  }
1080
1089
  // --- transport -------------------------------------------------------------
1081
1090
  // stdio for desktop/CLI clients (Claude Desktop/Code, Cursor). Logs go to
@@ -1083,4 +1092,5 @@ if (agentApi && agentTools) {
1083
1092
  const transport = new StdioServerTransport();
1084
1093
  await server.connect(transport);
1085
1094
  console.error(`infino MCP server ready on stdio (uri: ${uri}, mode: ${isHosted ? "hosted" : "embedded"}, ` +
1086
- `embedder: ${embedderInfo()}, agent tools: ${agentTools ? "on" : "off"})`);
1095
+ `embedder: ${embedderInfo()}, agent tools: ${agentTools ? "on" : "off"}, ` +
1096
+ `ask: ${agentTools && askTool ? "on" : "off"})`);
package/dist/join-gate.js CHANGED
@@ -130,8 +130,147 @@ export function aliasesOf(query, tables) {
130
130
  aliases.set(alias.toLowerCase(), table);
131
131
  }
132
132
  }
133
+ // A subquery or a CTE over one table stands for that table: its alias,
134
+ // the CTE's name and any alias given the CTE are the table's. A join
135
+ // written between two of them (each table grouped in a subquery, then the
136
+ // two joined on their key) was refused before, its `e.id = c.id` naming no
137
+ // table the check knew. A subquery or CTE over several tables stands for
138
+ // none: the join inside it is held to a key on its own.
139
+ for (const [name, table] of derivedTables(query, tables)) {
140
+ if (!aliases.has(name))
141
+ aliases.set(name, table);
142
+ }
133
143
  return aliases;
134
144
  }
145
+ /** The single known table each subquery alias and CTE name of a statement
146
+ * reads, and each alias given such a CTE (`FROM recent r`). Names in
147
+ * lowercase. */
148
+ function derivedTables(query, tables) {
149
+ const derived = new Map();
150
+ const only = (inner) => {
151
+ const named = tablesNamed(inner, tables);
152
+ return named.length === 1 ? named[0] : null;
153
+ };
154
+ const ctes = new Map();
155
+ for (const m of query.matchAll(CTE_START)) {
156
+ const open = (m.index ?? 0) + m[0].length - 1;
157
+ const inner = query.slice(open + 1, groupEnd(query, open) - 1);
158
+ const table = only(inner);
159
+ if (table)
160
+ ctes.set(m[1].toLowerCase(), { table, inner });
161
+ }
162
+ for (let i = 0; i < query.length; i++) {
163
+ const c = query[i];
164
+ if (c === "'" || c === '"') {
165
+ const close = query.indexOf(c, i + 1);
166
+ i = close < 0 ? query.length : close;
167
+ continue;
168
+ }
169
+ if (c !== "(")
170
+ continue;
171
+ const end = groupEnd(query, i);
172
+ const inner = query.slice(i + 1, end - 1);
173
+ if (!SUBQUERY_START.test(inner))
174
+ continue;
175
+ const alias = /^\s*(?:as\s+)?([A-Za-z_]\w*)/i.exec(query.slice(end))?.[1];
176
+ const table = only(inner);
177
+ if (alias &&
178
+ table &&
179
+ !NOT_AN_ALIAS.has(alias.toLowerCase()) &&
180
+ carriesAsSelected(query, [alias], inner)) {
181
+ derived.set(alias.toLowerCase(), table);
182
+ }
183
+ }
184
+ for (const [cte, { table, inner }] of ctes) {
185
+ const names = [cte];
186
+ const aliased = new RegExp(`(?<![\\w.'"])${escapeRegex(cte)}(?![\\w])\\s+(?:as\\s+)?([A-Za-z_]\\w*)`, "gi");
187
+ for (const m of query.matchAll(aliased)) {
188
+ const alias = m[1].toLowerCase();
189
+ if (!NOT_AN_ALIAS.has(alias) && alias !== cte)
190
+ names.push(alias);
191
+ }
192
+ // The CTE stands for its table under every name only when what the
193
+ // statement compares through those names is the table's own columns.
194
+ if (!carriesAsSelected(query, names, inner))
195
+ continue;
196
+ for (const name of names)
197
+ derived.set(name, table);
198
+ }
199
+ return derived;
200
+ }
201
+ /** Whether every column `query` compares through `names` (`n.col = ...`) is
202
+ * one the subquery or CTE `inner` selects under its own name - `col`,
203
+ * `t.col`, `col AS col` - or `inner` selects `*`. A column renamed inside
204
+ * (`account AS id`) is not the table's column of that name, so a derived
205
+ * name that compares one does not stand for the table: the join written
206
+ * through it is held to a key as a join between unknown sources would be.
207
+ * Columns only selected or sorted on join nothing and are left alone. */
208
+ function carriesAsSelected(query, names, inner) {
209
+ const selected = selectedAsThemselves(inner);
210
+ if (selected === "all")
211
+ return true;
212
+ for (const name of names) {
213
+ const read = new RegExp(`(?<![\\w.'"])"?${escapeRegex(name)}"?\\s*\\.\\s*"?([A-Za-z_]\\w*)"?`, "gi");
214
+ for (const m of query.matchAll(read)) {
215
+ const at = m.index ?? 0;
216
+ const compared = /=\s*$/.test(query.slice(0, at)) || /^\s*=/.test(query.slice(at + m[0].length));
217
+ if (compared && !selected.has(m[1].toLowerCase()))
218
+ return false;
219
+ }
220
+ }
221
+ return true;
222
+ }
223
+ /** The columns a query's top-level select list carries under their own
224
+ * names, lowercase: `col`, `t.col` and `col AS col`, quoted or not; "all"
225
+ * when the list holds `*` or `t.*`. An expression or a renamed column
226
+ * carries nothing. */
227
+ function selectedAsThemselves(inner) {
228
+ const carried = new Set();
229
+ for (const item of topLevelSelectList(inner)) {
230
+ const text = item.trim();
231
+ if (/^(?:"?[A-Za-z_]\w*"?\s*\.\s*)?\*$/.test(text))
232
+ return "all";
233
+ const m = /^(?:"?[A-Za-z_]\w*"?\s*\.\s*)?"?([A-Za-z_]\w*)"?(?:\s+(?:as\s+)?"?([A-Za-z_]\w*)"?)?$/i.exec(text);
234
+ if (!m)
235
+ continue;
236
+ const column = m[1].toLowerCase();
237
+ if (column === (m[2] ?? m[1]).toLowerCase())
238
+ carried.add(column);
239
+ }
240
+ return carried;
241
+ }
242
+ /** The items of a query's first top-level select list: what lies between
243
+ * its SELECT (and any DISTINCT) and the FROM at the same depth, split at the
244
+ * commas at that depth. Empty when the query has no such list. */
245
+ function topLevelSelectList(query) {
246
+ const start = /^\s*select\s+(?:distinct\s+)?/i.exec(query);
247
+ if (!start)
248
+ return [];
249
+ const items = [];
250
+ let depth = 0;
251
+ let from = start[0].length;
252
+ for (let i = from; i < query.length; i++) {
253
+ const c = query[i];
254
+ if (c === "'" || c === '"') {
255
+ const close = query.indexOf(c, i + 1);
256
+ i = close < 0 ? query.length : close;
257
+ }
258
+ else if (c === "(")
259
+ depth += 1;
260
+ else if (c === ")")
261
+ depth -= 1;
262
+ else if (depth === 0 && c === ",") {
263
+ items.push(query.slice(from, i));
264
+ from = i + 1;
265
+ }
266
+ else if (depth === 0 && /\s/.test(c) && /^\s+from\b/i.test(query.slice(i))) {
267
+ items.push(query.slice(from, i));
268
+ return items;
269
+ }
270
+ }
271
+ items.push(query.slice(from));
272
+ return items;
273
+ }
135
274
  /** A statement or predicate reduced to what its join condition is made of:
136
275
  * lowercase, aliases replaced by their tables, quotes and blanks gone. */
137
276
  export function normalizeSql(text, aliases) {
@@ -156,6 +295,9 @@ export function predicateHolds(query, predicate, aliases) {
156
295
  const SET_OPERATOR = /\b(?:union(?:\s+all)?|intersect|except)\b/gi;
157
296
  /** The opening of a subquery inside parentheses. */
158
297
  const SUBQUERY_START = /^\s*(?:select|with)\b/i;
298
+ /** A CTE's name and the parenthesis its query opens with: `WITH r AS (`,
299
+ * `, s AS (`. */
300
+ const CTE_START = /(?:\bwith\s+(?:recursive\s+)?|,\s*)([A-Za-z_]\w*)\s+as\s*\(/gi;
159
301
  /** A FROM list that names several sources (`FROM a, b`): a join. */
160
302
  const FROM_LIST = /\bfrom\b([\s\S]*?)(?:\bwhere\b|\bgroup\b|\border\b|\blimit\b|\bhaving\b|\bwindow\b|\bqualify\b|$)/gi;
161
303
  /** The index just past the parenthesised group that opens at `open`, quotes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infino-ai/mcp-server",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "description": "MCP server for Infino — keyword, semantic, hybrid, and SQL retrieval for AI agents: RAG, persistent agent memory, and search over data stored as plain Parquet on object storage. Local embeddings, no API key.",
5
5
  "mcpName": "io.github.infino-ai/mcp-server",
6
6
  "license": "Apache-2.0",
@@ -58,17 +58,17 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@huggingface/transformers": "^4.3.2",
61
- "@infino-ai/infino": "^0.11.24",
61
+ "@infino-ai/infino": "^0.11.27",
62
62
  "@modelcontextprotocol/sdk": "^1.32.2",
63
63
  "zod": "^4.6.5"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@eslint/js": "^10.0.1",
67
67
  "@types/node": "^26",
68
- "eslint": "^10.14.0",
68
+ "eslint": "^10.15.0",
69
69
  "globals": "^17.14.0",
70
- "prettier": "^3.9.10",
70
+ "prettier": "^3.10.1",
71
71
  "typescript": "^6.0.3",
72
- "typescript-eslint": "^8.72.1"
72
+ "typescript-eslint": "^8.72.2"
73
73
  }
74
74
  }