@functional-systems/lambdadb-mcp 0.1.3-dev.10 → 0.1.3-dev.11

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - Pin the stable LambdaDB SDK to 0.8.0; expose Bayesian candidate budgets and
6
+ native embedding configuration in MCP guidance while preserving free-form
7
+ queries, SDK/server validation, rerank defaults, errors and response metadata.
8
+ - Retain legacy `managedEmbedding: true` and existing tool names/inputs. Native
9
+ embedding-only requests require a supporting server; no defaults are promoted.
10
+ - Add Bayesian/native contract tests, installed-package coverage, practical MCP
11
+ examples and an opt-in live suite with verified temporary-collection cleanup.
12
+
5
13
  ## [0.1.2] - 2026-10-04
6
14
 
7
15
  - Pin the LambdaDB TypeScript SDK to 0.7.0 and expose all 49 fixed lowercase
package/README.md CHANGED
@@ -103,8 +103,8 @@ Optional write tools:
103
103
 
104
104
  ## API contract and tool inputs
105
105
 
106
- The LambdaDB SDK is pinned to `@functional-systems/lambdadb@0.7.0`, checked against
107
- the published package and [v0.7.0 release](https://github.com/lambdadb/lambdadb-typescript-client/releases/tag/v0.7.0).
106
+ The LambdaDB SDK is pinned to `@functional-systems/lambdadb@0.8.0`, checked against
107
+ the published package and [v0.8.0 release](https://github.com/lambdadb/lambdadb-typescript-client/releases/tag/v0.8.0).
108
108
  This dependency update applies to builds containing this change. Publishing the SDK
109
109
  alone does not update previously published or installed MCP packages.
110
110
 
@@ -174,6 +174,114 @@ This MCP update does not migrate existing Collections or indexes. Partial update
174
174
  segment merging, and old Tags do not upgrade old indexes. If migration is needed,
175
175
  plan and authorize reinsertion into a new Collection separately.
176
176
 
177
+ ### Bayesian hybrid search
178
+
179
+ Arguments for `lambdadb_query_collection` using an existing two-dimensional
180
+ caller-provided vector field `embedding` and text field `body`:
181
+
182
+ ```json
183
+ {
184
+ "collectionName": "articles",
185
+ "query": {
186
+ "bayesian": [
187
+ { "queryString": { "query": "body:restore" } },
188
+ { "knn": { "field": "embedding", "queryVector": [1, 0], "k": 30 } }
189
+ ]
190
+ },
191
+ "size": 10,
192
+ "candidateSize": 30
193
+ }
194
+ ```
195
+
196
+ Bayesian requires exactly two signals. Boolean subqueries may combine clauses
197
+ within a signal, but explicit boosts (even `1`) on either signal or its Boolean
198
+ descendants and nested rank-fusion queries are unsupported. Do not supply fusion
199
+ weights. Without rerank, top-level `candidateSize` is required and must satisfy
200
+ `1 <= size <= candidateSize <= 100`; omitted `size` retains the server default of
201
+ 10. The budget is per signal, independent of final output size and `knn.k`.
202
+
203
+ With rerank, omit top-level `candidateSize` and use `rerank.candidateSize`:
204
+
205
+ ```json
206
+ {
207
+ "collectionName": "articles",
208
+ "query": {
209
+ "bayesian": [
210
+ { "queryString": { "query": "body:restore" } },
211
+ { "knn": { "field": "embedding", "queryVector": [1, 0], "k": 30 } }
212
+ ]
213
+ },
214
+ "size": 10,
215
+ "rerank": {
216
+ "provider": "typesafe",
217
+ "model": "jev-1.13.0",
218
+ "queryText": "How do I restore a previous version?",
219
+ "fields": ["body"],
220
+ "candidateSize": 30
221
+ }
222
+ }
223
+ ```
224
+
225
+ Omitted/null `rerank.candidateSize` retains `max(50, size)`; omitted/null `rerank`
226
+ requires the top-level Bayesian budget. Ordinary text/KNN/RRF/Min-Max/L2 queries
227
+ must omit top-level `candidateSize`. MCP preserves free-form queries, passes
228
+ integer candidate budgets unchanged, and leaves Bayesian structure, bounds and
229
+ cross-field validation to the server, retaining service errors. No query defaults,
230
+ weights or candidate counts are inserted by MCP. Bayesian scores are heuristic
231
+ fusion scores; applied reranking preserves them in `retrievalScore` and retains
232
+ all rerank status metadata, including through SDK-managed `docsUrl` downloads.
233
+
234
+ The [Bayesian contract](https://github.com/lambdadb/lambdadb-typescript-client/blob/v0.8.0/docs/bayesian-search.md)
235
+ and native embedding additions below are pinned to backend
236
+ `9072a1bc8925954369a887f558f1eaf387b7ea0e`. A source pin does not establish deployment
237
+ in another environment. Existing fusion methods and tool names remain unchanged.
238
+
239
+ ### Native embedding configuration
240
+
241
+ With write tools enabled, call `lambdadb_create_collection` with:
242
+
243
+ ```json
244
+ {
245
+ "collectionName": "native-articles",
246
+ "indexConfigs": {
247
+ "body": { "type": "text" },
248
+ "embedding": {
249
+ "type": "vector",
250
+ "embedding": {
251
+ "provider": "openai",
252
+ "model": "text-embedding-3-small",
253
+ "sourceField": "body",
254
+ "dimensions": 512,
255
+ "similarity": "cosine"
256
+ }
257
+ }
258
+ }
259
+ }
260
+ ```
261
+
262
+ Then call `lambdadb_upsert_docs` with
263
+ `{"collectionName":"native-articles","docs":[{"id":"one","body":"Restore a saved version."}]}`.
264
+ The source must be a text field; omit the generated vector from documents.
265
+ Use `knn.queryText` instead of `queryVector` for this field, including in either
266
+ Bayesian example above. For example, call `lambdadb_query_collection` with:
267
+
268
+ ```json
269
+ {
270
+ "collectionName": "native-articles",
271
+ "query": { "knn": { "field": "embedding", "queryText": "Restore a version", "k": 30 } },
272
+ "size": 10
273
+ }
274
+ ```
275
+
276
+ Native dimensions and similarity are optional and belong inside `embedding`.
277
+ MCP does not infer a flag, provider, model or native dimensions/similarity default.
278
+ The SDK rejects `managedEmbedding: false` with `embedding`, and native embedding
279
+ with top-level dimensions/similarity. Caller-provided vectors continue to use
280
+ top-level dimensions/similarity. Free-form nested object configurations retain
281
+ server validation. For older servers, explicitly add `managedEmbedding: true`
282
+ beside `type`; it is preserved. Normalized collection metadata may still contain
283
+ that true flag. See the [native embedding contract](https://github.com/lambdadb/lambdadb-typescript-client/blob/v0.8.0/docs/native-embeddings.md).
284
+
177
285
  ### Optional managed reranking
178
286
 
179
287
  `lambdadb_query_collection` accepts per-query `rerank`; omission or `null`
@@ -205,7 +313,7 @@ Optional `criteria` replaces the default with 2–10 distinct nonblank descripti
205
313
  ordered from lowest to highest relevance (2 KiB each, 8 KiB total UTF-8).
206
314
  Omitted/null criteria uses defaults; text, order, nulls and omission are preserved.
207
315
 
208
- Final `size`, vector-leg `knn.k`, and merged `candidateSize` are separate.
316
+ Final `size`, vector-leg `knn.k`, and merged `rerank.candidateSize` are separate.
209
317
  Require `1 <= size <= candidateSize <= 100`; omitted/null candidateSize defaults
210
318
  on the server to `max(50, size)`, with final size defaulting to 10. MCP never
211
319
  increases `k`. Reranking requires a scoring retrieval query, forbids `sort`,
@@ -294,7 +402,9 @@ MCP JSON Schema and actual tool-to-SDK HTTP path, including match-all, facet-onl
294
402
  document+facet, omitted/null/default bucket options, boundaries, invalid requests,
295
403
  and all 49 analyzers. Rerank tests cover JSON Schema, request preservation,
296
404
  local bounds/UTF-8 rejection, score envelopes, skipped/fallback results and
297
- metadata downloads. They do not require credentials
405
+ metadata downloads. Bayesian tests cover untouched free-form requests, candidate
406
+ budgets, server errors, native/legacy configurations and contradictory inputs.
407
+ They do not require credentials
298
408
  or create remote collections. `test:package` additionally installs the actual
299
409
  tarball in a clean consumer directory and repeats the tool contracts over real
300
410
  stdio, checking version identity, config errors, stdout and process termination.
@@ -340,9 +450,23 @@ Cleanup deletes the collection and verifies its absence even after a failed chec
340
450
  It does not assert fixed model scores or relevance rankings, and a fallback result
341
451
  does not pass as applied inference. Provider failures remain fixture tests; this
342
452
  suite does not deliberately induce failures or verify search quality, load,
343
- production deployment or billing readiness. Both live suites are outside default
453
+ production deployment or billing readiness. These live suites are outside default
344
454
  checks and credential-free CI.
345
455
 
456
+ Bayesian/native embedding verification also requires explicit managed inference
457
+ opt-in for OpenAI embeddings and TypeSafe reranking:
458
+
459
+ ```bash
460
+ LAMBDADB_RUN_LIVE_TESTS=1 LAMBDADB_RUN_LIVE_RERANK_TESTS=1 LAMBDADB_LIVE_CONFIRM_PROJECT=YOUR_DEV_PROJECT npm run test:live:bayesian
461
+ ```
462
+
463
+ This suite creates one owned collection with native, legacy and caller-provided
464
+ vector fields. It checks real embedding generation and text queries, Bayesian
465
+ budgets and server rejections, existing fusion methods, applied reranking with
466
+ retrieval scores and actual docsUrl hydration, then deletes and verifies absence.
467
+ These live suites are outside default checks and credential-free CI. Verify the
468
+ target's deployment provenance before running; the source pin alone is insufficient.
469
+
346
470
  If the environment file is outside the worktree:
347
471
 
348
472
  ```bash
@@ -68,7 +68,7 @@ export function registerReadTools(server, config) {
68
68
  });
69
69
  server.registerTool("lambdadb_query_collection", {
70
70
  title: "Query Collection",
71
- description: "Search documents with optional managed reranking and keyword facet counts across all matches. Omit query for match-all; size: 0 requires facets and forbids reranking. Reranking requires a scoring query and forbids sort; it does not enable vector/hybrid facets. Applied envelope score is an evaluation score, retrievalScore preserves search score, and rerank metadata reports status. Features require a supporting server; facets require newly built keyword indexes.",
71
+ description: "Search documents with optional Bayesian hybrid search, managed reranking and keyword facet counts across all matches. Omit query for match-all; size: 0 requires facets and forbids reranking. Reranking requires a scoring query and forbids sort; it does not enable vector/hybrid facets. Applied envelope score is an evaluation score, retrievalScore preserves search score, and rerank metadata reports status. Features require a supporting server; facets require newly built keyword indexes.",
72
72
  annotations: {
73
73
  readOnlyHint: true,
74
74
  openWorldHint: false
@@ -77,7 +77,9 @@ export function registerReadTools(server, config) {
77
77
  collectionName: nameSchema,
78
78
  size: z.number().int().min(0).max(100).optional()
79
79
  .describe("Documents to return (1–100), or 0 with nonempty facets."),
80
- query: z.record(z.string(), z.any()).optional().describe("Omit for match-all."),
80
+ // Preserve SDK/server validation and error classification for free-form queries.
81
+ candidateSize: z.number().int().optional().describe("Bayesian without rerank requires 1 <= size <= candidateSize <= 100 (size defaults to 10 on the server). With rerank, omit this field and use rerank.candidateSize, whose default is unchanged. Unsupported for other queries; server validates these combinations."),
82
+ query: z.record(z.string(), z.any()).optional().describe("Free-form query; omit for match-all. Top-level bayesian is an array of exactly two subqueries, with no explicit boosts on either subquery or its Boolean descendants. Nested rank fusion and fusion weights are unsupported. Server validates the query contract."),
81
83
  facets: facetsSchema.optional(),
82
84
  rerank: rerankSchema,
83
85
  ref: readRefSchema.optional(),
@@ -105,7 +107,7 @@ export function registerReadTools(server, config) {
105
107
  }
106
108
  }]
107
109
  })
108
- }, async ({ collectionName, size, query, facets, rerank, ref, consistentRead, includeVectors, sort, fields, partitionFilter }) => {
110
+ }, async ({ collectionName, size, candidateSize, query, facets, rerank, ref, consistentRead, includeVectors, sort, fields, partitionFilter }) => {
109
111
  try {
110
112
  const client = createLambdaDBClient(config);
111
113
  const input = {
@@ -113,6 +115,7 @@ export function registerReadTools(server, config) {
113
115
  facets,
114
116
  rerank,
115
117
  size,
118
+ candidateSize,
116
119
  ...readOptions(ref, consistentRead),
117
120
  includeVectors,
118
121
  sort,
@@ -6,13 +6,13 @@ import { jsonResult, nameSchema, partitionFilterSchema } from "./shared.js";
6
6
  export function registerWriteTools(server, config) {
7
7
  server.registerTool("lambdadb_create_collection", {
8
8
  title: "Create Collection",
9
- description: `Create a new collection in the configured project. Fixed lowercase text analyzer presets: ${Object.values(Analyzer).join(", ")}. Omitted analyzers uses standard; custom pipelines/options are unsupported. The keyword text analyzer is distinct from the keyword field type. Keyword indexes built on a supporting server support facets.`,
9
+ description: `Create a new collection in the configured project. Fixed lowercase text analyzer presets: ${Object.values(Analyzer).join(", ")}. Omitted analyzers uses standard; custom pipelines/options are unsupported. The keyword text analyzer is distinct from the keyword field type. Keyword indexes built on a supporting server support facets. Native vector fields accept embedding without managedEmbedding; explicit managedEmbedding: true remains supported for older servers.`,
10
10
  annotations: {
11
11
  openWorldHint: false
12
12
  },
13
13
  inputSchema: z.strictObject({
14
14
  collectionName: nameSchema,
15
- indexConfigs: z.record(z.string(), z.any()).refine((value) => Object.keys(value).length > 0, "indexConfigs must contain at least one field."),
15
+ indexConfigs: z.record(z.string(), z.any()).refine((value) => Object.keys(value).length > 0, "indexConfigs must contain at least one field.").describe("Field configurations validated by the SDK/server. Native vectors: {type: 'vector', embedding: {provider, model, sourceField, dimensions?, similarity?}}; declare sourceField as text. Native dimensions/similarity belong inside embedding, never at the field top level. Do not combine embedding with managedEmbedding: false. Legacy true is preserved; no provider/model or native defaults are inferred. Caller-provided vectors retain top-level dimensions/similarity."),
16
16
  description: z.string().max(255).optional(),
17
17
  tags: z.record(z.string().regex(/^[A-Za-z0-9_.-]{1,63}$/), z.string().min(1).max(127).regex(/^[^:#,]+$/))
18
18
  .refine((value) => Object.keys(value).length <= 5, "At most five tags are allowed.")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functional-systems/lambdadb-mcp",
3
- "version": "0.1.3-dev.10",
3
+ "version": "0.1.3-dev.11",
4
4
  "private": false,
5
5
  "description": "MCP server for LambdaDB data plane",
6
6
  "type": "module",
@@ -11,6 +11,7 @@
11
11
  "build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.json && node -e \"require('node:fs').chmodSync('dist/index.js', 0o755)\"",
12
12
  "check": "npm run check:version && npm run typecheck && npm test",
13
13
  "test": "npm run build && node --test test/*.test.mjs",
14
+ "test:live:bayesian": "npm run build && bash ./scripts/with-env.sh --test test/integration/bayesian-live.test.mjs",
14
15
  "test:live:rerank": "npm run build && bash ./scripts/with-env.sh --test test/integration/rerank-live.test.mjs",
15
16
  "test:live": "npm run build && bash ./scripts/with-env.sh --test test/integration/live.test.mjs",
16
17
  "dev": "tsx watch src/index.ts",
@@ -23,7 +24,7 @@
23
24
  "test:package": "node scripts/test-package.mjs"
24
25
  },
25
26
  "dependencies": {
26
- "@functional-systems/lambdadb": "0.7.0",
27
+ "@functional-systems/lambdadb": "0.8.0",
27
28
  "@modelcontextprotocol/sdk": "1.29.0",
28
29
  "zod": "^4.1.12"
29
30
  },
@@ -61,5 +62,5 @@
61
62
  "access": "public",
62
63
  "registry": "https://registry.npmjs.org"
63
64
  },
64
- "gitHead": "df4be52ea47726f4d3d82a99b3ee2a755139c1f9"
65
+ "gitHead": "bd1ae5547f868991a22c92b5a07849edfcf696fb"
65
66
  }