import type { H3Event } from "h3"; import type { ActionEntry } from "../agent/production-agent.js"; import { type LocaleCode } from "../localization/shared.js"; import { type McpApprovalRecord } from "./approval-store.js"; import { type McpApprovalSummary } from "./approval-summary.js"; import type { MCPRequestMeta } from "./build-server.js"; import { type McpApprovalPriorRun, type McpApprovalReview } from "./execute-action-call.js"; /** * The page where a person approves or denies an MCP action call their agent * could not get approved in its own client. The id in the URL is a lookup * handle, not a credential: every read and decision requires the browser * session cookie of the user the call would run as, in the same app and * organization, and a decision also requires a same-origin JSON POST carrying * a token minted for that session. Approving never runs anything; it lets the * identical call, from the same MCP caller, run once when the agent retries * it. */ /** Where `mountMcpApprovalRoute` serves review pages for `routePrefix`. */ export declare function mcpApprovalRoute(routePrefix?: string): string; /** The app whose grants a mounted review page reads and decides. */ export interface McpApprovalApp { appId: string; actions: Record; /** The app's own pages show reviews; see `MCPConfig.appApprovalPage`. */ appPage?: boolean; } /** * The review page for one grant, on the route the request's MCP mount * serves it from, absolute only for a configured origin or local development. */ export declare function mcpApprovalReviewUrl(nonce: string, requestMeta: Pick | undefined): string; /** What the page shows, as JSON for an in-app review surface. */ export type McpApprovalViewState = "pending" | "approved" | "used" | "denied" | "closed" | "expired"; /** * The connection that made the call. `name` is the one the client gave * itself (or, for a client identified by URL, that URL's host), so it is * shown with when this user connected it: a name alone can be copied. */ export interface McpApprovalRequester { name: string | null; connectedAt: number | null; } export interface McpApprovalView { id: string; state: McpApprovalViewState; actionName: string; summary: McpApprovalSummary; requester: McpApprovalRequester | undefined; createdAt: number | null; expiresAt: number; /** The server's clock when it built this view; deadlines are on that clock. */ servedAt: number; priorRun: McpApprovalPriorRun | undefined; /** The reader's chosen time zone; null means the device's own. */ readerTimeZone: string | null; /** The summary's language, for the rest of the page's copy. */ locale: LocaleCode; /** Present while a decision can be made; sent back with it. */ csrfToken?: string; } export declare function mcpApprovalViewState(record: McpApprovalRecord, now: number): McpApprovalViewState; export declare function handleMcpApprovalRequest(event: H3Event, app: McpApprovalApp): Promise; /** * The in-client approval prompt for a grant: the review page's summary, as * text, in the owner's language and time zone. */ export declare function mcpApprovalPrompt(input: { entry: ActionEntry | undefined; review: McpApprovalReview; ownerEmail: string | undefined; mode: "form" | "url"; reviewUrl: string; }): Promise<{ message: string; decisionTitle: string; decisionHelp: string; }>; export declare function mcpApprovalRelativeLinkNote(ownerEmail: string | undefined): Promise; export declare const MCP_APPROVAL_PRUNE_SWEEP_ID = "mcp-approval-grants"; export declare function mountMcpApprovalRoute(nitroApp: unknown, app: McpApprovalApp, routePrefix?: string): void;