import { a as McpAppThemePalette, i as McpAppPresentation, n as McpAppBrand, o as NEUTRAL_APP_PRESENTATION, r as McpAppBrandColors, s as buildHubUrl, t as MCP_APP_PRESENTATION_SCRIPT_ID } from "./app-presentation-shared.js"; import { SupabaseMcpServer } from "./types.js"; import { ChumboCapabilityRisk } from "./capabilities.js"; import { z } from "zod"; import { CallToolResult, McpServer, RegisteredResource, RegisteredTool, StandardSchemaWithJSON, ToolAnnotations, ToolCallback } from "@modelcontextprotocol/server"; //#region src/mcp-apps.d.ts declare const MCP_APP_MIME_TYPE: "text/html;profile=mcp-app"; declare const MCP_APP_RESOURCE_URI_META_KEY: "ui/resourceUri"; declare const MCP_APP_PRESENTATION_PLACEHOLDER: "__MCP_APP_PRESENTATION__"; type McpAppUri = `ui://${string}`; type McpAppToolVisibility = "model" | "app"; declare class McpAppPresentationError extends Error { readonly code: "presentation_invalid" | "presentation_placeholder_invalid"; constructor(code: "presentation_invalid" | "presentation_placeholder_invalid", message: string); } /** SEP-1865 Content Security Policy origin allowlists for a `ui://` Resource. */ interface McpAppCsp { /** Maps to CSP `connect-src`. Omitted/empty -> `connect-src 'none'`. */ readonly connectDomains?: readonly string[]; /** Maps to CSP `img-src`, `style-src`, `script-src`, `font-src`, `media-src`. */ readonly resourceDomains?: readonly string[]; /** Maps to CSP `frame-src`. Omitted/empty -> `frame-src 'none'`. */ readonly frameDomains?: readonly string[]; /** Maps to CSP `base-uri`. Omitted/empty -> `base-uri 'none'` / `'self'`. */ readonly baseUriDomains?: readonly string[]; } /** SEP-1865 iframe Permission Policy requests. */ interface McpAppPermissions { readonly camera?: Readonly>; readonly microphone?: Readonly>; readonly geolocation?: Readonly>; readonly clipboardWrite?: Readonly>; } interface McpAppResourceMeta { readonly [key: string]: unknown; readonly ui: { readonly csp: McpAppCsp; readonly permissions?: McpAppPermissions; readonly domain?: string; readonly prefersBorder?: boolean; }; } interface McpAppToolMeta { readonly [key: string]: unknown; readonly ui: { readonly resourceUri: McpAppUri; readonly visibility: readonly McpAppToolVisibility[]; }; readonly "ui/resourceUri": McpAppUri; } interface McpAppCspInput { /** HTTPS origins (e.g. `"https://files.example.com"`) for `fetch`/XHR/WebSocket. */ readonly connectOrigins?: readonly string[]; /** HTTPS origins (or `"https://*.example.com"`) for images, media, or styles. */ readonly resourceOrigins?: readonly string[]; /** HTTPS origins for nested iframes. */ readonly frameOrigins?: readonly string[]; /** HTTPS origins for document ``. */ readonly baseUriOrigins?: readonly string[]; /** Permit `http://localhost:` and `http://127.0.0.1:` origins in local dev. */ readonly allowLocalhostOrigins?: boolean; } interface McpAppReadContext { readonly uri: URL; readonly presentation: McpAppPresentation; } interface McpAppDefinition { /** Stable resource name passed to `server.registerResource` (kebab-case, e.g. `"review-queue"`). */ readonly name: string; /** Canonical `ui:///.html` identifier. Validated at definition time. */ readonly uri: McpAppUri; /** Static title or presentation-derived title. */ readonly title: string | ((presentation: McpAppPresentation) => string); readonly description: string; /** * Default scope gate required to discover and read the HTML Resource, and * inherited by `openTool` and read-only `appTool` registrations when their own * `scopes` field is omitted. Mutating `appTool`s on a scoped app MUST declare * explicit `scopes` so `visibility: ["app"]` is never mistaken for authority. */ readonly scopes?: readonly string[]; /** * Compiled single-file HTML string (e.g. imported from `generated/apps/.html.ts`) * or an async reader (e.g. `() => Deno.readTextFile(...)`). */ readonly html: string | ((context: McpAppReadContext) => string | Promise); /** Static baseline CSP origins. Merged with per-registration origins and presentation logos. */ readonly csp?: McpAppCspInput; readonly permissions?: McpAppPermissions; /** Defaults to `true` (explicit host border preference recommended by SEP-1865). */ readonly prefersBorder?: boolean; /** Optional host-specific dedicated sandbox domain. */ readonly domain?: string; } interface DefinedMcpApp extends Readonly { readonly uri: McpAppUri; readonly scopes: readonly string[]; } interface RegisterMcpAppOptions { /** * Per-connection tenant presentation injected into ``, `` breakouts) * and U+2028 / U+2029 JS line terminators. */ declare function scriptSafeJson(value: unknown): string; /** * Inject `presentation` into a compiled single-file View HTML string. * * When `mode` is `"placeholder"` (default), `MCP_APP_PRESENTATION_PLACEHOLDER` * MUST occur exactly once inside the HTML; 0 or >1 occurrences throw `McpAppPresentationError`. * When `mode` is `"auto"`, 1 occurrence is replaced, >1 throws, and 0 occurrences leaves static HTML untouched. */ declare function injectAppPresentation(html: string, presentation: McpAppPresentation, options?: { readonly mode?: "placeholder" | "auto"; }): string; /** Schema for explicit `request_id` UUID arguments on idempotent UI mutation tools. */ declare const requestIdFieldSchema: z.ZodString; /** Standard domain refusal when a `request_id` is reused with mutated arguments. */ declare function idempotencyConflictResult(field?: string): CallToolResult; declare function assertMcpAppUri(uri: string): McpAppUri; /** Low-level `_meta` helper for attaching a `ui://` View to `defineCapability` or raw `registerTool`. */ declare function mcpAppToolMeta(resourceUri: McpAppUri, visibility: readonly McpAppToolVisibility[]): McpAppToolMeta; /** Low-level `_meta` builder for `ui://` Resources with auto-derived presentation CSP domains. */ declare function mcpAppResourceMeta(options: { readonly csp?: McpAppCspInput; readonly presentation?: McpAppPresentation; readonly permissions?: McpAppPermissions; readonly prefersBorder?: boolean; readonly domain?: string; }): McpAppResourceMeta; /** True when a discovered tool declares `visibility` containing `"app"` and NOT `"model"`. */ declare function isMcpAppOnlyTool(tool: { readonly _meta?: Readonly>; }): boolean; /** Validate and freeze a reusable `ui://` MCP App definition. */ declare function defineMcpApp(definition: McpAppDefinition): DefinedMcpApp; /** * Register the `ui://` HTML Resource once and return scope-aware `openTool` and `appTool` * builders bound to its `resourceUri`. */ declare function registerMcpApp(server: SupabaseMcpServer | McpServer, app: DefinedMcpApp, options?: RegisterMcpAppOptions): RegisteredMcpApp; //#endregion export { AppToolConfig, DefinedMcpApp, MCP_APP_MIME_TYPE, MCP_APP_PRESENTATION_PLACEHOLDER, MCP_APP_PRESENTATION_SCRIPT_ID, MCP_APP_RESOURCE_URI_META_KEY, type McpAppBrand, type McpAppBrandColors, McpAppCsp, McpAppCspInput, McpAppDefinition, McpAppPermissions, type McpAppPresentation, McpAppPresentationError, McpAppPresentationInput, McpAppPresentationManifestInput, McpAppPresentationManifestSchema, McpAppPresentationResolveInput, McpAppReadContext, McpAppResourceMeta, type McpAppThemePalette, McpAppToolMeta, McpAppToolVisibility, McpAppUri, NEUTRAL_APP_PRESENTATION, OpenToolConfig, RegisterMcpAppOptions, RegisteredMcpApp, assertMcpAppUri, buildHubUrl, defineMcpApp, idempotencyConflictResult, injectAppPresentation, isMcpAppOnlyTool, mcpAppPresentationOrigins, mcpAppResourceMeta, mcpAppToolMeta, parseAppPresentationEnv, parseAppPresentationManifest, registerMcpApp, requestIdFieldSchema, resolveAppPresentation, scriptSafeJson }; //# sourceMappingURL=mcp-apps.d.ts.map