import { SupabaseMcpContext, SupabaseMcpServer } from "./types.js"; import { ChumboCapabilityRisk, ChumboCliProjection } from "./capabilities.js"; import { z } from "zod"; import { CallToolResult, RegisteredTool, ServerContext, StandardSchemaWithJSON, ToolAnnotations } from "@modelcontextprotocol/server"; //#region src/field-projection.d.ts interface ProjectedFieldRule { /** Scope string (`ctx.hasScope(scope)`), scope array (`ctx.hasScopes(scopes)`), or request-time predicate. */ readonly allow: string | readonly string[] | ((context: SupabaseMcpContext) => boolean | Promise); /** Concise bullet rendered into the projected tool description when this field is permitted. */ readonly summary: string; /** Companion optional fields in `Shape` included only when this field is permitted (e.g. `version_id` for `source_date`). */ readonly companionFields?: readonly (keyof Shape & string)[]; } interface ProjectInputFieldsConfig { /** Base Zod object schema declaring all target, guarded, and companion fields. */ readonly schema: z.ZodObject; /** Target identifier fields always exposed when the tool mounts (e.g. `["path"]` or `["id"]`). */ readonly alwaysInclude: readonly Exclude[]; /** Deterministic evaluation/application order of guarded fields. */ readonly fields: Readonly>>; /** Require at least one guarded field in every call. Defaults to `true`. */ readonly requireAtLeastOne?: boolean; /** Omit the tool from `tools/list` (do not register) when zero guarded fields are permitted. Defaults to `true`. */ readonly dropWhenEmpty?: boolean; /** Render the projected tool title from the active permitted field names. */ readonly title?: (permittedFields: readonly GuardedKey[]) => string; /** Render the projected tool description from active permitted fields and their formatted bullets. */ readonly description: (input: { readonly permittedFields: readonly GuardedKey[]; readonly bullets: readonly string[]; }) => string; } interface ValidatedFieldPlan { /** Ordered list of guarded fields actually supplied in this call (all verified permitted at call time). */ readonly fields: readonly GuardedKey[]; /** Parsed, type-safe input values. */ readonly input: z.output>; } type FieldPlanAuthorizationResult = { readonly ok: true; readonly plan: ValidatedFieldPlan; } | { readonly ok: false; readonly result: CallToolResult; }; interface ProjectedToolContract { readonly permittedFields: readonly GuardedKey[]; readonly title?: string; readonly description: string; /** * Standard Schema advertising ONLY `alwaysInclude` + `permittedFields` + active * `companionFields` in `tools/list` (`additionalProperties: false`), while * validating known fields cleanly so call-time authorization produces actionable * domain refusals instead of opaque schema errors. */ readonly inputSchema: StandardSchemaWithJSON>, z.output>>; authorize(parsedInput: z.output>, toolName: string, callTimeContext?: SupabaseMcpContext): Promise>; } interface ProjectedCapabilityRegistration extends ProjectInputFieldsConfig { readonly id?: string; readonly mcpName: string; readonly risk: Exclude; readonly idempotent?: boolean; readonly scopes?: readonly string[]; readonly cli?: ChumboCliProjection; readonly outputSchema?: Output; readonly annotations?: ToolAnnotations; readonly mcpMeta?: Readonly>; readonly handler: (plan: ValidatedFieldPlan, mcpContext: ServerContext) => CallToolResult | Promise; } /** * Compile a permission-projected input contract for `context`, returning `null` * when zero guarded fields are permitted and `dropWhenEmpty` is `true` (default). */ declare function projectInputFields(context: SupabaseMcpContext, config: ProjectInputFieldsConfig): Promise | null>; /** * Register a mutating capability whose advertised `inputSchema` and `description` * expose only fields permitted for `context`, while re-evaluating field permissions * atomically at call time before `handler` executes. */ declare function registerProjectedCapability(server: SupabaseMcpServer, context: SupabaseMcpContext, config: ProjectedCapabilityRegistration): Promise; //#endregion export { FieldPlanAuthorizationResult, ProjectInputFieldsConfig, ProjectedCapabilityRegistration, ProjectedFieldRule, ProjectedToolContract, ValidatedFieldPlan, projectInputFields, registerProjectedCapability }; //# sourceMappingURL=field-projection.d.ts.map