import { JsonValue, ResultGuidance } from "./results.js"; import { SupabaseMcpServer } from "./types.js"; import { ChumboCliProjection } from "./capabilities.js"; import { z } from "zod"; import { CallToolResult, RegisteredTool, ServerContext, ToolAnnotations } from "@modelcontextprotocol/server"; //#region src/collections.d.ts declare const collectionLimits: Readonly<{ defaultLimit: 20; maxLimit: 100; maxBytes: number; minBytes: 512; maxCursorLength: 2048; }>; interface DefineCursorOptions, Filters extends Record = Record> { /** Bump when changing sort columns or key encoding. Defaults to 1. */ readonly version?: number; /** Keyset columns in deterministic sort order (end with a unique tie-breaker such as `id`). */ readonly keys: Keys; /** Active filter/sort schemas bound into the cursor so filter drift is refused. */ readonly filters?: Filters; } type DecodedCursorResult = { readonly ok: true; readonly keys: KeyValues | null; } | { readonly ok: false; readonly reason: "invalid_cursor" | "filter_mismatch"; readonly result: CallToolResult; }; interface DefinedCursor, FilterValues extends Record = Record> { /** Validated string schema (1..2048 chars, `ccur1.` prefix) for `collectionInputSchema`. */ readonly schema: z.ZodType; encode(row: Readonly, ...filters: [keyof FilterValues] extends [never] ? [filters?: undefined] : [filters: FilterValues]): string; decode(cursorValue: string | undefined, ...filters: [keyof FilterValues] extends [never] ? [filters?: undefined] : [filters: FilterValues]): DecodedCursorResult; /** Curried `cursorFor` helper for `collectionResult`. */ forFilters(...filters: [keyof FilterValues] extends [never] ? [filters?: undefined] : [filters: FilterValues]): (row: Readonly) => string; } /** * Define an opaque, validated composite keyset cursor bound to active filter * and sort arguments (`ccur1.`). Encodes position only, never authority. */ declare function defineCursor>, Filters extends Record = Record>(options: DefineCursorOptions): DefinedCursor<{ [K in keyof Keys]: z.output }, [keyof Filters] extends [never] ? Record : z.output>>; /** Extend this object schema with application filters. Cursor semantics remain application-owned. */ declare function collectionInputSchema(options?: { defaultLimit?: number; maxLimit?: number; cursorSchema?: z.ZodType; }): z.ZodObject<{ limit: z.ZodDefault; cursor: z.ZodOptional>>, z.ZodString>>; }, z.core.$strip>; /** Register this outputSchema only for structured or intentional hybrid collection results. */ declare function collectionOutputSchema(itemSchema: T): z.ZodObject<{ items: z.ZodArray; has_more: z.ZodBoolean; next_cursor: z.ZodNullable; next_call: z.ZodNullable; }, z.core.$strip>>; next: z.ZodOptional; warnings: z.ZodOptional>; }, z.core.$strip>; interface CollectionNextCall { name: string; arguments: Record; } interface CollectionPage { next?: string; warnings?: string[]; items: Item[]; has_more: boolean; next_cursor: string | null; next_call: CollectionNextCall | null; } interface CollectionResultOptions { /** One bounded, ordered source window. Fetch limit + 1 to detect more rows. */ items: readonly Row[]; limit: number; /** Whether the source has rows beyond this supplied window. Defaults to `false`. */ hasMore?: boolean; /** * Explicit compact projection, validated before it enters either response lane. * When omitted, copies strictly the keys declared in `itemSchema.shape` and parses via `itemSchema`. */ project?: (row: Row) => Item; itemSchema: z.ZodType; /** Stable keyset cursor AFTER this row, never after the fetched window. */ cursorFor: (row: Row) => string; tool: string; /** Explicit safe filters only. Chumbo overwrites cursor and limit with this page's continuation. */ arguments?: Record; maxLimit?: number; maxBytes?: number; mode?: "text" | "structured" | "hybrid"; /** Purpose-written text from exactly the projected page. Required for text/hybrid. */ render?: (page: Readonly>) => string; /** Dual-lane operational guidance budgeted together with the returned page. */ guidance?: ResultGuidance | ((page: Readonly>) => ResultGuidance); /** A compact detail-tool or Resource instruction when the first item cannot fit. */ onOversizedItem?: (row: Row) => string; } /** * Build the largest prefix that fits both count and UTF-8 serialized CallToolResult budgets. * Source queries, stable ordering, projection semantics and authorization remain builder-owned. * Existing result helpers and arbitrary tool results are never automatically paginated. */ declare function collectionResult(options: CollectionResultOptions): CallToolResult; interface CollectionPageBuilderOptions { readonly hasMore?: boolean; readonly guidance?: ResultGuidance | ((page: Readonly>) => ResultGuidance); readonly onOversizedItem?: (row: Row) => string; } interface RegisterCollectionConfig, KeyValues extends Record, FiltersShape extends Record = Record, Row = z.input> { readonly name: string; readonly id?: string; readonly title?: string; readonly description: string; readonly scopes?: readonly string[]; readonly cli?: ChumboCliProjection; readonly filters?: FiltersShape; readonly itemSchema: ItemSchema; readonly cursor: DefinedCursor : { [K in keyof FiltersShape]: z.output }>; readonly defaultLimit?: number; readonly maxLimit?: number; readonly maxBytes?: number; /** Defaults to `"structured"` when `render` is omitted, or `"hybrid"` when `render` is supplied. */ readonly mode?: "text" | "structured" | "hybrid"; readonly project?: (row: Row) => z.output; readonly render?: (page: Readonly>>) => string; readonly onOversizedItem?: (row: Row) => string; readonly annotations?: ToolAnnotations; readonly mcpMeta?: Readonly>; } interface CollectionHandlerInput, KeyValues extends Record, FiltersShape extends Record, Row> { readonly limit: number; readonly cursor: string | undefined; /** Decoded keyset values from `cursor`, or `null` on the first page. */ readonly after: KeyValues | null; /** Validated filter/sort arguments (excluding `limit` and `cursor`). */ readonly filters: { [K in keyof FiltersShape]: z.output }; /** Build the bounded `CallToolResult` with tool name, cursor, filters, and schemas pre-bound. */ page(items: readonly Row[], options?: CollectionPageBuilderOptions>): CallToolResult; } /** * Register a bounded, keyset-paginated read capability with filter-bound cursor * decoding, automatic `outputSchema`, and pre-bound `page(items)` result builder. */ declare function registerCollection, KeyValues extends Record, FiltersShape extends Record = Record, Row extends KeyValues = z.input & KeyValues>(server: SupabaseMcpServer, config: RegisterCollectionConfig, handler: (input: CollectionHandlerInput, mcpContext: ServerContext) => CallToolResult | Promise): RegisteredTool; //#endregion export { CollectionHandlerInput, CollectionNextCall, CollectionPage, CollectionPageBuilderOptions, CollectionResultOptions, DecodedCursorResult, DefineCursorOptions, DefinedCursor, RegisterCollectionConfig, collectionInputSchema, collectionLimits, collectionOutputSchema, collectionResult, defineCursor, registerCollection }; //# sourceMappingURL=collections.d.ts.map