@cyanheads/brapi-mcp-server 0.4.14 → 0.5.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.
Files changed (115) hide show
  1. package/CLAUDE.md +23 -19
  2. package/README.md +40 -26
  3. package/changelog/0.5.x/0.5.0.md +59 -0
  4. package/dist/config/builtin-aliases.d.ts +1 -1
  5. package/dist/config/builtin-aliases.js +1 -1
  6. package/dist/config/server-config.d.ts +3 -3
  7. package/dist/config/server-config.d.ts.map +1 -1
  8. package/dist/config/server-config.js +13 -13
  9. package/dist/config/server-config.js.map +1 -1
  10. package/dist/index.js +62 -15
  11. package/dist/index.js.map +1 -1
  12. package/dist/mcp-server/prompts/definitions/brapi-eda-study.prompt.js +1 -1
  13. package/dist/mcp-server/prompts/definitions/brapi-eda-study.prompt.js.map +1 -1
  14. package/dist/mcp-server/prompts/definitions/brapi-meta-analysis.prompt.js +3 -3
  15. package/dist/mcp-server/prompts/definitions/brapi-meta-analysis.prompt.js.map +1 -1
  16. package/dist/mcp-server/tools/definitions/brapi-dataframe-describe.tool.d.ts +8 -11
  17. package/dist/mcp-server/tools/definitions/brapi-dataframe-describe.tool.d.ts.map +1 -1
  18. package/dist/mcp-server/tools/definitions/brapi-dataframe-describe.tool.js +15 -25
  19. package/dist/mcp-server/tools/definitions/brapi-dataframe-describe.tool.js.map +1 -1
  20. package/dist/mcp-server/tools/definitions/brapi-dataframe-drop.tool.d.ts +6 -10
  21. package/dist/mcp-server/tools/definitions/brapi-dataframe-drop.tool.d.ts.map +1 -1
  22. package/dist/mcp-server/tools/definitions/brapi-dataframe-drop.tool.js +6 -16
  23. package/dist/mcp-server/tools/definitions/brapi-dataframe-drop.tool.js.map +1 -1
  24. package/dist/mcp-server/tools/definitions/brapi-dataframe-export.tool.d.ts +69 -0
  25. package/dist/mcp-server/tools/definitions/brapi-dataframe-export.tool.d.ts.map +1 -0
  26. package/dist/mcp-server/tools/definitions/brapi-dataframe-export.tool.js +233 -0
  27. package/dist/mcp-server/tools/definitions/brapi-dataframe-export.tool.js.map +1 -0
  28. package/dist/mcp-server/tools/definitions/brapi-dataframe-query.tool.d.ts +19 -11
  29. package/dist/mcp-server/tools/definitions/brapi-dataframe-query.tool.d.ts.map +1 -1
  30. package/dist/mcp-server/tools/definitions/brapi-dataframe-query.tool.js +80 -28
  31. package/dist/mcp-server/tools/definitions/brapi-dataframe-query.tool.js.map +1 -1
  32. package/dist/mcp-server/tools/definitions/brapi-find-genotype-calls.tool.d.ts +4 -6
  33. package/dist/mcp-server/tools/definitions/brapi-find-genotype-calls.tool.d.ts.map +1 -1
  34. package/dist/mcp-server/tools/definitions/brapi-find-genotype-calls.tool.js +28 -36
  35. package/dist/mcp-server/tools/definitions/brapi-find-genotype-calls.tool.js.map +1 -1
  36. package/dist/mcp-server/tools/definitions/brapi-find-germplasm.tool.d.ts +3 -5
  37. package/dist/mcp-server/tools/definitions/brapi-find-germplasm.tool.d.ts.map +1 -1
  38. package/dist/mcp-server/tools/definitions/brapi-find-germplasm.tool.js +19 -19
  39. package/dist/mcp-server/tools/definitions/brapi-find-germplasm.tool.js.map +1 -1
  40. package/dist/mcp-server/tools/definitions/brapi-find-images.tool.d.ts +4 -6
  41. package/dist/mcp-server/tools/definitions/brapi-find-images.tool.d.ts.map +1 -1
  42. package/dist/mcp-server/tools/definitions/brapi-find-images.tool.js +16 -16
  43. package/dist/mcp-server/tools/definitions/brapi-find-images.tool.js.map +1 -1
  44. package/dist/mcp-server/tools/definitions/brapi-find-locations.tool.d.ts +3 -5
  45. package/dist/mcp-server/tools/definitions/brapi-find-locations.tool.d.ts.map +1 -1
  46. package/dist/mcp-server/tools/definitions/brapi-find-locations.tool.js +15 -15
  47. package/dist/mcp-server/tools/definitions/brapi-find-locations.tool.js.map +1 -1
  48. package/dist/mcp-server/tools/definitions/brapi-find-observations.tool.d.ts +4 -6
  49. package/dist/mcp-server/tools/definitions/brapi-find-observations.tool.d.ts.map +1 -1
  50. package/dist/mcp-server/tools/definitions/brapi-find-observations.tool.js +17 -17
  51. package/dist/mcp-server/tools/definitions/brapi-find-observations.tool.js.map +1 -1
  52. package/dist/mcp-server/tools/definitions/brapi-find-studies.tool.d.ts +4 -6
  53. package/dist/mcp-server/tools/definitions/brapi-find-studies.tool.d.ts.map +1 -1
  54. package/dist/mcp-server/tools/definitions/brapi-find-studies.tool.js +17 -17
  55. package/dist/mcp-server/tools/definitions/brapi-find-studies.tool.js.map +1 -1
  56. package/dist/mcp-server/tools/definitions/brapi-find-variables.tool.d.ts +2 -4
  57. package/dist/mcp-server/tools/definitions/brapi-find-variables.tool.d.ts.map +1 -1
  58. package/dist/mcp-server/tools/definitions/brapi-find-variables.tool.js +17 -17
  59. package/dist/mcp-server/tools/definitions/brapi-find-variables.tool.js.map +1 -1
  60. package/dist/mcp-server/tools/definitions/brapi-find-variants.tool.d.ts +3 -5
  61. package/dist/mcp-server/tools/definitions/brapi-find-variants.tool.d.ts.map +1 -1
  62. package/dist/mcp-server/tools/definitions/brapi-find-variants.tool.js +15 -15
  63. package/dist/mcp-server/tools/definitions/brapi-find-variants.tool.js.map +1 -1
  64. package/dist/mcp-server/tools/definitions/brapi-raw-get.tool.d.ts +17 -2
  65. package/dist/mcp-server/tools/definitions/brapi-raw-get.tool.d.ts.map +1 -1
  66. package/dist/mcp-server/tools/definitions/brapi-raw-get.tool.js +51 -7
  67. package/dist/mcp-server/tools/definitions/brapi-raw-get.tool.js.map +1 -1
  68. package/dist/mcp-server/tools/definitions/brapi-raw-search.tool.d.ts +16 -2
  69. package/dist/mcp-server/tools/definitions/brapi-raw-search.tool.d.ts.map +1 -1
  70. package/dist/mcp-server/tools/definitions/brapi-raw-search.tool.js +51 -5
  71. package/dist/mcp-server/tools/definitions/brapi-raw-search.tool.js.map +1 -1
  72. package/dist/mcp-server/tools/definitions/index.d.ts +141 -165
  73. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
  74. package/dist/mcp-server/tools/definitions/index.js +28 -17
  75. package/dist/mcp-server/tools/definitions/index.js.map +1 -1
  76. package/dist/mcp-server/tools/shared/find-helpers.d.ts +52 -41
  77. package/dist/mcp-server/tools/shared/find-helpers.d.ts.map +1 -1
  78. package/dist/mcp-server/tools/shared/find-helpers.js +89 -66
  79. package/dist/mcp-server/tools/shared/find-helpers.js.map +1 -1
  80. package/dist/mcp-server/tools/shared/raw-routing-hints.d.ts.map +1 -1
  81. package/dist/mcp-server/tools/shared/raw-routing-hints.js +6 -6
  82. package/dist/mcp-server/tools/shared/raw-routing-hints.js.map +1 -1
  83. package/dist/services/canvas-bridge/canvas-bridge.d.ts +69 -44
  84. package/dist/services/canvas-bridge/canvas-bridge.d.ts.map +1 -1
  85. package/dist/services/canvas-bridge/canvas-bridge.js +143 -112
  86. package/dist/services/canvas-bridge/canvas-bridge.js.map +1 -1
  87. package/dist/services/canvas-bridge/index.d.ts +1 -1
  88. package/dist/services/canvas-bridge/index.d.ts.map +1 -1
  89. package/dist/services/canvas-bridge/index.js +1 -1
  90. package/dist/services/canvas-bridge/index.js.map +1 -1
  91. package/dist/services/canvas-bridge/types.d.ts +11 -12
  92. package/dist/services/canvas-bridge/types.d.ts.map +1 -1
  93. package/dist/services/canvas-bridge/types.js +4 -4
  94. package/package.json +3 -11
  95. package/server.json +3 -3
  96. package/dist/mcp-server/resources/definitions/brapi-dataset.resource.d.ts +0 -13
  97. package/dist/mcp-server/resources/definitions/brapi-dataset.resource.d.ts.map +0 -1
  98. package/dist/mcp-server/resources/definitions/brapi-dataset.resource.js +0 -26
  99. package/dist/mcp-server/resources/definitions/brapi-dataset.resource.js.map +0 -1
  100. package/dist/mcp-server/tools/definitions/brapi-manage-dataset.tool.d.ts +0 -89
  101. package/dist/mcp-server/tools/definitions/brapi-manage-dataset.tool.d.ts.map +0 -1
  102. package/dist/mcp-server/tools/definitions/brapi-manage-dataset.tool.js +0 -306
  103. package/dist/mcp-server/tools/definitions/brapi-manage-dataset.tool.js.map +0 -1
  104. package/dist/services/dataset-store/dataset-store.d.ts +0 -44
  105. package/dist/services/dataset-store/dataset-store.d.ts.map +0 -1
  106. package/dist/services/dataset-store/dataset-store.js +0 -208
  107. package/dist/services/dataset-store/dataset-store.js.map +0 -1
  108. package/dist/services/dataset-store/index.d.ts +0 -8
  109. package/dist/services/dataset-store/index.d.ts.map +0 -1
  110. package/dist/services/dataset-store/index.js +0 -7
  111. package/dist/services/dataset-store/index.js.map +0 -1
  112. package/dist/services/dataset-store/types.d.ts +0 -72
  113. package/dist/services/dataset-store/types.d.ts.map +0 -1
  114. package/dist/services/dataset-store/types.js +0 -8
  115. package/dist/services/dataset-store/types.js.map +0 -1
