/** * `/mcp/connect` — frictionless external-agent connection. The legacy * `/_agent-native/mcp/connect` alias is mounted by the core route plugin. * * A logged-in user on a deployed agent-native app (e.g. mail.agent-native.com) * mints a per-user, scoped, revocable MCP bearer token WITHOUT ever copying a * shared deployment secret. Two surfaces: * * 1. Browser — `GET /mcp/connect` renders a minimal in-app page (same inline * HTML approach as the auth pages). The Authorize button POSTs to * `/connect/token`, then shows the ready-to-paste `.mcp.json` entry, the * `agent-native connect ` one-liner, and the user's existing * tokens with Revoke buttons. * 2. CLI — an OAuth-2.0-device-authorization-style flow: * POST /mcp/connect/device/start (unauth) → device_code + user_code * GET /mcp/connect?user_code=… (browser) → user signs in & approves * POST /mcp/connect/device/authorize (session) → binds user to the code * POST /mcp/connect/device/poll (unauth) → mints + returns the token * * When A2A_SECRET exists, the minted token reuses the existing A2A signer * (`signA2AToken`) and adds a random `jti` + `scope: "mcp-connect"` claim so * it can be revoked. Deployments without A2A_SECRET mint the same standard MCP * OAuth access-token format used by remote MCP OAuth, signed with the auth * secret fallback and bound to the exact MCP resource URL. * * Node-only (crypto + the A2A signer), bundled alongside the other framework * routes. Dialect-agnostic SQL lives in `connect-store.ts`. */ import type { H3Event } from "h3"; export interface McpConnectRouteOptions { /** App id (directory under apps/, e.g. `mail`). Used for the server name. */ appId?: string; /** Human app name shown on the connect page. */ appName?: string; /** Explicit MCP server id to return in copyable config/device-flow grants. */ serverName?: string; } /** * Mint an ORG SERVICE token: a connect-scoped, revocable bearer whose subject * is the synthetic service identity `svc-@service.` instead of a * person. Built for CI (e.g. the `PLAN_RECAP_TOKEN` GitHub secret) so the * credential survives any individual leaving or revoking their personal * tokens, and so rows created by CI are org-scoped (visible to org members) * rather than owned by one person. * * The token value is returned exactly once and never persisted — only the * random `jti` is stored, so the standard revocation path * (`isJtiRevoked` in `verifyAuth`) applies to service tokens identically. * * Authorization is the CALLER'S responsibility: this function does not check * org membership/role. The `create-org-service-token` action gates on org * owner/admin before calling it. */ export declare function mintOrgServiceToken(params: { /** Human-readable service principal name, e.g. "ci" or "pr-recap". */ serviceName: string; /** Org the service token acts for; becomes the resolved session orgId. */ orgId: string; /** The human minting the token — stored for audit, never used as identity. */ createdBy: string; /** 1–365 days; clamped. Defaults to DEFAULT_TOKEN_TTL_DAYS. */ ttlDays?: number; /** App origin used for OAuth-signed tokens (resource/issuer binding). */ appUrl: string; }): Promise<{ token: string; jti: string; id: string; serviceName: string; serviceEmail: string; ttlDays: number; }>; /** * Handle a `/mcp/connect[...]` request. The legacy * `/_agent-native/mcp/connect` alias is mounted too. `subpath` is the part * after `/connect` (empty string = the page itself, otherwise e.g. `/token`, * `/device/start`). The core-routes-plugin computes it from the stripped event * path so this module stays mount-agnostic. */ export declare function handleMcpConnect(event: H3Event, subpath: string, options?: McpConnectRouteOptions): Promise; //# sourceMappingURL=connect-route.d.ts.map