import { JsonValue } from "./results.js"; import { RuntimeDependencies, SupabaseMcpApp, SupabaseMcpSurfaceTool, VerifiedSupabaseIdentity } from "./types.js"; import { n as createSupabaseMcpInternal } from "./runtime.js"; import { CatalogTokenReport, EstimateCatalogTokensOptions, ResultTokenEstimate, SURFACE_TOKEN_LIMITS, SurfaceToolInput, TOKEN_ESTIMATOR_ID, ToolTokenBreakdown, estimateCatalogTokens, estimateResultTokens, estimateTextTokens, estimateToolTokens } from "./surface-tokens.js"; import { LockedSurfaceContextBudget, LockedSurfaceEntry, LockedToolAuthorityMeta, McpSurfaceLockfileV1, SURFACE_DIFF_DEFAULTS, SurfaceAuthMode, SurfaceDiffCategory, SurfaceDiffFinding, SurfaceDiffReport, SurfaceDiffRuleCode, diffSurfaceSnapshots } from "./surface-diff.js"; import { CallToolResult, GetPromptResult, Implementation, InitializeResult, ListPromptsResult, ListResourcesResult, ReadResourceResult } from "@modelcontextprotocol/server"; import { SupabaseEnv } from "@supabase/server"; //#region src/testing.d.ts type McpTestableTarget = Pick | ((request: Request) => Response | Promise); interface TestUserPersona { readonly id: string; readonly email?: string; /** Supply a real Supabase session access_token for live RLS tests, or omit when using `authHarness`. */ readonly token?: string; readonly role?: string; readonly scopes?: readonly string[]; readonly clientId?: string; readonly appMetadata?: Readonly>; readonly userMetadata?: Readonly>; readonly expiresInSeconds?: number; } interface TestAuthHarness { readonly issuer: string; readonly resourceUrl: string; readonly jwks: { readonly keys: readonly (JsonWebKey & { readonly kid?: string; })[]; }; /** Ready-to-pass `Partial` for `createSupabaseMcp({ supabase: { env } })` or `SUPABASE_JWKS`. */ readonly supabaseEnv: Partial; mintUserToken(persona: TestUserPersona): Promise; } /** * Generate an ephemeral in-memory WebCrypto ES256 JWKS harness for testing * authenticated MCP apps through real JWT signature verification without * auth backdoors or `node:crypto` dependencies. */ declare function createTestAuthHarness(options?: { readonly supabaseUrl?: string; readonly resourceUrl?: string; readonly kid?: string; }): Promise; interface CreateMcpTestClientOptions { /** Base endpoint URL used in synthesized `Request` objects. Defaults to `"https://example.test/functions/v1/mcp"`. */ readonly endpoint?: string | URL; /** Ephemeral ES256 JWT issuer enabling tokenless `asUser({ id, email, scopes })` against real JWKS verification. */ readonly authHarness?: TestAuthHarness; /** Default client info sent in `_meta` and `initialize`. */ readonly clientInfo?: Implementation; /** Known tool names across all profiles (enables automatic unmounted-tool-reference lint in `snapshotSurface`). */ readonly knownTools?: Iterable; readonly plainWordTools?: Iterable; } interface McpTestToolResult> extends CallToolResult { readonly structuredContent?: Structured; /** Concatenated text from all `{ type: "text" }` blocks in `content`. */ readonly text: string; /** Exact UTF-8 serialized byte length of the wire `CallToolResult`. */ readonly encodedBytes: number; /** Extracted dual-lane guidance (`structuredContent.next/warnings` or text lane fallback). */ readonly guidance: { readonly next?: string; readonly warnings: readonly string[]; }; } interface McpTestResourceResult extends ReadResourceResult { /** Concatenated UTF-8 text from all text contents in `contents`. */ readonly text: string; /** Exact UTF-8 serialized byte length of the wire `ReadResourceResult`. */ readonly encodedBytes: number; } interface McpTestPromptResult extends GetPromptResult { /** Exact UTF-8 serialized byte length of the wire `GetPromptResult`. */ readonly encodedBytes: number; } interface UnmountedToolReferenceFinding { readonly location: "instructions" | `${string}.description` | `${string}.inputSchema` | `${string}.outputSchema`; readonly referencedTool: string; readonly excerpt: string; } interface SurfaceSnapshot { readonly schemaVersion: 1; readonly profile: string; readonly instructions?: string; readonly tools: readonly SupabaseMcpSurfaceTool[]; /** Identical `sha256:` digest to `onSurface` and `mcp-surface.lock.json`. */ readonly contentDigest: `sha256:${string}`; readonly estimatedTokens: number; readonly unmountedReferences: readonly UnmountedToolReferenceFinding[]; } interface McpTestCallOptions { readonly meta?: Readonly>; readonly headers?: Readonly>; /** Convenience carrier setting `_meta["dev.chumbo/run"]`. */ readonly run?: string; readonly sessionId?: string; } interface McpTestHttpExchange { readonly status: number; readonly headers: Headers; readonly body: unknown; } interface McpTestPersonaClient { readonly sessionId: string | null; initialize(capabilities?: Record): Promise; listTools(): Promise; callTool>(name: string, args?: Readonly>, options?: McpTestCallOptions): Promise>; /** Low-level JSON-RPC exchange preserving HTTP status (401/403/405/429) and JSON-RPC error envelopes. */ exchange(method: string, params?: Readonly>, options?: McpTestCallOptions): Promise; listResources(): Promise; readResource(uri: string, options?: McpTestCallOptions): Promise; listPrompts(): Promise; getPrompt(name: string, args?: Readonly>, options?: McpTestCallOptions): Promise; /** Capture deterministic surface snapshot + `contentDigest` + unmounted-tool-reference lint. */ snapshotSurface(options?: { readonly profile?: string; readonly knownTools?: Iterable; readonly allowUnmountedReferences?: boolean; }): Promise; } interface RlsIsolationAssertionOptions { readonly personaA: McpTestPersonaClient; readonly personaB: McpTestPersonaClient; readonly tool: string; readonly arguments?: Readonly>; /** Private strings/IDs belonging to A that MUST appear in A's result and MUST NOT appear in B's result. */ readonly mustIsolateForA?: readonly string[]; /** Private strings/IDs belonging to B that MUST appear in B's result and MUST NOT appear in A's result. */ readonly mustIsolateForB?: readonly string[]; /** Cross-tenant direct-ID probes (e.g. A calls `get_draft` or `delete_draft` with B's ID) that must fail or return empty. */ readonly crossAccessProbes?: readonly { readonly caller: "A" | "B"; readonly tool: string; readonly arguments: Readonly>; readonly expectOutcome?: "error" | "empty"; }[]; } interface McpTestClient { asUser(persona: TestUserPersona | string): McpTestPersonaClient; asApiKey(token: string, options?: { readonly header?: "authorization" | "apikey"; }): McpTestPersonaClient; anon(): McpTestPersonaClient; assertRlsIsolation(options: RlsIsolationAssertionOptions): Promise<{ readonly resultA: McpTestToolResult; readonly resultB: McpTestToolResult; }>; } /** * Deterministic linter checking server `instructions`, tool descriptions, and * JSON Schema `description` fields for references to known tools that are not * mounted on the advertised surface. */ declare function lintUnmountedToolReferences(input: { readonly instructions?: string; readonly tools: readonly (Pick & Partial>)[]; readonly knownTools: Iterable; readonly plainWordTools?: Iterable; }): readonly UnmountedToolReferenceFinding[]; /** * Create a zero-backdoor HTTP MCP test client supporting multi-persona * execution (`asUser`, `asApiKey`, `anon`), deterministic surface snapshots * with unmounted-tool-reference linting, and concurrent two-user RLS assertions. */ declare function createMcpTestClient(target: McpTestableTarget, options?: CreateMcpTestClientOptions): McpTestClient; //#endregion export { type CatalogTokenReport, CreateMcpTestClientOptions, type EstimateCatalogTokensOptions, type LockedSurfaceContextBudget, type LockedSurfaceEntry, type LockedToolAuthorityMeta, type McpSurfaceLockfileV1, McpTestCallOptions, McpTestClient, McpTestHttpExchange, McpTestPersonaClient, McpTestPromptResult, McpTestResourceResult, McpTestToolResult, McpTestableTarget, type ResultTokenEstimate, RlsIsolationAssertionOptions, type RuntimeDependencies, SURFACE_DIFF_DEFAULTS, SURFACE_TOKEN_LIMITS, type SurfaceAuthMode, type SurfaceDiffCategory, type SurfaceDiffFinding, type SurfaceDiffReport, type SurfaceDiffRuleCode, SurfaceSnapshot, type SurfaceToolInput, TOKEN_ESTIMATOR_ID, TestAuthHarness, TestUserPersona, type ToolTokenBreakdown, UnmountedToolReferenceFinding, type VerifiedSupabaseIdentity, createMcpTestClient, createSupabaseMcpInternal as createSupabaseMcpForTesting, createTestAuthHarness, diffSurfaceSnapshots, estimateCatalogTokens, estimateResultTokens, estimateTextTokens, estimateToolTokens, lintUnmountedToolReferences }; //# sourceMappingURL=testing.d.ts.map