@@ -2,8 +2,8 @@
2
2
  * @fileoverview Shared building blocks for `find_*` tools — Zod fragments for
3
3
  * common inputs (alias, loadLimit, extraFilters), utilities to merge named
4
4
  * filters with the passthrough map, a generic distribution aggregator, and
5
- * the dataset-spillover handler that turns a "too many rows" result into a
6
- * DatasetStore handle.
5
+ * the spillover handler that turns a "too many rows" result into a canvas
6
+ * dataframe handle.
7
7
  *
8
8
  * @module mcp-server/tools/shared/find-helpers
9
9
  */
@@ -11,14 +11,14 @@ import { type Context, type HandlerContext, z } from '@cyanheads/mcp-ts-core';
11
11
  import type { ServerConfig } from '../../../config/server-config.js';
12
12
  import type { BrapiClient, BrapiEnvelope, BrapiPagination, BrapiRequestOptions, ResolvedAuth } from '../../../services/brapi-client/index.js';
13
13
  import type { BrapiDialect } from '../../../services/brapi-dialect/index.js';
14
+ import type { CanvasBridge, RegisterDataframeResult } from '../../../services/canvas-bridge/index.js';
14
15
  import type { CapabilityProfile } from '../../../services/capability-registry/types.js';
15
- import type { DatasetMetadata, DatasetStore } from '../../../services/dataset-store/index.js';
16
16
  import type { RegisteredServer } from '../../../services/server-registry/index.js';
