@infino-ai/mcp-server 0.1.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/LICENSE +201 -0
- package/README.md +280 -0
- package/dist/embedding.js +36 -0
- package/dist/index.js +447 -0
- package/package.json +36 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright The Infino Authors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
# Infino MCP server
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@infino-ai/mcp-server)
|
|
4
|
+
[](https://registry.modelcontextprotocol.io/?search=io.github.infino-ai/mcp-server)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
|
|
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
|
+
|
|
9
|
+
- **No API key.** Semantic search embeds queries with a local model — nothing leaves the machine for embedding.
|
|
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, GCS, Azure, or any S3-compatible store).
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Contents
|
|
16
|
+
|
|
17
|
+
- [Requirements](#requirements)
|
|
18
|
+
- [Quick start](#quick-start)
|
|
19
|
+
- [Client setup](#client-setup)
|
|
20
|
+
- [Claude Code](#claude-code)
|
|
21
|
+
- [Claude Desktop](#claude-desktop)
|
|
22
|
+
- [Cursor](#cursor)
|
|
23
|
+
- [VS Code](#vs-code)
|
|
24
|
+
- [Other MCP clients](#other-mcp-clients)
|
|
25
|
+
- [Configuration](#configuration)
|
|
26
|
+
- [Environment variables](#environment-variables)
|
|
27
|
+
- [Storage backends](#storage-backends)
|
|
28
|
+
- [Tools](#tools)
|
|
29
|
+
- [Security & data handling](#security--data-handling)
|
|
30
|
+
- [How retrieval works](#how-retrieval-works)
|
|
31
|
+
- [Troubleshooting](#troubleshooting)
|
|
32
|
+
- [Local development](#local-development)
|
|
33
|
+
- [License](#license)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Requirements
|
|
38
|
+
|
|
39
|
+
- **Node.js ≥ 18** (the server runs as a Node process over stdio).
|
|
40
|
+
- **An MCP-compatible client** (Claude Code, Claude Desktop, Cursor, VS Code, …).
|
|
41
|
+
- **Data reachable by Infino** — a local directory, or a bucket with credentials available in the environment (see [Storage backends](#storage-backends)).
|
|
42
|
+
- On first run the server downloads the local embedding model (~90 MB) once and caches it; subsequent runs are offline for embedding.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Quick start
|
|
47
|
+
|
|
48
|
+
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. At minimum, set `INFINO_MCP_URI` to the data you want to serve.
|
|
49
|
+
|
|
50
|
+
```jsonc
|
|
51
|
+
{
|
|
52
|
+
"command": "npx",
|
|
53
|
+
"args": ["-y", "@infino-ai/mcp-server"],
|
|
54
|
+
"env": {
|
|
55
|
+
"INFINO_MCP_URI": "/Users/me/.infino/memory"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The sections below show the exact place each client expects this block.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Client setup
|
|
65
|
+
|
|
66
|
+
### Claude Code
|
|
67
|
+
|
|
68
|
+
Add the server with the CLI. Use `--scope user` to make it available in every project, or `--scope project` to commit it to the repo (writes a shared `.mcp.json`); the default scope is `local` (this project only).
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
claude mcp add infino \
|
|
72
|
+
--scope user \
|
|
73
|
+
-e INFINO_MCP_URI=/Users/me/.infino/memory \
|
|
74
|
+
-- npx -y @infino-ai/mcp-server
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Add more knobs with repeated `-e` flags, e.g. `-e INFINO_MCP_ENABLE_WRITES=true`. Verify with:
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
claude mcp list
|
|
81
|
+
claude mcp get infino
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Claude Desktop
|
|
85
|
+
|
|
86
|
+
Edit the configuration file (create it if it doesn't exist), then fully restart Claude Desktop.
|
|
87
|
+
|
|
88
|
+
| OS | Path |
|
|
89
|
+
| --- | --- |
|
|
90
|
+
| macOS | `~/Library/Application Support/Claude/claude_desktop_config.json` |
|
|
91
|
+
| Windows | `%APPDATA%\Claude\claude_desktop_config.json` |
|
|
92
|
+
| Linux | `~/.config/Claude/claude_desktop_config.json` |
|
|
93
|
+
|
|
94
|
+
```jsonc
|
|
95
|
+
{
|
|
96
|
+
"mcpServers": {
|
|
97
|
+
"infino": {
|
|
98
|
+
"command": "npx",
|
|
99
|
+
"args": ["-y", "@infino-ai/mcp-server"],
|
|
100
|
+
"env": {
|
|
101
|
+
"INFINO_MCP_URI": "/Users/me/.infino/memory"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Cursor
|
|
109
|
+
|
|
110
|
+
Add the server to **`~/.cursor/mcp.json`** (available in all projects) or **`<project>/.cursor/mcp.json`** (this project only), then reload. The format matches Claude Desktop:
|
|
111
|
+
|
|
112
|
+
```jsonc
|
|
113
|
+
{
|
|
114
|
+
"mcpServers": {
|
|
115
|
+
"infino": {
|
|
116
|
+
"command": "npx",
|
|
117
|
+
"args": ["-y", "@infino-ai/mcp-server"],
|
|
118
|
+
"env": {
|
|
119
|
+
"INFINO_MCP_URI": "/Users/me/.infino/memory"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### VS Code
|
|
127
|
+
|
|
128
|
+
VS Code (1.102+) reads MCP servers from **`.vscode/mcp.json`** in the workspace (or your user `mcp.json` via the command palette → *MCP: Open User Configuration*). Note the top-level key is `servers` and each entry declares `"type": "stdio"`:
|
|
129
|
+
|
|
130
|
+
```jsonc
|
|
131
|
+
{
|
|
132
|
+
"servers": {
|
|
133
|
+
"infino": {
|
|
134
|
+
"type": "stdio",
|
|
135
|
+
"command": "npx",
|
|
136
|
+
"args": ["-y", "@infino-ai/mcp-server"],
|
|
137
|
+
"env": {
|
|
138
|
+
"INFINO_MCP_URI": "/Users/me/.infino/memory"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Other MCP clients
|
|
146
|
+
|
|
147
|
+
Any client that speaks MCP over stdio works. Configure it to launch:
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
command: npx
|
|
151
|
+
args: -y @infino-ai/mcp-server
|
|
152
|
+
env: INFINO_MCP_URI=<path-or-bucket-uri> (plus any options below)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Logs are written to **stderr** so they never corrupt the JSON-RPC stream on stdout — point your client's log capture there when debugging.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Configuration
|
|
160
|
+
|
|
161
|
+
All configuration is via environment variables — there are no config files and no command-line flags to manage.
|
|
162
|
+
|
|
163
|
+
### Environment variables
|
|
164
|
+
|
|
165
|
+
| Variable | Required | Default | Description |
|
|
166
|
+
| --- | --- | --- | --- |
|
|
167
|
+
| `INFINO_MCP_URI` | **Yes** | — | Data to serve: a local path (`/Users/me/.infino/memory`) or a bucket URI (`s3://…`, `gs://…`, `az://…`). |
|
|
168
|
+
| `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. |
|
|
169
|
+
| `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). |
|
|
170
|
+
| `INFINO_MCP_S3_ENDPOINT` | No | — | Custom S3 endpoint for non-AWS S3-compatible stores (Cloudflare R2, MinIO, Backblaze B2, …). |
|
|
171
|
+
| `INFINO_MCP_S3_REGION` | No | `auto` | Region to send with a custom S3 endpoint. |
|
|
172
|
+
|
|
173
|
+
Cloud credentials are read from the standard provider environment variables — the server does not introduce its own:
|
|
174
|
+
|
|
175
|
+
| Backend | Credentials |
|
|
176
|
+
| --- | --- |
|
|
177
|
+
| AWS S3 | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` (+ `AWS_SESSION_TOKEN` if used) |
|
|
178
|
+
| S3-compatible (R2/MinIO/B2) | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` **and** `INFINO_MCP_S3_ENDPOINT` |
|
|
179
|
+
| Google Cloud Storage | `GOOGLE_APPLICATION_CREDENTIALS` (or ambient ADC) |
|
|
180
|
+
| Azure Blob | `AZURE_STORAGE_ACCOUNT`, `AZURE_STORAGE_KEY` |
|
|
181
|
+
|
|
182
|
+
### Storage backends
|
|
183
|
+
|
|
184
|
+
```jsonc
|
|
185
|
+
// Local directory
|
|
186
|
+
"env": { "INFINO_MCP_URI": "/Users/me/.infino/memory" }
|
|
187
|
+
|
|
188
|
+
// AWS S3 — ambient AWS_* credentials, default endpoint
|
|
189
|
+
"env": {
|
|
190
|
+
"INFINO_MCP_URI": "s3://my-bucket/infino",
|
|
191
|
+
"AWS_ACCESS_KEY_ID": "…",
|
|
192
|
+
"AWS_SECRET_ACCESS_KEY": "…"
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// S3-compatible (Cloudflare R2 / MinIO / Backblaze B2) — custom endpoint
|
|
196
|
+
"env": {
|
|
197
|
+
"INFINO_MCP_URI": "s3://my-bucket/infino",
|
|
198
|
+
"INFINO_MCP_S3_ENDPOINT": "https://<account>.r2.cloudflarestorage.com",
|
|
199
|
+
"INFINO_MCP_S3_REGION": "auto",
|
|
200
|
+
"AWS_ACCESS_KEY_ID": "…",
|
|
201
|
+
"AWS_SECRET_ACCESS_KEY": "…"
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Tools
|
|
208
|
+
|
|
209
|
+
| Tool | Arguments | What it does |
|
|
210
|
+
| --- | --- | --- |
|
|
211
|
+
| `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). |
|
|
212
|
+
| `infino_keyword_search` | `table`, `query`, `k`, `column?` | BM25 full-text search — for exact terms, identifiers, error codes, product names. |
|
|
213
|
+
| `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. |
|
|
214
|
+
| `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. |
|
|
215
|
+
| `infino_exact_match` | `table`, `value`, `column?`, `limit?` | Unranked exact-equality filter over an indexed column (tag, status, id string). |
|
|
216
|
+
| `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. |
|
|
217
|
+
| `infino_list_tables` | — | List the tables in the connected catalog. |
|
|
218
|
+
| `infino_describe_table` | `table` | Column names and types for a table. |
|
|
219
|
+
| `infino_add_documents` | `table`, `documents` | Append rows (one call = one commit); embeds the text column for vector tables. **Only when `INFINO_MCP_ENABLE_WRITES` is set.** |
|
|
220
|
+
| `infino_update_documents` | `table`, `predicate`, `documents` | Replace the rows matching a SQL predicate with new documents, 1:1 (missing vectors are embedded). Durable storage only. **Only when `INFINO_MCP_ENABLE_WRITES` is set.** |
|
|
221
|
+
| `infino_delete_documents` | `table`, `predicate` | Delete the rows matching a SQL predicate. Durable storage only. **Only when `INFINO_MCP_ENABLE_WRITES` is set.** |
|
|
222
|
+
|
|
223
|
+
The engine's search table functions (`bm25_search`, `vector_search`, `hybrid_search`, …) are not callable from `infino_sql` — retrieval goes through the dedicated search tools above, which embed and project for you. `infino_sql` is for filters, joins, and aggregates.
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Security & data handling
|
|
228
|
+
|
|
229
|
+
This server is designed to run locally, beside the client, and to keep data and credentials on the user's machine.
|
|
230
|
+
|
|
231
|
+
- **Local execution.** It runs as a subprocess of your MCP client over stdio. There is no network listener and no remote service.
|
|
232
|
+
- **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.
|
|
233
|
+
- **Credentials stay in the environment.** Storage credentials are read from standard provider environment variables and used only to reach the bucket you configured. They are never logged or returned in tool output.
|
|
234
|
+
- **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.
|
|
235
|
+
- **Least privilege.** Point `INFINO_MCP_URI` at the narrowest dataset the task needs, and supply storage credentials scoped to that bucket/prefix.
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## How retrieval works
|
|
240
|
+
|
|
241
|
+
Semantic search embeds locally with Hugging Face transformers.js (`all-MiniLM-L6-v2`, 384-dim by default; override with `INFINO_MCP_EMBED_MODEL`). The server embeds **both** the documents it ingests (via `infino_add_documents`) and your queries with the same model, so they align in the same vector space.
|
|
242
|
+
|
|
243
|
+
If you change `INFINO_MCP_EMBED_MODEL`, the table's vector index must match the new model's dimension — embeddings produced by different models are not comparable, and a dimension mismatch will fail at search time.
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## Troubleshooting
|
|
248
|
+
|
|
249
|
+
| Symptom | Likely cause / fix |
|
|
250
|
+
| --- | --- |
|
|
251
|
+
| Client shows no Infino tools | Server didn't start — check the client's MCP logs (stderr). Confirm `npx` is on `PATH` and `INFINO_MCP_URI` is set. Fully restart the client after editing config. |
|
|
252
|
+
| `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). |
|
|
253
|
+
| `add_documents` not available | `INFINO_MCP_ENABLE_WRITES` isn't set, or the client wasn't restarted after setting it. |
|
|
254
|
+
| Slow first query | One-time embedding-model download (~90 MB). Subsequent runs use the cache. |
|
|
255
|
+
| 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. |
|
|
256
|
+
| `… 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. |
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Local development
|
|
261
|
+
|
|
262
|
+
The server depends on the published [`@infino-ai/infino`](https://www.npmjs.com/package/@infino-ai/infino) Node binding, which resolves from public npm like any other dependency.
|
|
263
|
+
|
|
264
|
+
```sh
|
|
265
|
+
npm install
|
|
266
|
+
npm run build
|
|
267
|
+
INFINO_MCP_URI=/path/to/data node dist/index.js # runs on stdio
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Point a client at `node /absolute/path/dist/index.js` over stdio to dogfood a local build, or use the [MCP Inspector](https://github.com/modelcontextprotocol/inspector):
|
|
271
|
+
|
|
272
|
+
```sh
|
|
273
|
+
npx @modelcontextprotocol/inspector node dist/index.js
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## License
|
|
279
|
+
|
|
280
|
+
[Apache-2.0](./LICENSE)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright The Infino Authors
|
|
3
|
+
//
|
|
4
|
+
// Server-side embedding. infino is bring-your-own-vectors (the engine doesn't
|
|
5
|
+
// embed) and an agent can't produce a query vector — so the server turns text
|
|
6
|
+
// into vectors for semantic search.
|
|
7
|
+
//
|
|
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.
|
|
16
|
+
let pipe = null;
|
|
17
|
+
function getPipe() {
|
|
18
|
+
if (!pipe) {
|
|
19
|
+
pipe = (async () => {
|
|
20
|
+
const { pipeline } = await import("@huggingface/transformers");
|
|
21
|
+
return (await pipeline("feature-extraction", MODEL));
|
|
22
|
+
})();
|
|
23
|
+
}
|
|
24
|
+
return pipe;
|
|
25
|
+
}
|
|
26
|
+
/** Embed one text into a vector with the local model. */
|
|
27
|
+
export async function embed(text) {
|
|
28
|
+
const extractor = await getPipe();
|
|
29
|
+
// Mean-pool token vectors and L2-normalize → one sentence embedding.
|
|
30
|
+
const output = await extractor(text, { pooling: "mean", normalize: true });
|
|
31
|
+
return Array.from(output.data, Number);
|
|
32
|
+
}
|
|
33
|
+
/** Human-readable description of the embedder, for the startup log. */
|
|
34
|
+
export function embedderInfo() {
|
|
35
|
+
return `local ${MODEL} (no key)`;
|
|
36
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The Infino Authors
|
|
4
|
+
//
|
|
5
|
+
// MCP server for Infino — lets an agent run retrieval over data on object
|
|
6
|
+
// storage from any MCP client. Exposes catalog discovery (list/describe),
|
|
7
|
+
// keyword (BM25), semantic (local-embedding vector), and hybrid (fused)
|
|
8
|
+
// search, unranked token/exact match, and read-only SQL; document writes
|
|
9
|
+
// (add/update/delete) and full SQL are opt-in behind INFINO_MCP_ENABLE_WRITES.
|
|
10
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
11
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { connect } from "@infino-ai/infino";
|
|
14
|
+
import { embed, embedderInfo } from "./embedding.js";
|
|
15
|
+
// --- connection (env-configured, opened once at startup) -------------------
|
|
16
|
+
//
|
|
17
|
+
// 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://|gs://|az:// bucket).
|
|
19
|
+
// AWS S3 uses the default endpoint + ambient AWS_* creds. For any other
|
|
20
|
+
// S3-compatible store (Cloudflare R2, MinIO, Backblaze B2, …) set
|
|
21
|
+
// INFINO_MCP_S3_ENDPOINT (and optionally INFINO_MCP_S3_REGION) alongside
|
|
22
|
+
// AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY. GCS/Azure use GOOGLE_*/AZURE_* creds.
|
|
23
|
+
const uri = process.env.INFINO_MCP_URI;
|
|
24
|
+
if (!uri) {
|
|
25
|
+
console.error("INFINO_MCP_URI is required — a local path (e.g. /Users/me/.infino/memory) " +
|
|
26
|
+
"or an s3://|gs://|az:// URI for the data to serve.");
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
// A custom S3 endpoint (non-AWS S3-compatible store) requires the region and
|
|
30
|
+
// access/secret keys to be supplied with it; AWS S3 needs none of this.
|
|
31
|
+
let connectOptions;
|
|
32
|
+
const s3Endpoint = process.env.INFINO_MCP_S3_ENDPOINT;
|
|
33
|
+
if (s3Endpoint) {
|
|
34
|
+
const accessKey = process.env.AWS_ACCESS_KEY_ID;
|
|
35
|
+
const secretKey = process.env.AWS_SECRET_ACCESS_KEY;
|
|
36
|
+
if (!accessKey || !secretKey) {
|
|
37
|
+
console.error("INFINO_MCP_S3_ENDPOINT is set but AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY are missing.");
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
connectOptions = {
|
|
41
|
+
endpoint: s3Endpoint,
|
|
42
|
+
region: process.env.INFINO_MCP_S3_REGION ?? "auto",
|
|
43
|
+
accessKey,
|
|
44
|
+
secretKey,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
let db;
|
|
48
|
+
try {
|
|
49
|
+
db = connect(uri, connectOptions);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
console.error(`Failed to connect to ${uri}: ${err.message}`);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
// Writes (infino_add_documents) are off unless explicitly enabled, so the
|
|
56
|
+
// default install is read-only and the write tool isn't even advertised.
|
|
57
|
+
const writesEnabled = ["1", "true", "yes"].includes((process.env.INFINO_MCP_ENABLE_WRITES ?? "").toLowerCase());
|
|
58
|
+
// --- helpers ---------------------------------------------------------------
|
|
59
|
+
// `_id` comes back as a bigint, which JSON can't serialize — render it as a string.
|
|
60
|
+
const toText = (value) => JSON.stringify(value, (_k, v) => (typeof v === "bigint" ? v.toString() : v), 2);
|
|
61
|
+
const ok = (value) => ({ content: [{ type: "text", text: toText(value) }] });
|
|
62
|
+
const fail = (message) => ({
|
|
63
|
+
content: [{ type: "text", text: message }],
|
|
64
|
+
isError: true,
|
|
65
|
+
});
|
|
66
|
+
// SQL literal / identifier quoting. The hybrid_search tool builds SQL from
|
|
67
|
+
// caller-supplied table/column names and query text, so every interpolated
|
|
68
|
+
// value is escaped: string args become single-quoted literals, column names
|
|
69
|
+
// become double-quoted identifiers.
|
|
70
|
+
const sqlStr = (s) => `'${s.replace(/'/g, "''")}'`;
|
|
71
|
+
const sqlIdent = (s) => `"${s.replace(/"/g, '""')}"`;
|
|
72
|
+
// When the caller doesn't name a column, search the first UTF-8 text column in
|
|
73
|
+
// the table's schema. (A table can have several; an explicit `column` overrides.)
|
|
74
|
+
function inferTextColumn(table) {
|
|
75
|
+
const field = table.schema().fields.find((f) => String(f.type).toLowerCase().includes("utf8"));
|
|
76
|
+
return field?.name;
|
|
77
|
+
}
|
|
78
|
+
// The first list-typed column (the vector index lives on a FixedSizeList<float32>).
|
|
79
|
+
function inferVectorColumn(table) {
|
|
80
|
+
const field = table.schema().fields.find((f) => String(f.type).toLowerCase().includes("list"));
|
|
81
|
+
return field?.name;
|
|
82
|
+
}
|
|
83
|
+
async function embedRows(handle, rows) {
|
|
84
|
+
const vecCol = inferVectorColumn(handle);
|
|
85
|
+
if (!vecCol)
|
|
86
|
+
return rows;
|
|
87
|
+
const textCol = inferTextColumn(handle);
|
|
88
|
+
return Promise.all(rows.map(async (doc) => doc[vecCol] == null && textCol && typeof doc[textCol] === "string"
|
|
89
|
+
? { ...doc, [vecCol]: await embed(doc[textCol]) }
|
|
90
|
+
: doc));
|
|
91
|
+
}
|
|
92
|
+
// Search table functions are routed to the dedicated search tools instead of
|
|
93
|
+
// infino_sql. This is now a usability policy, not a technical limit: search
|
|
94
|
+
// TVFs through query_sql work from this async host (they once aborted via the
|
|
95
|
+
// engine's blocking bridge; that's fixed). But hand-assembling a TVF call —
|
|
96
|
+
// especially a vector literal — is error-prone for an agent, so retrieval goes
|
|
97
|
+
// through the typed tools (infino_semantic_search / infino_keyword_search /
|
|
98
|
+
// infino_hybrid_search), which build the call internally.
|
|
99
|
+
const SEARCH_TVFS = ["bm25_search", "vector_search", "hybrid_search", "token_match", "exact_match"];
|
|
100
|
+
// Guard for infino_sql. Two layers:
|
|
101
|
+
// - The search-TVF block is ALWAYS on. It is a usability policy: search TVFs
|
|
102
|
+
// do work through query_sql now, but the typed retrieval tools are the
|
|
103
|
+
// intended interface (they handle embedding and projection), so free-form
|
|
104
|
+
// SQL is kept to filters/joins/aggregates and retrieval goes through them.
|
|
105
|
+
// - The read-only restriction (single statement, must start with SELECT/WITH)
|
|
106
|
+
// is policy, gated by the same INFINO_MCP_ENABLE_WRITES switch as
|
|
107
|
+
// infino_add_documents. Off → read-only only, so the default install can't
|
|
108
|
+
// write through SQL. On → any single statement (DDL/DML) is allowed, which
|
|
109
|
+
// makes the binding's querySql fully reachable.
|
|
110
|
+
function guardSql(sql, allowWrites) {
|
|
111
|
+
const stripped = sql.trim().replace(/;\s*$/, "");
|
|
112
|
+
if (stripped.includes(";"))
|
|
113
|
+
throw new Error("only a single statement is allowed");
|
|
114
|
+
const tvf = SEARCH_TVFS.find((fn) => new RegExp(`\\b${fn}\\s*\\(`, "i").test(stripped));
|
|
115
|
+
if (tvf) {
|
|
116
|
+
throw new Error(`${tvf}() isn't available through infino_sql — use the dedicated retrieval tools (infino_keyword_search, ` +
|
|
117
|
+
`infino_semantic_search, infino_hybrid_search) instead. infino_sql is for filters, joins, and aggregates over your tables.`);
|
|
118
|
+
}
|
|
119
|
+
if (!allowWrites && !/^(select|with)\b/i.test(stripped)) {
|
|
120
|
+
throw new Error("only read-only SELECT / WITH queries are allowed (set INFINO_MCP_ENABLE_WRITES to permit DDL/DML through SQL)");
|
|
121
|
+
}
|
|
122
|
+
return stripped;
|
|
123
|
+
}
|
|
124
|
+
// --- server ----------------------------------------------------------------
|
|
125
|
+
// Server-level instructions are returned to the client on initialize and shown
|
|
126
|
+
// to the model — the highest-leverage place to position Infino and steer which
|
|
127
|
+
// tool fires when. Kept factual and answer-first (no keyword stuffing).
|
|
128
|
+
const server = new McpServer({ name: "infino", version: "0.1.0" }, {
|
|
129
|
+
instructions: "Infino is an embedded retrieval engine for data on object storage: full-text (BM25), vector, " +
|
|
130
|
+
"hybrid, and SQL search over one copy of the data, in-process, with no separate server or managed " +
|
|
131
|
+
"service. These tools retrieve from a connected catalog of tables.\n\n" +
|
|
132
|
+
"Pick a tool by the question shape:\n" +
|
|
133
|
+
"- infino_keyword_search — literal terms, identifiers, error codes, names (ranked BM25).\n" +
|
|
134
|
+
"- infino_semantic_search — meaning or paraphrase when the exact wording is unknown; its optional " +
|
|
135
|
+
"'filter' restricts the ranking to rows matching a keyword predicate first.\n" +
|
|
136
|
+
"- infino_hybrid_search — a query carrying both specific terms and an intent (fuses keyword + semantic in one pass).\n" +
|
|
137
|
+
"- infino_sql — counts, joins, aggregates, and filtering by exact column value (structural, not relevance).\n" +
|
|
138
|
+
"- infino_token_match / infino_exact_match — unranked keyword / exact-equality filters.\n" +
|
|
139
|
+
"- infino_list_tables / infino_describe_table — discover the tables and their columns before searching.\n\n" +
|
|
140
|
+
"The server is read-only by default; document writes (add/update/delete) and DDL/DML SQL are available " +
|
|
141
|
+
"only when the operator has enabled writes.",
|
|
142
|
+
});
|
|
143
|
+
server.registerTool("infino_list_tables", {
|
|
144
|
+
title: "List Infino tables",
|
|
145
|
+
description: "List the tables in the connected catalog. Call this first to discover what is available to search or query.",
|
|
146
|
+
inputSchema: {},
|
|
147
|
+
}, async () => {
|
|
148
|
+
try {
|
|
149
|
+
return ok({ tables: db.listTables() });
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
return fail(`list_tables failed: ${err.message}`);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
server.registerTool("infino_describe_table", {
|
|
156
|
+
title: "Describe an Infino table",
|
|
157
|
+
description: "Return a table's column names and types — call before searching so you know which column to target and what " +
|
|
158
|
+
"fields each result row carries.",
|
|
159
|
+
inputSchema: {
|
|
160
|
+
table: z.string().describe("Table name (from infino_list_tables)."),
|
|
161
|
+
},
|
|
162
|
+
}, async ({ table }) => {
|
|
163
|
+
try {
|
|
164
|
+
const columns = db
|
|
165
|
+
.openTable(table)
|
|
166
|
+
.schema()
|
|
167
|
+
.fields.map((f) => ({ name: f.name, type: String(f.type) }));
|
|
168
|
+
return ok({ table, columns });
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
return fail(`describe_table failed: ${err.message}`);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
server.registerTool("infino_semantic_search", {
|
|
175
|
+
title: "Semantic (vector) search",
|
|
176
|
+
description: "Use when searching for a concept by meaning and the exact wording is unknown — this retrieves paraphrases and " +
|
|
177
|
+
"synonyms, not just literal matches. Embeds the query with a local model (no API key) and ranks a table's " +
|
|
178
|
+
"embedding column by vector similarity, each hit with a score. Optional 'filter' restricts the ranking to rows " +
|
|
179
|
+
"whose keyword column matches a predicate first (a pushdown pre-filter, e.g. semantic search only within rows " +
|
|
180
|
+
"tagged 'billing'). For exact terms use infino_keyword_search; when the query has both literal terms and an " +
|
|
181
|
+
"intent use infino_hybrid_search.",
|
|
182
|
+
inputSchema: {
|
|
183
|
+
table: z.string().describe("Table to search."),
|
|
184
|
+
query: z.string().describe("Query text; embedded and matched by vector similarity."),
|
|
185
|
+
k: z.number().int().positive().max(100).default(10).describe("Maximum results."),
|
|
186
|
+
column: z.string().optional().describe("Text column to return with each hit; inferred if omitted."),
|
|
187
|
+
vectorColumn: z.string().optional().describe("Vector column to search; inferred if omitted."),
|
|
188
|
+
filter: z
|
|
189
|
+
.object({
|
|
190
|
+
column: z.string().describe("Keyword-indexed (FTS) column the predicate applies to."),
|
|
191
|
+
query: z.string().describe("Terms the column must match."),
|
|
192
|
+
mode: z
|
|
193
|
+
.enum(["or", "and"])
|
|
194
|
+
.optional()
|
|
195
|
+
.describe("Match any term ('or', the default) or every term ('and')."),
|
|
196
|
+
})
|
|
197
|
+
.optional()
|
|
198
|
+
.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)."),
|
|
199
|
+
},
|
|
200
|
+
}, async ({ table, query, k, column, vectorColumn, filter }) => {
|
|
201
|
+
try {
|
|
202
|
+
const handle = db.openTable(table);
|
|
203
|
+
const vecCol = vectorColumn ?? inferVectorColumn(handle);
|
|
204
|
+
if (!vecCol)
|
|
205
|
+
return fail(`semantic_search: no vector column in '${table}' — pass 'vectorColumn'.`);
|
|
206
|
+
const textCol = column ?? inferTextColumn(handle);
|
|
207
|
+
const vector = await embed(query);
|
|
208
|
+
const projection = textCol ? [textCol, "_id", "score"] : ["_id", "score"];
|
|
209
|
+
const results = handle.vectorSearch(vecCol, vector, k, { projection, filter });
|
|
210
|
+
return ok({ table, query, results });
|
|
211
|
+
}
|
|
212
|
+
catch (err) {
|
|
213
|
+
return fail(`semantic_search failed: ${err.message}`);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
server.registerTool("infino_keyword_search", {
|
|
217
|
+
title: "Keyword (BM25) search",
|
|
218
|
+
description: "Use when the query is literal terms — identifiers, error codes, product names, exact phrases — and you want " +
|
|
219
|
+
"results ranked by relevance. BM25 full-text search over a text column: ranks rows by how well the query's " +
|
|
220
|
+
"tokens (and their stems) match, each with a relevance score. Matches exact tokens, not synonyms or paraphrases. " +
|
|
221
|
+
"Prefer this over SQL LIKE for known literal terms. For meaning-based search use infino_semantic_search; for " +
|
|
222
|
+
"both at once use infino_hybrid_search.",
|
|
223
|
+
inputSchema: {
|
|
224
|
+
table: z.string().describe("Table to search."),
|
|
225
|
+
query: z.string().describe("Query terms, matched as literal tokens."),
|
|
226
|
+
k: z.number().int().positive().max(100).default(10).describe("Maximum results to return."),
|
|
227
|
+
column: z
|
|
228
|
+
.string()
|
|
229
|
+
.optional()
|
|
230
|
+
.describe("Text column to search; inferred from the table schema when omitted."),
|
|
231
|
+
},
|
|
232
|
+
}, async ({ table, query, k, column }) => {
|
|
233
|
+
try {
|
|
234
|
+
const handle = db.openTable(table);
|
|
235
|
+
const col = column ?? inferTextColumn(handle);
|
|
236
|
+
if (!col) {
|
|
237
|
+
return fail(`keyword_search: no text column found in '${table}' — pass 'column' explicitly.`);
|
|
238
|
+
}
|
|
239
|
+
const results = handle.bm25Search(col, query, k, { projection: [col, "_id", "score"] });
|
|
240
|
+
return ok({ table, column: col, query, results });
|
|
241
|
+
}
|
|
242
|
+
catch (err) {
|
|
243
|
+
return fail(`keyword_search failed: ${err.message}`);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
server.registerTool("infino_hybrid_search", {
|
|
247
|
+
title: "Hybrid (keyword + semantic) search",
|
|
248
|
+
description: "Use when a query carries both specific terms and an intent — you want exact-term precision without giving up " +
|
|
249
|
+
"paraphrase recall. Fuses BM25 over a text column with vector similarity over the embedding column in a single " +
|
|
250
|
+
"ranking pass, so rows matching the literal terms AND the meaning rank highest. Embeds the query with a local " +
|
|
251
|
+
"model (no API key). Sits between infino_keyword_search (literal only) and infino_semantic_search (meaning only).",
|
|
252
|
+
inputSchema: {
|
|
253
|
+
table: z.string().describe("Table to search."),
|
|
254
|
+
query: z.string().describe("Query text; matched as keyword terms AND embedded for vector similarity."),
|
|
255
|
+
k: z.number().int().positive().max(100).default(10).describe("Maximum results."),
|
|
256
|
+
column: z.string().optional().describe("Text column for the keyword half; inferred if omitted."),
|
|
257
|
+
vectorColumn: z.string().optional().describe("Vector column for the semantic half; inferred if omitted."),
|
|
258
|
+
},
|
|
259
|
+
}, async ({ table, query, k, column, vectorColumn }) => {
|
|
260
|
+
try {
|
|
261
|
+
const handle = db.openTable(table);
|
|
262
|
+
const textCol = column ?? inferTextColumn(handle);
|
|
263
|
+
if (!textCol)
|
|
264
|
+
return fail(`hybrid_search: no text column in '${table}' — pass 'column'.`);
|
|
265
|
+
const vecCol = vectorColumn ?? inferVectorColumn(handle);
|
|
266
|
+
if (!vecCol)
|
|
267
|
+
return fail(`hybrid_search: no vector column in '${table}' — pass 'vectorColumn'.`);
|
|
268
|
+
const vector = await embed(query);
|
|
269
|
+
// hybrid_search is a SQL table-valued function (there is no typed binding
|
|
270
|
+
// method), so build the call internally — the agent never hand-assembles
|
|
271
|
+
// the vector literal. k is a validated positive int, safe to inline.
|
|
272
|
+
const cols = [sqlIdent(textCol), "_id", "score"].join(", ");
|
|
273
|
+
const sql = `SELECT ${cols} FROM hybrid_search(` +
|
|
274
|
+
`${sqlStr(table)}, ${sqlStr(textCol)}, ${sqlStr(query)}, ` +
|
|
275
|
+
`${sqlStr(vecCol)}, ${sqlStr(vector.join(","))}, ${k})`;
|
|
276
|
+
const results = db.querySql(sql);
|
|
277
|
+
return ok({ table, query, results });
|
|
278
|
+
}
|
|
279
|
+
catch (err) {
|
|
280
|
+
return fail(`hybrid_search failed: ${err.message}`);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
server.registerTool("infino_token_match", {
|
|
284
|
+
title: "Token match (unranked keyword filter)",
|
|
285
|
+
description: "Use when you need the SET of rows containing a keyword, not a ranked order — a fast unranked keyword filter. " +
|
|
286
|
+
"Returns rows whose text column contains the token(s), matching indexed tokens and their stems. For ranked " +
|
|
287
|
+
"results use infino_keyword_search; for analytical filtering across columns use infino_sql.",
|
|
288
|
+
inputSchema: {
|
|
289
|
+
table: z.string().describe("Table to search."),
|
|
290
|
+
query: z.string().describe("Token(s) to match."),
|
|
291
|
+
column: z.string().optional().describe("Text column to match; inferred if omitted."),
|
|
292
|
+
mode: z
|
|
293
|
+
.enum(["or", "and"])
|
|
294
|
+
.optional()
|
|
295
|
+
.describe("Match any token ('or', the default) or every token ('and')."),
|
|
296
|
+
limit: z
|
|
297
|
+
.number()
|
|
298
|
+
.int()
|
|
299
|
+
.positive()
|
|
300
|
+
.max(1000)
|
|
301
|
+
.default(100)
|
|
302
|
+
.describe("Max rows to return; matches beyond this are counted in 'matched' but not returned."),
|
|
303
|
+
},
|
|
304
|
+
}, async ({ table, query, column, mode, limit }) => {
|
|
305
|
+
try {
|
|
306
|
+
const handle = db.openTable(table);
|
|
307
|
+
const col = column ?? inferTextColumn(handle);
|
|
308
|
+
if (!col)
|
|
309
|
+
return fail(`token_match: no text column in '${table}' — pass 'column'.`);
|
|
310
|
+
const rows = handle.tokenMatch(col, query, { mode, projection: [col, "_id"] });
|
|
311
|
+
return ok({ table, column: col, query, matched: rows.length, results: rows.slice(0, limit) });
|
|
312
|
+
}
|
|
313
|
+
catch (err) {
|
|
314
|
+
return fail(`token_match failed: ${err.message}`);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
server.registerTool("infino_exact_match", {
|
|
318
|
+
title: "Exact match (unranked exact filter)",
|
|
319
|
+
description: "Use to fetch rows whose column exactly equals a value — a tag, status, or id string. Unranked exact-equality " +
|
|
320
|
+
"filter over an indexed column. For ranked text relevance use infino_keyword_search; for multi-column " +
|
|
321
|
+
"analytical filtering use infino_sql.",
|
|
322
|
+
inputSchema: {
|
|
323
|
+
table: z.string().describe("Table to search."),
|
|
324
|
+
value: z.string().describe("The exact value the column must equal."),
|
|
325
|
+
column: z.string().optional().describe("Column to match; inferred (first text column) if omitted."),
|
|
326
|
+
limit: z
|
|
327
|
+
.number()
|
|
328
|
+
.int()
|
|
329
|
+
.positive()
|
|
330
|
+
.max(1000)
|
|
331
|
+
.default(100)
|
|
332
|
+
.describe("Max rows to return; matches beyond this are counted in 'matched' but not returned."),
|
|
333
|
+
},
|
|
334
|
+
}, async ({ table, value, column, limit }) => {
|
|
335
|
+
try {
|
|
336
|
+
const handle = db.openTable(table);
|
|
337
|
+
const col = column ?? inferTextColumn(handle);
|
|
338
|
+
if (!col)
|
|
339
|
+
return fail(`exact_match: no column found in '${table}' — pass 'column'.`);
|
|
340
|
+
const rows = handle.exactMatch(col, value, { projection: [col, "_id"] });
|
|
341
|
+
return ok({ table, column: col, value, matched: rows.length, results: rows.slice(0, limit) });
|
|
342
|
+
}
|
|
343
|
+
catch (err) {
|
|
344
|
+
return fail(`exact_match failed: ${err.message}`);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
server.registerTool("infino_sql", {
|
|
348
|
+
title: "SQL over Infino",
|
|
349
|
+
description: "Use for structural or analytical questions — counts, GROUP BY, joins, aggregates, filtering by exact column " +
|
|
350
|
+
"value — returning result rows. Row filters use literal/substring matching (e.g. LIKE), not ranked relevance, so " +
|
|
351
|
+
"for ranked or meaning-based text search use infino_keyword_search / infino_semantic_search / infino_hybrid_search " +
|
|
352
|
+
"instead (the engine's search table functions are not callable here). " +
|
|
353
|
+
(writesEnabled
|
|
354
|
+
? "Any single statement is allowed (including DDL/DML), since INFINO_MCP_ENABLE_WRITES is set."
|
|
355
|
+
: "Read-only: a single SELECT / WITH statement; DDL/DML is rejected."),
|
|
356
|
+
inputSchema: {
|
|
357
|
+
query: writesEnabled
|
|
358
|
+
? z.string().describe("A single SQL statement.")
|
|
359
|
+
: z.string().describe("A single read-only SELECT or WITH statement."),
|
|
360
|
+
},
|
|
361
|
+
}, async ({ query }) => {
|
|
362
|
+
try {
|
|
363
|
+
return ok({ rows: db.querySql(guardSql(query, writesEnabled)) });
|
|
364
|
+
}
|
|
365
|
+
catch (err) {
|
|
366
|
+
return fail(`sql failed: ${err.message}`);
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
// Write tool — registered only when writes are enabled, so a read-only install
|
|
370
|
+
// never advertises it to the agent.
|
|
371
|
+
if (writesEnabled) {
|
|
372
|
+
server.registerTool("infino_add_documents", {
|
|
373
|
+
title: "Add documents to an Infino table",
|
|
374
|
+
description: "Append documents (rows, as JSON objects keyed by column name) to a table — one call is one commit. " +
|
|
375
|
+
"If the table has a vector index and a document omits the vector, the server embeds its text column " +
|
|
376
|
+
"(a local model, no API key). Available only because INFINO_MCP_ENABLE_WRITES is set.",
|
|
377
|
+
inputSchema: {
|
|
378
|
+
table: z.string().describe("Table to append to."),
|
|
379
|
+
documents: z
|
|
380
|
+
.array(z.record(z.any()))
|
|
381
|
+
.min(1)
|
|
382
|
+
.describe("Rows to append, as JSON objects keyed by column name."),
|
|
383
|
+
},
|
|
384
|
+
}, async ({ table, documents }) => {
|
|
385
|
+
try {
|
|
386
|
+
const handle = db.openTable(table);
|
|
387
|
+
const rows = await embedRows(handle, documents);
|
|
388
|
+
handle.append(rows);
|
|
389
|
+
return ok({ table, appended: rows.length });
|
|
390
|
+
}
|
|
391
|
+
catch (err) {
|
|
392
|
+
return fail(`add_documents failed: ${err.message}`);
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
server.registerTool("infino_update_documents", {
|
|
396
|
+
title: "Update documents in an Infino table",
|
|
397
|
+
description: "Replace the rows matching a SQL predicate with new documents, 1:1 — the number of matched rows must equal " +
|
|
398
|
+
"the number of replacement documents. As with add, a row that omits its vector has it embedded from the text " +
|
|
399
|
+
"column (local model, no API key). Requires durable storage (not memory://). Available only because " +
|
|
400
|
+
"INFINO_MCP_ENABLE_WRITES is set.",
|
|
401
|
+
inputSchema: {
|
|
402
|
+
table: z.string().describe("Table to update."),
|
|
403
|
+
predicate: z
|
|
404
|
+
.string()
|
|
405
|
+
.describe("SQL predicate selecting the rows to replace, e.g. \"status = 'draft'\"."),
|
|
406
|
+
documents: z
|
|
407
|
+
.array(z.record(z.any()))
|
|
408
|
+
.min(1)
|
|
409
|
+
.describe("Replacement rows, as JSON objects keyed by column name (one per matched row)."),
|
|
410
|
+
},
|
|
411
|
+
}, async ({ table, predicate, documents }) => {
|
|
412
|
+
try {
|
|
413
|
+
const handle = db.openTable(table);
|
|
414
|
+
const rows = await embedRows(handle, documents);
|
|
415
|
+
const stats = handle.update(predicate, rows);
|
|
416
|
+
return ok({ table, predicate, ...stats });
|
|
417
|
+
}
|
|
418
|
+
catch (err) {
|
|
419
|
+
return fail(`update_documents failed: ${err.message}`);
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
server.registerTool("infino_delete_documents", {
|
|
423
|
+
title: "Delete documents from an Infino table",
|
|
424
|
+
description: "Delete the rows matching a SQL predicate, e.g. \"status = 'spam'\". Returns how many rows matched and were " +
|
|
425
|
+
"removed. Requires durable storage (not memory://). Available only because INFINO_MCP_ENABLE_WRITES is set.",
|
|
426
|
+
inputSchema: {
|
|
427
|
+
table: z.string().describe("Table to delete from."),
|
|
428
|
+
predicate: z
|
|
429
|
+
.string()
|
|
430
|
+
.describe("SQL predicate selecting the rows to delete, e.g. \"status = 'spam'\"."),
|
|
431
|
+
},
|
|
432
|
+
}, async ({ table, predicate }) => {
|
|
433
|
+
try {
|
|
434
|
+
const stats = db.openTable(table).delete(predicate);
|
|
435
|
+
return ok({ table, predicate, ...stats });
|
|
436
|
+
}
|
|
437
|
+
catch (err) {
|
|
438
|
+
return fail(`delete_documents failed: ${err.message}`);
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
// --- transport -------------------------------------------------------------
|
|
443
|
+
// stdio for desktop/CLI clients (Claude Desktop/Code, Cursor). Logs go to
|
|
444
|
+
// stderr so they never corrupt the JSON-RPC stream on stdout.
|
|
445
|
+
const transport = new StdioServerTransport();
|
|
446
|
+
await server.connect(transport);
|
|
447
|
+
console.error(`infino MCP server ready on stdio (uri: ${uri}, writes: ${writesEnabled ? "on" : "off"}, embedder: ${embedderInfo()})`);
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@infino-ai/mcp-server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for Infino — keyword, vector, and SQL retrieval over data on object storage, for AI agents.",
|
|
5
|
+
"mcpName": "io.github.infino-ai/mcp-server",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"infino-mcp": "dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"watch": "tsc --watch",
|
|
24
|
+
"start": "node dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@huggingface/transformers": "^4.2.0",
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
29
|
+
"@infino-ai/infino": "^0.1.0",
|
|
30
|
+
"zod": "^3.23.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^20",
|
|
34
|
+
"typescript": "^5"
|
|
35
|
+
}
|
|
36
|
+
}
|