provideMCPApps

Configure the opt-in MCP Apps activity renderer for Angular.

Import MCP Apps from the secondary entry point so applications that do not use it do not load its host and sandbox code.

import { ApplicationConfig } from "@angular/core";
import { provideCopilotKit } from "@copilotkit/angular";
import { provideMCPApps } from "@copilotkit/angular/mcp-apps";

export const appConfig: ApplicationConfig = {
  providers: [
    provideCopilotKit({ runtimeUrl: "/api/copilotkit" }),
    provideMCPApps({
      idleTimeoutMs: 30_000,
      initializationTimeoutMs: 30_000,
      hostInfo: { name: "Acme Copilot", version: "1.0.0" },
    }),
  ],
};
interface MCPAppsConfig {
  idleTimeoutMs?: number;
  initializationTimeoutMs?: number;
  hostInfo?: { name: string; version: string };
  hostCapabilities?: Record<string, unknown>;
  hostContext?: Record<string, unknown>;
  allowSameOriginFallback?: boolean;
}

provideMCPApps contributes a lower-precedence built-in renderer for activityType: "mcp-apps"; an explicit application activity renderer still wins. It deliberately accepts no MCP server URL. Resource loads, tool calls, and follow-up messages travel through the selected AG-UI agent.

Widgets run in a sandbox with an opaque origin, so they can't reach your page's cookies, storage or DOM. allowSameOriginFallback: true restores allow-same-origin for trusted widgets that need localStorage, IndexedDB or cookies. It is unsafe: every widget then runs with your page's origin. See Sandbox and widget storage.

  • Host context is browser-visible and must not contain secrets.
  • Each widget owns its iframe listener. All widgets share one request queue.
  • Destroying a widget cancels only the requests that widget queued.
  • When the thread changes, queued requests from the old thread are dropped.
  • Busy agents and initialization handshakes use the configured timeouts.
  • Snapshot content, JSON-RPC messages, and exact iframe event sources are validated before use.

During SSR the widget is inert. Its sandbox and message listener initialize in the browser after hydration. CopilotMCPAppsWidget, schemas, tokens, and the ready-made activity config are also public from the secondary entry point for advanced custom hosts; see the public API inventory.

How is this guide?