17
17
  /** True when the thrown value is an upstream 404 surfaced by the BrAPI client. */
18
18
  export declare function isUpstreamNotFound(err: unknown): boolean;
19
- /** Upper cap on how many rows we'll pull for DatasetStore spillover per call. */
19
+ /** Upper cap on how many rows we'll pull for canvas dataframe spillover per call. */
20
20
  export declare const MAX_SPILLOVER_ROWS = 50000;
21
- /** Hard cap on how many BrAPI pages we'll traverse when building a dataset. */
21
+ /** Hard cap on how many BrAPI pages we'll traverse when building a dataframe. */
22
22
  export declare const MAX_SPILLOVER_PAGES = 50;
23
23
  export declare const AliasInput: z.ZodOptional<z.ZodString>;
24
24
  export declare const LoadLimitInput: z.ZodOptional<z.ZodNumber>;
@@ -90,18 +90,18 @@ export declare function companionRequestOptions(connection: RegisteredServer, di
90
90
  */
91
91
  export declare function computeDistribution<T>(rows: readonly T[], accessor: (row: T) => string | readonly string[] | undefined | null): Record<string, number>;
92
92
  /**
93
- * Render the standardized header line for `find_*` tools. When a dataset
94
- * spillover is present, surfaces the dataset row count alongside the
93
+ * Render the standardized header line for `find_*` tools. When a dataframe
94
+ * spillover is present, surfaces the dataframe row count alongside the
95
95
  * in-context count and the upstream total — `{returned} of {total}` alone
96
96
  * hides the middle number and confuses readers when filters miss server-
97
- * side and the dataset row count diverges from both.
97
+ * side and the dataframe row count diverges from both.
98
98
  */
99
99
  export declare function renderFindHeader(opts: {
100
100
  noun: string;
101
101
  alias: string;
102
102
  returnedCount: number;
103
103
  totalCount: number;
104
- dataset?: {
104
+ dataframe?: {
105
105
  rowCount: number;
106
106
  expiresAt?: string;
107
107
  } | undefined;
@@ -127,12 +127,13 @@ export interface LoadedRows<T> {
127
127
  /**
128
128
  * Pull rows up to `loadLimit` on a single page. If the server reports more
129
129
  * rows than the limit, leave the rest behind — callers decide whether to
130
- * spill via `spillToDataset`.
130
+ * spill via `spillToCanvas`.
131
131
  */
132
132
  export declare function loadInitialPage<T>(client: BrapiClient, connection: RegisteredServer, path: string, filters: Record<string, unknown>, loadLimit: number, ctx: Context): Promise<LoadedRows<T>>;
133
133
  /** Pull the first page for either a GET list endpoint or POST /search route. */
134
134
  export declare function loadInitialFindPage<T>(client: BrapiClient, connection: RegisteredServer, route: FindRoute, loadLimit: number, ctx: Context): Promise<LoadedRows<T>>;
135
135
  export interface SpillInput<T> {
136
+ bridge: CanvasBridge;
136
137
  client: BrapiClient;
137
138
  connection: RegisteredServer;
138
139
  ctx: Context;
@@ -147,8 +148,8 @@ export interface SpillInput<T> {
147
148
  route?: FindRoute;
148
149
  /**
149
150
  * Optional client-side predicate applied to every row (first-page + spilled)
150
- * before persistence. When present, only rows that pass are persisted to
151
- * DatasetStore and returned in `fullRows`. The unfiltered upstream total is
151
+ * before persistence. When present, only rows that pass are registered on
152
+ * the canvas and returned in `fullRows`. The unfiltered upstream total is
152
153
  * preserved separately on the LoadedRows envelope so distributions and
153
154
  * headers can still report the true upstream size.
154
155
  */
@@ -157,54 +158,53 @@ export interface SpillInput<T> {
157
158
  * Optional client-side transform applied to every row (first-page + spilled)
158
159
  * before any predicate filter runs. Used to normalize sparse / duplicated
159
160
  * upstream payloads (e.g. dedup'ing CassavaBase's 11×-repeated synonym
160
- * arrays) so the in-context view, the persisted dataset, and the canvas
161
- * dataframe all see the same cleaned shape. Runs before `rowFilter`.
161
+ * arrays) so the in-context view and the canvas dataframe see the same
162
+ * cleaned shape. Runs before `rowFilter`.
162
163
  */
163
164
  rowMapper?: (row: T) => T;
164
165
  source: string;
165
- store: DatasetStore;
166
166
  /** Total reported by the server on the first page. */
167
167
  totalCount: number;
168
168
  }
169
169
  export interface SpillResult<T> {
170
- dataset: DatasetMetadata;
171
- /** Rows that were persisted (post-filter when `rowFilter` was supplied). */
170
+ dataframe: RegisterDataframeResult;
171
+ /** Rows that were registered (post-filter when `rowFilter` was supplied). */
172
172
  fullRows: T[];
173
173
  pagesFetched: number;
174
174
  }
175
175
  /**
176
- * Shape of the dataset handle returned inline by `find_*` tools. Drops the
177
- * provenance fields (source/baseUrl/query) since those are internal and
178
- * available via `brapi_manage_dataset summary`.
176
+ * Shape of the dataframe handle returned inline by `find_*` tools. The
177
+ * dataframe is the canvas table holding every row beyond `loadLimit`; query
178
+ * it with `brapi_dataframe_query` for SQL access or describe it with
179
+ * `brapi_dataframe_describe` for schema + provenance.
179
180
  */
180
- export declare const DatasetHandleSchema: z.ZodObject<{
181
- datasetId: z.ZodString;
181
+ export declare const DataframeHandleSchema: z.ZodObject<{
182
+ tableName: z.ZodString;
182
183
  rowCount: z.ZodNumber;
183
- sizeBytes: z.ZodNumber;
184
184
  columns: z.ZodArray<z.ZodString>;
185
185
  createdAt: z.ZodString;
186
186
  expiresAt: z.ZodString;
187
187
  truncated: z.ZodOptional<z.ZodBoolean>;
188
188
  maxRows: z.ZodOptional<z.ZodNumber>;
189
- dataframe: z.ZodOptional<z.ZodString>;
190
189
  }, z.core.$strip>;
191
- export type DatasetHandle = z.infer<typeof DatasetHandleSchema>;
190
+ export type DataframeHandle = z.infer<typeof DataframeHandleSchema>;
192
191
  /**
193
- * Render a DatasetHandle as bullet lines, matching the existing find_* tool
192
+ * Render a DataframeHandle as bullet lines, matching the existing find_* tool
194
193
  * format. Centralized so the truncated/maxRows fields surface consistently.
195
194
  * `expiresAt` is paired with a human-readable `expires in Xh / Xd` so the
196
195
  * agent doesn't have to subtract dates to know when the handle goes stale.
197
196
  */
198
- export declare function renderDatasetHandle(handle: DatasetHandle): string[];
197
+ export declare function renderDataframeHandle(handle: DataframeHandle): string[];
199
198
  /**
200
199
  * Render an absolute `expiresAt` timestamp as a relative human label
201
200
  * (`expires in 24h`, `expires in 30m`, `expired 5m ago`). Coarsens to the
202
201
  * most useful unit so the value reads at a glance.
203
202
  */
204
203
  export declare function formatExpiresIn(expiresAt: string, now?: Date): string;
205
- /** Project a `DatasetMetadata` to the in-context handle shape. */
206
- export declare function toDatasetHandle(metadata: DatasetMetadata): DatasetHandle;
204
+ /** Project a `RegisterDataframeResult` to the inline handle shape. */
205
+ export declare function toDataframeHandle(result: RegisterDataframeResult): DataframeHandle;
207
206
  export interface MaybeSpillInput<T> {
207
+ bridge: CanvasBridge;
208
208
  client: BrapiClient;
209
209
  connection: RegisteredServer;
210
210
  ctx: Context;
@@ -215,7 +215,7 @@ export interface MaybeSpillInput<T> {
215
215
  route?: FindRoute;
216
216
  /**
217
217
  * Optional client-side predicate applied to every row before persistence.
218
- * Forwarded to `spillToDataset`. When present and no spillover happens, the
218
+ * Forwarded to `spillToCanvas`. When present and no spillover happens, the
219
219
  * first-page rows are also filtered before being returned.
220
220
  */
221
221
  rowFilter?: (row: T) => boolean;
@@ -227,38 +227,49 @@ export interface MaybeSpillInput<T> {
227
227
  source: string;
228
228
  /**
229
229
  * Optional request overrides for spillover page pulls. Useful when a tool
230
- * wants dataset persistence to be best-effort under a tighter latency
231
- * budget than the first page.
230
+ * wants dataframe materialization to run under a tighter latency budget
231
+ * than the first page.
232
232
  */
233
233
  spillRequestOptions?: BrapiRequestOptions;
234
- store: DatasetStore;
235
234
  /** Optional warning sink. When supplied, spillover failures degrade to rows-only output. */
236
235
  warnings?: string[];
237
236
  }
238
237
  export interface MaybeSpillResult<T> {
239
- dataset?: DatasetHandle;
238
+ dataframe?: DataframeHandle;
240
239
  /** Row set after `rowFilter` (when supplied), spilled or first-page only. */
241
240
  fullRows: T[];
242
241
  }
243
242
  /**
244
- * Wrap `spillToDataset` with the "only spill when hasMore and totalCount >
243
+ * Wrap `spillToCanvas` with the "only spill when hasMore and totalCount >
245
244
  * loadLimit" guard that every `find_*` tool replicates. When no spillover is
246
- * needed, returns the first-page rows untouched. When it is, persists the
247
- * union to DatasetStore and returns both the full set and the handle.
245
+ * needed, returns the first-page rows untouched. When it is, materializes
246
+ * the union as a canvas dataframe and returns both the full set and the
247
+ * handle.
248
248
  */
249
249
  export declare function maybeSpill<T extends Record<string, unknown>>(input: MaybeSpillInput<T>): Promise<MaybeSpillResult<T>>;
250
250
  /**
251
- * Pull every remaining page up to MAX_SPILLOVER_* caps, then persist the
252
- * union to DatasetStore. Returns the dataset metadata plus the full row set
253
- * (so callers can compute honest distributions from the whole result).
251
+ * Pull every remaining page up to MAX_SPILLOVER_* caps, then materialize the
252
+ * union as a canvas dataframe. Returns the dataframe metadata plus the full
253
+ * row set (so callers can compute honest distributions from the whole result).
254
254
  */
255
- export declare function spillToDataset<T extends Record<string, unknown>>(input: SpillInput<T>): Promise<SpillResult<T>>;
255
+ export declare function spillToCanvas<T extends Record<string, unknown>>(input: SpillInput<T>): Promise<SpillResult<T>>;
256
256
  /** BrAPI list endpoints return `{data: T[], ...}`. Some omit the wrapper. */
257
257
  export interface BrapiListResult<T> {
258
258
  data?: T[];
259
259
  [key: string]: unknown;
260
260
  }
261
261
  export declare function extractRows<T>(result: BrapiListResult<T> | T[]): T[];
262
+ /**
263
+ * Extract a homogeneous record-row set from a raw BrAPI envelope `result`.
264
+ * Returns the array when `result` is itself a list of objects, or when
265
+ * `result.data` is — covering both bare-array and BrAPI-list-envelope shapes.
266
+ * Returns `null` for non-list shapes (single object, scalar, primitive
267
+ * arrays) so callers — notably `raw_get` / `raw_search` — can skip spillover
268
+ * and pass the upstream payload through unchanged. Empty arrays are list-
269
+ * shaped but carry no rows; the caller uses `length === 0` to decide whether
270
+ * to register a dataframe.
271
+ */
272
+ export declare function extractListRows<T extends Record<string, unknown>>(result: unknown): T[] | null;
262
273
  /** Return the input as a non-empty string, or undefined. Used in distribution accessors. */
263
274
  export declare function asString(value: unknown): string | undefined;
264
275
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"find-helpers.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/shared/find-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,cAAc,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,YAAY,EACb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,y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ACxC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IAAE,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAAO,GAC/C,gBAAgB,CAOlB;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACrD,OAAO,GAAE,qBAA0B,GAClC,MAAM,GAAG,SAAS,CAqBpB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,GAChC,MAAM,EAAE,CAQV;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,GAChC,IAAI,CAMN;AAED,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC"}
@@ -2,8 +2,8 @@
2
2
  * @fileoverview Shared building blocks for `find_*` tools — Zod fragments for
3
3
  * common inputs (alias, loadLimit, extraFilters), utilities to merge named
4
4
  * filters with the passthrough map, a generic distribution aggregator, and
5
- * the dataset-spillover handler that turns a "too many rows" result into a
6
- * DatasetStore handle.
5
+ * the spillover handler that turns a "too many rows" result into a canvas
6
+ * dataframe handle.
7
7
  *
8
8
  * @module mcp-server/tools/shared/find-helpers
9
9
  */
@@ -13,9 +13,9 @@ import { JsonRpcErrorCode, McpError, validationError } from '@cyanheads/mcp-ts-c
13
13
  export function isUpstreamNotFound(err) {
14
14
  return err instanceof McpError && err.code === JsonRpcErrorCode.NotFound;
15
15
  }
16
- /** Upper cap on how many rows we'll pull for DatasetStore spillover per call. */
16
+ /** Upper cap on how many rows we'll pull for canvas dataframe spillover per call. */
17
17
  export const MAX_SPILLOVER_ROWS = 50_000;
18
- /** Hard cap on how many BrAPI pages we'll traverse when building a dataset. */
18
+ /** Hard cap on how many BrAPI pages we'll traverse when building a dataframe. */
19
19
  export const MAX_SPILLOVER_PAGES = 50;
20
20
  export const AliasInput = z
21
21
  .string()
@@ -27,7 +27,7 @@ export const LoadLimitInput = z
27
27
  .int()
28
28
  .positive()
29
29
  .optional()
30
- .describe('Override the in-context row cap. Rows beyond the cap return as a dataset handle for paged follow-up.');
30
+ .describe('Cap on rows returned inline. Omit for the deployment default — sized so spillover reaches its full row-count ceiling. Rows beyond the cap land in a dataframe; query with brapi_dataframe_query (SQL) instead of paging row-by-row. Heads-up: this same value drives the upstream pageSize during spillover walks, so lowering it to "preview a smaller sample" also shrinks the dataframe ceiling proportionally — prefer SQL `LIMIT` on the dataframe for sampling instead.');
31
31
  export const ExtraFiltersInput = z
32
32
  .record(z.string(), z.unknown())
33
33
  .optional()
@@ -199,16 +199,18 @@ export function computeDistribution(rows, accessor) {
199
199
  return Object.fromEntries([...counts.entries()].sort(([, a], [, b]) => b - a));
200
200
  }
201
201
  /**
202
- * Render the standardized header line for `find_*` tools. When a dataset
203
- * spillover is present, surfaces the dataset row count alongside the
202
+ * Render the standardized header line for `find_*` tools. When a dataframe
203
+ * spillover is present, surfaces the dataframe row count alongside the
204
204
  * in-context count and the upstream total — `{returned} of {total}` alone
205
205
  * hides the middle number and confuses readers when filters miss server-
206
- * side and the dataset row count diverges from both.
206
+ * side and the dataframe row count diverges from both.
207
207
  */
208
208
  export function renderFindHeader(opts) {
209
- if (opts.dataset) {
210
- const expiry = opts.dataset.expiresAt ? ` (${formatExpiresIn(opts.dataset.expiresAt)})` : '';
211
- return `# ${opts.returnedCount} returned · ${opts.dataset.rowCount} in dataset${expiry} · ${opts.totalCount} total ${opts.noun} — \`${opts.alias}\``;
209
+ if (opts.dataframe) {
210
+ const expiry = opts.dataframe.expiresAt
211
+ ? ` (${formatExpiresIn(opts.dataframe.expiresAt)})`
212
+ : '';
213
+ return `# ${opts.returnedCount} returned · ${opts.dataframe.rowCount} in dataframe${expiry} · ${opts.totalCount} total ${opts.noun} — \`${opts.alias}\``;
212
214
  }
213
215
  return `# ${opts.returnedCount} of ${opts.totalCount} ${opts.noun} — \`${opts.alias}\``;
214
216
  }
@@ -249,7 +251,7 @@ export function renderDistributions(distributions) {
249
251
  /**
250
252
  * Pull rows up to `loadLimit` on a single page. If the server reports more
251
253
  * rows than the limit, leave the rest behind — callers decide whether to
252
- * spill via `spillToDataset`.
254
+ * spill via `spillToCanvas`.
253
255
  */
254
256
  export async function loadInitialPage(client, connection, path, filters, loadLimit, ctx) {
255
257
  return await loadInitialFindPage(client, connection, getRouteForPath(path, filters), loadLimit, ctx);
@@ -283,45 +285,48 @@ async function fetchFindRoutePage(client, connection, route, pageSize, page, ctx
283
285
  return await client.getSearchResults(connection.baseUrl, route.noun, response.searchResultsDbId, ctx, buildRequestOptions(connection, { pageSize, page }, requestOptions));
284
286
  }
285
287
  /**
286
- * Shape of the dataset handle returned inline by `find_*` tools. Drops the
287
- * provenance fields (source/baseUrl/query) since those are internal and
288
- * available via `brapi_manage_dataset summary`.
288
+ * Shape of the dataframe handle returned inline by `find_*` tools. The
289
+ * dataframe is the canvas table holding every row beyond `loadLimit`; query
290
+ * it with `brapi_dataframe_query` for SQL access or describe it with
291
+ * `brapi_dataframe_describe` for schema + provenance.
289
292
  */
290
- export const DatasetHandleSchema = z.object({
291
- datasetId: z.string().describe('Use with brapi_manage_dataset to page or export.'),
292
- rowCount: z.number().int().nonnegative().describe('Number of rows persisted in the dataset.'),
293
- sizeBytes: z.number().int().nonnegative().describe('Serialized size of the dataset in bytes.'),
293
+ export const DataframeHandleSchema = z.object({
294
+ tableName: z
295
+ .string()
296
+ .describe('Dataframe name. Use with brapi_dataframe_describe (schema + provenance) and brapi_dataframe_query (SQL).'),
297
+ rowCount: z
298
+ .number()
299
+ .int()
300
+ .nonnegative()
301
+ .describe('Number of rows materialized in the dataframe.'),
294
302
  columns: z
295
- .array(z.string().describe('Column name from the persisted rows.'))
296
- .describe('Full column list of the persisted rows.'),
297
- createdAt: z.string().describe('ISO 8601 timestamp the dataset was created.'),
298
- expiresAt: z.string().describe('ISO 8601 timestamp after which the dataset will be purged.'),
303
+ .array(z.string().describe('Column name from the materialized rows.'))
304
+ .describe('Full column list of the dataframe.'),
305
+ createdAt: z.string().describe('ISO 8601 timestamp the dataframe was created.'),
306
+ expiresAt: z
307
+ .string()
308
+ .describe('ISO 8601 timestamp after which the dataframe metadata will be purged. Re-run the find_* tool to refresh, or copy results out before expiry.'),
299
309
  truncated: z
300
310
  .boolean()
301
311
  .optional()
302
- .describe('True when the dataset hit a row cap before exhausting upstream.'),
312
+ .describe('True when the dataframe hit a row cap before exhausting upstream.'),
303
313
  maxRows: z
304
314
  .number()
305
315
  .int()
306
316
  .positive()
307
317
  .optional()
308
318
  .describe('Cap that was applied at create time, when truncation occurred.'),
309
- dataframe: z
310
- .string()
311
- .optional()
312
- .describe('Dataframe name when this dataset was auto-registered as a SQL-queryable dataframe. Use with brapi_dataframe_query to run SQL across the rows.'),
313
319
  });
314
320
  /**
315
- * Render a DatasetHandle as bullet lines, matching the existing find_* tool
321
+ * Render a DataframeHandle as bullet lines, matching the existing find_* tool
316
322
  * format. Centralized so the truncated/maxRows fields surface consistently.
317
323
  * `expiresAt` is paired with a human-readable `expires in Xh / Xd` so the
318
324
  * agent doesn't have to subtract dates to know when the handle goes stale.
319
325
  */
320
- export function renderDatasetHandle(handle) {
326
+ export function renderDataframeHandle(handle) {
321
327
  const lines = [
322
- `- datasetId: \`${handle.datasetId}\``,
328
+ `- tableName: \`${handle.tableName}\` (query via brapi_dataframe_query)`,
323
329
  `- rowCount: ${handle.rowCount}`,
324
- `- sizeBytes: ${handle.sizeBytes}`,
325
330
  `- columns: ${handle.columns.join(', ')}`,
326
331
  `- createdAt: ${handle.createdAt}`,
327
332
  `- expiresAt: ${handle.expiresAt} (${formatExpiresIn(handle.expiresAt)})`,
@@ -330,9 +335,6 @@ export function renderDatasetHandle(handle) {
330
335
  lines.push(`- truncated: true`);
331
336
  if (typeof handle.maxRows === 'number')
332
337
  lines.push(`- maxRows: ${handle.maxRows}`);
333
- if (handle.dataframe) {
334
- lines.push(`- dataframe: \`${handle.dataframe}\` (queryable via brapi_dataframe_query)`);
335
- }
336
338
  return lines;
337
339
  }
338
340
  /**
@@ -360,29 +362,27 @@ export function formatExpiresIn(expiresAt, now = new Date()) {
360
362
  label = `${days}d`;
361
363
  return deltaMs >= 0 ? `expires in ${label}` : `expired ${label} ago`;
362
364
  }
363
- /** Project a `DatasetMetadata` to the in-context handle shape. */
364
- export function toDatasetHandle(metadata) {
365
+ /** Project a `RegisterDataframeResult` to the inline handle shape. */
366
+ export function toDataframeHandle(result) {
365
367
  const handle = {
366
- datasetId: metadata.datasetId,
367
- rowCount: metadata.rowCount,
368
- sizeBytes: metadata.sizeBytes,
369
- columns: metadata.columns,
370
- createdAt: metadata.createdAt,
371
- expiresAt: metadata.expiresAt,
368
+ tableName: result.tableName,
369
+ rowCount: result.rowCount,
370
+ columns: result.columns,
371
+ createdAt: result.createdAt,
372
+ expiresAt: result.expiresAt,
372
373
  };
373
- if (metadata.truncated)
374
+ if (result.truncated)
374
375
  handle.truncated = true;
375
- if (typeof metadata.maxRows === 'number')
376
- handle.maxRows = metadata.maxRows;
377
- if (metadata.dataframe)
378
- handle.dataframe = metadata.dataframe;
376
+ if (typeof result.maxRows === 'number')
377
+ handle.maxRows = result.maxRows;
379
378
  return handle;
380
379
  }
381
380
  /**
382
- * Wrap `spillToDataset` with the "only spill when hasMore and totalCount >
381
+ * Wrap `spillToCanvas` with the "only spill when hasMore and totalCount >
383
382
  * loadLimit" guard that every `find_*` tool replicates. When no spillover is
384
- * needed, returns the first-page rows untouched. When it is, persists the
385
- * union to DatasetStore and returns both the full set and the handle.
383
+ * needed, returns the first-page rows untouched. When it is, materializes
384
+ * the union as a canvas dataframe and returns both the full set and the
385
+ * handle.
386
386
  */
387
387
  export async function maybeSpill(input) {
388
388
  const { firstPage, rowMapper, rowFilter } = input;
@@ -392,7 +392,7 @@ export async function maybeSpill(input) {
392
392
  return { fullRows: applyRowTransforms(firstPage.rows, rowMapper, rowFilter) };
393
393
  }
394
394
  const spillInput = {
395
- store: input.store,
395
+ bridge: input.bridge,
396
396
  client: input.client,
397
397
  connection: input.connection,
398
398
  path: input.path,
@@ -412,16 +412,16 @@ export async function maybeSpill(input) {
412
412
  if (input.spillRequestOptions)
413
413
  spillInput.pageRequestOptions = input.spillRequestOptions;
414
414
  try {
415
- const spill = await spillToDataset(spillInput);
415
+ const spill = await spillToCanvas(spillInput);
416
416
  return {
417
417
  fullRows: spill.fullRows,
418
- dataset: toDatasetHandle(spill.dataset),
418
+ dataframe: toDataframeHandle(spill.dataframe),
419
419
  };
420
420
  }
421
421
  catch (err) {
422
422
  if (!input.warnings || !(err instanceof SpillPageFetchError))
423
423
  throw err;
424
- input.warnings.push(`Dataset spillover skipped after returning the first ${firstPage.rows.length} row(s): ${formatSpillError(err)}. Narrow filters, raise loadLimit enough to fit the result in one page, or retry when the upstream server is responsive.`);
424
+ input.warnings.push(`Dataframe spillover skipped after returning the first ${firstPage.rows.length} row(s): ${formatSpillError(err)}. Narrow filters, raise loadLimit enough to fit the result in one page, or retry when the upstream server is responsive.`);
425
425
  return { fullRows: applyRowTransforms(firstPage.rows, rowMapper, rowFilter) };
426
426
  }
427
427
  }
@@ -429,18 +429,18 @@ export async function maybeSpill(input) {
429
429
  * Apply mapper before filter on a row set. Centralizes the order constraint
430
430
  * across the three spillover sites — early-exit, error fallback, and persist
431
431
  * — so they can't drift apart and accidentally filter raw rows the spilled
432
- * dataset has already normalized.
432
+ * dataframe has already normalized.
433
433
  */
434
434
  function applyRowTransforms(rows, mapper, filter) {
435
435
  const mapped = mapper ? rows.map(mapper) : rows;
436
436
  return filter ? mapped.filter(filter) : mapped;
437
437
  }
438
438
  /**
439
- * Pull every remaining page up to MAX_SPILLOVER_* caps, then persist the
440
- * union to DatasetStore. Returns the dataset metadata plus the full row set
441
- * (so callers can compute honest distributions from the whole result).
439
+ * Pull every remaining page up to MAX_SPILLOVER_* caps, then materialize the
440
+ * union as a canvas dataframe. Returns the dataframe metadata plus the full
441
+ * row set (so callers can compute honest distributions from the whole result).
442
442
  */
443
- export async function spillToDataset(input) {
443
+ export async function spillToCanvas(input) {
444
444
  const remainingTarget = Math.min(input.totalCount, MAX_SPILLOVER_ROWS);
445
445
  const pageSize = input.loadLimit;
446
446
  const totalPages = Math.min(Math.ceil(remainingTarget / pageSize), MAX_SPILLOVER_PAGES);
@@ -470,23 +470,23 @@ export async function spillToDataset(input) {
470
470
  const reachedPageCap = pagesFetched >= MAX_SPILLOVER_PAGES && input.totalCount > rows.length;
471
471
  const truncated = reachedRowCap || reachedPageCap;
472
472
  const persistedRows = applyRowTransforms(rows, input.rowMapper, input.rowFilter);
473
- const createInput = {
473
+ const registerInput = {
474
474
  source: input.source,
475
475
  baseUrl: input.connection.baseUrl,
476
476
  query: input.filters,
477
477
  rows: persistedRows,
478
478
  };
479
479
  if (truncated) {
480
- createInput.truncated = true;
480
+ registerInput.truncated = true;
481
481
  // `maxRows` only carries meaning when the row cap fired — it's the upper
482
482
  // bound the spillover honored. When the page cap fired first (small
483
483
  // `loadLimit` × `MAX_SPILLOVER_PAGES` < upstream total), reporting
484
- // `maxRows = MAX_SPILLOVER_ROWS` is misleading: the dataset stopped at
484
+ // `maxRows = MAX_SPILLOVER_ROWS` is misleading: the dataframe stopped at
485
485
  // `loadLimit × MAX_SPILLOVER_PAGES`, well below the row cap. Log the
486
486
  // page-cap event for operators; the agent sees only `truncated: true`
487
487
  // without the false 50k bound and can raise `loadLimit` to push past it.
488
488
  if (reachedRowCap) {
489
- createInput.maxRows = MAX_SPILLOVER_ROWS;
489
+ registerInput.maxRows = MAX_SPILLOVER_ROWS;
490
490
  }
491
491
  else if (reachedPageCap) {
492
492
  input.ctx.log.warning('Spillover hit page cap before exhausting upstream', {
@@ -498,8 +498,8 @@ export async function spillToDataset(input) {
498
498
  });
499
499
  }
500
500
  }
501
- const dataset = await input.store.create(input.ctx, createInput);
502
- return { dataset, fullRows: persistedRows, pagesFetched };
501
+ const dataframe = await input.bridge.registerDataframe(input.ctx, registerInput);
502
+ return { dataframe, fullRows: persistedRows, pagesFetched };
503
503
  }
504
504
  class SpillPageFetchError extends Error {
505
505
  name = 'SpillPageFetchError';
@@ -526,6 +526,29 @@ export function extractRows(result) {
526
526
  return result.data;
527
527
  return [];
528
528
  }
529
+ /**
530
+ * Extract a homogeneous record-row set from a raw BrAPI envelope `result`.
531
+ * Returns the array when `result` is itself a list of objects, or when
532
+ * `result.data` is — covering both bare-array and BrAPI-list-envelope shapes.
533
+ * Returns `null` for non-list shapes (single object, scalar, primitive
534
+ * arrays) so callers — notably `raw_get` / `raw_search` — can skip spillover
535
+ * and pass the upstream payload through unchanged. Empty arrays are list-
536
+ * shaped but carry no rows; the caller uses `length === 0` to decide whether
537
+ * to register a dataframe.
538
+ */
539
+ export function extractListRows(result) {
540
+ const candidate = Array.isArray(result)
541
+ ? result
542
+ : result && typeof result === 'object' && Array.isArray(result.data)
543
+ ? result.data
544
+ : null;
545
+ if (candidate === null)
546
+ return null;
547
+ if (candidate.length === 0)
548
+ return [];
549
+ const allObjects = candidate.every((row) => typeof row === 'object' && row !== null && !Array.isArray(row));
550
+ return allObjects ? candidate : null;
551
+ }
529
552
  /** Return the input as a non-empty string, or undefined. Used in distribution accessors. */
530
553
  export function asString(value) {
531
554
  return typeof value === 'string' && value.length > 0 ? value : undefined;