> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# MCP Apps

Modern.js builds React cards for MCP hosts. UI builds and servers exchange only `ui-manifest.json`. Servers use the official MCP SDK directly.

## Create a project

```bash
npx @modern-js/create@latest my-mcp --template mcp-apps
npx @modern-js/create@latest my-mf-mcp --template mcp-apps --mf
```

Choose a release containing MCP Apps support. Run `pnpm dev`. The explicit BFF route is `/api/mcp`.

`@modern-js/mcp-apps` provides the build plugin, server plugin, server adapters and card runtime through `./cli`, `./server-plugin`, `./server` and `./react`. The application must install the peers `react`, `react-dom`, `@modelcontextprotocol/server` and `@modelcontextprotocol/ext-apps`, so cards use the application's React and tools, resources and HTTP handling use the application's SDK versions. `@modern-js/server-runtime` and `@module-federation/enhanced` are optional peers that provide the default request context for BFF handlers and the default MF shell runtime. The project templates already declare these dependencies.

## Build cards

Declare local default-export React components, this project's MF exposes, or exposes of deployed remotes in `mcp-views.json`:

The following JSONC example uses comments to explain the fields. The actual `mcp-views.json` must be valid JSON, so remove the comments before use.

```jsonc
{
  // Maps card names to view configurations
  "views": {
    "todos": {
      // Local React component path, relative to mcp-views.json, with a default export
      "component": "./src/components/Todos.tsx",
      // Optional resource configuration
      "resource": {
        // Custom resource URI, defaults to ui://app/todos when omitted
        "uri": "ui://app/todos",
        "_meta": {
          // UI metadata overrides for this card only
          "ui": {
            // Requests a border around this card from the host
            "prefersBorder": true,
          },
        },
      },
    },
    // References a deployed MF remote
    "stats": {
      // Exposed module name, must start with ./
      "expose": "./Stats",
      // Absolute HTTP(S) MF manifest URL, with a path ending in .json
      "remote": "https://example.com/mf-manifest.json",
    },
  },
  // Global CSP configuration applied to all cards
  "csp": {
    // API domains that cards may connect to
    "connectDomains": ["https://api.example.com"],
  },
}
```

Define tool names, parameters, metadata, and handlers directly in the MCP server. Associate tools with the resource URIs returned by `registerUiResources` through `_meta.ui.resourceUri`.

Import `mcpAppsPlugin` from `@modern-js/mcp-apps/cli` and add `mcpAppsPlugin({ views: './mcp-views.json' })` to your Modern.js plugins. Paths resolve relative to the JSON file. MF cards require the Modern.js MF plugin with manifest output enabled. The UI plugin validates exposes against the actual emitted MF manifest and builds the shell with the application's React dependencies.

The plugin finds the MF manifest in the web build output by filename, `mf-manifest.json` by default, and requires exactly one match. The shell imports `createInstance` from `@module-federation/enhanced/runtime` by default. Other MF implementations can replace both through the `mf` option:

```ts
mcpAppsPlugin({
  views: './mcp-views.json',
  mf: {
    // MF manifest filename in the build output
    manifestFile: 'vmok-manifest.json',
    // Resolved from the application. Must export a compatible createInstance
    runtime: '@vmok/kit/runtime',
  },
});
```

### Reference deployed remotes

When another project publishes the card as an MF remote, set `remote` to the manifest URL of the remote:

```json
{
  "remote": "https://ui.example.com/mf-manifest.json",
  "views": {
    "todos": { "expose": "./Todos" },
    "stats": { "expose": "./Stats" }
  },
  "csp": { "resourceDomains": ["https://cdn.example.com"] }
}
```

The top-level `remote` is shared by all expose views. A view can set its own `remote` to override it. Component paths still reference local components. Without a top-level or view-level `remote`, exposes refer to this application. With a top-level `remote`, expose views in the same config cannot refer to this application's exposes. To mix both, omit the top-level `remote` and set `remote` only on the views that reference a deployed remote.

- The URL must be an absolute HTTP(S) URL whose path ends with `.json`. Entries that are not manifests, such as `remoteEntry.js`, are not supported
- The remote's name is not needed. The runtime reads it from the manifest
- The shell reads the remote manifest and loads the expose when the card opens. Republishing the remote needs no rebuild or restart of the MCP server. Exposes are not checked at build time. A missing expose shows a load error in the card
- This project does not need the MF plugin, but it must install the runtime that `mf.runtime` points to. Set `mf.runtime` as above when the remote uses another MF implementation
- The manifest origin is added to CSP automatically. Declare other origins serving the remote's scripts and styles, such as a CDN, in `csp.resourceDomains`. The manifest and scripts must allow cross-origin requests
- The remote must share React as a singleton so it uses the shell's React
- Adding a card or changing `remote` or `expose` still requires rebuilding the MCP server

Local cards build as separate entries without the framework page runtime. With `source.enableAsyncEntry`, each entry adds a dynamic import boundary so MF shared dependencies can initialize. The MF plugin enables this option automatically. Otherwise cards mount directly without an extra request.


```tsx
import type { McpViewProps } from '@modern-js/mcp-apps/react'

export default function Todos({
  todos = [],
  mcpApp,
}: McpViewProps<{ todos: string[] }>) {
  return (
    <section>
      <ul>
        {todos.map(todo => (
          <li key={todo}>{todo}</li>
        ))}
      </ul>
      <button
        onClick={() =>
          mcpApp.callServerTool({ name: 'refresh', arguments: {} })
        }
      >
        Refresh
      </button>
    </section>
  )
}
```

Props come from successful `structuredContent`. The reserved `mcpApp` prop is injected by the wrapper. Input arguments are not merged into props. New input, cancellation and teardown clear previous output. The wrapper manages connection, host styling and loading/error states. Results from tools called inside a card must be handled by the component itself.

## Write the server

Enable `bffPlugin()` and create `api/lambda/mcp.ts`. The UI plugin does not register the MCP endpoint. Card HTTP pages require per-view opt-in as described below.


```ts
import { McpServer } from '@modelcontextprotocol/server'
import { registerAppTool } from '@modelcontextprotocol/ext-apps/server'
import {
  createBffHandlers,
  registerUiResources,
} from '@modern-js/mcp-apps/server'
import { z } from 'zod'

async function createServer(request: Request) {
  const server = new McpServer({ name: 'todos', version: '1.0.0' })
  const ui = await registerUiResources(server, { request })
  registerAppTool(
    server,
    'list_todos',
    {
      inputSchema: z.object({}),
      _meta: { ui: { resourceUri: ui.todos } },
    },
    async () => ({
      content: [{ type: 'text', text: 'Todo list' }],
      structuredContent: { todos: ['Read the MCP Apps guide'] },
    }),
  )
  return server
}

export const { POST, GET, DELETE } = createBffHandlers(createServer)
```

The adapter reconstructs BFF's consumed JSON body and returns the SDK Response. It reads the raw request through `useHonoContext` from `@modern-js/server-runtime`. Frameworks built on Modern.js can pass their own implementation with `createBffHandlers(createServer, { useContext })`. The official SDK owns protocol serving and tool validation. Serving is stateless, so unsupported session operations such as GET and DELETE are rejected by the SDK. Return a fresh server per request. Put authentication and authorization in surrounding middleware or the factory, and persist business data in an external store.

For independent Hono servers, create `handle = createFetchHandler(createServer)` and mount `app.all('/mcp', c => handle(c.req.raw))`. Foreign browser origins are rejected unless listed in `allowedOrigins` in the adapter's second argument.

## Application entries and URL pages

`mcp-views.json` declares views and their build, resource and page settings. Define tool names, input schemas, handlers and host entrypoint metadata in SDK registration code, rather than in the view JSON. `registerUiResources` registers MCP resources. `resolveUiViews` returns page URLs, resolved UI metadata and render functions. Neither registers business tools.

```json
{
  "views": {
    "home": { "entry": "main", "url": "/" },
    "todos": "./src/components/Todos.tsx",
    "preview": { "component": "./src/components/Preview.tsx", "http": true }
  }
}
```

- `home` references the existing application entry `main`. Its `url` declares the actual application route. Replace the example entry name and path. Entry names do not determine routes. Choose exactly one of `entry`, `component` and `expose`.
- `todos` is a resource-only card by default. `/mcp-views/todos` returns 404.
- `preview` explicitly enables `/mcp-views/preview` with `http: true`. Component and expose views support this option, which defaults to false. These cards can still be registered as MCP resources. Replace component paths with files in your application.

Entry views reuse the application's HTML, React root and routes. They are excluded from MCP UI resources, return 404 under `/mcp-views/`, and do not accept `http`. Top-level browser visits render normally. Embedded visits establish an MCP connection according to `entryAutoConnect`.

### Reference page URLs in tools

URL delivery requires a running page server and a host supporting URL sources. Put the following example in `api/lambda/mcp.ts` to reference the complete application URL through `views.home.url`:

```ts
import { McpServer } from '@modelcontextprotocol/server';
import { createBffHandlers, resolveUiViews } from '@modern-js/mcp-apps/server';

export const { POST, GET, DELETE } = createBffHandlers(async request => {
  const server = new McpServer({ name: 'tasks', version: '1.0.0' });
  const views = await resolveUiViews({ request });
  server.registerTool(
    'open_home',
    {
      title: 'Home',
      inputSchema: {},
      _meta: {
        'doubao/ui': {
          url: views.home.url,
          entrypoints: [{ type: 'global' }],
          csp: views.home.ui.csp,
          permissions: views.home.ui.permissions,
        },
      },
    },
    async () => ({ content: [], structuredContent: { todos: [] } }),
  );
  return server;
});
```

Use `views.preview.url` in the same way for an HTTP-enabled component page. A URL tool must not also declare `_meta.ui.resourceUri`. URL-only servers do not need `registerUiResources`. Use the resource registration example above when resource cards are also needed.

Relative paths use the request's public origin, honoring `x-forwarded-proto` sanitized by a trusted proxy. Override it with `resolveUiViews({ request, publicBaseUrl: 'https://app.example.com' })`, replacing the example domain with the deployed application domain. `publicBaseUrl` must be an HTTP(S) origin without a path, query or fragment and takes precedence over the request origin. An entry's `url` may also be a complete HTTP(S) URL. Static `assetBase` may point to a CDN and is never used as the application page origin.

The `.url` property resolves on access. Reading it throws when an entry has no configured `url`, a component or expose has not enabled `http: true`, or a relative URL has neither a request nor `publicBaseUrl`. Resource-only and stdio servers do not read `.url` and need no additional application origin.

### Resource metadata and host declarations

Configure custom `uri`, `mimeType` and `_meta` in `resource`. `resource._meta.ui` carries CSP and browser permissions. Other fields in `resource._meta` can carry host extensions. The framework preserves declarations in resource listings and resource contents without copying them into tool metadata. URL tools explicitly reference resolved `views.home.ui.csp` and `views.home.ui.permissions`. The host interprets entrypoints, display preferences and permission declarations.

Entry views can also use `resource._meta.ui` for view-specific CSP and browser permissions without registering an MCP resource:

```json
{
  "views": {
    "home": {
      "entry": "main",
      "url": "/",
      "resource": {
        "_meta": {
          "ui": {
            "csp": { "connectDomains": ["https://api.example.com"] },
            "permissions": {}
          }
        }
      }
    }
  }
}
```

Replace the example API domain with the actual service. Known CSP domain arrays merge with defaults and required page origins, removing duplicates. Explicit `permissions` replaces the defaults, including an empty object requesting no browser permissions.

### Migrate and verify

Move any legacy JSON `tool` configuration into SDK registration code. Resource tools bind views through URIs returned by `registerUiResources`. Replace manually assembled page URLs with `.url` from `resolveUiViews`.

Applications previously opening cards through `/mcp-views/<view-name>` must add `http: true` to those component or expose views and rebuild. Cards used only through `resources/read` need no HTTP opt-in.

After building, check `tools/list`. Resource tools should include `_meta.ui.resourceUri`. URL tools should include the complete `_meta["doubao/ui"].url`. Verify that cards without HTTP opt-in return 404 and opted-in cards support GET and HEAD. Open URL tools from the host and verify the page, application routes and entry tool result. Entry scripts emit `mcp-app-connected` and `mcp-app-tool-result`. React pages can use `useEntryMcpApp` to read connection state and retained results.

## Manifest and deployment

Builds emit `dist/mcp-apps/ui-manifest.json` and `dist/mcp-apps/ui/*.html`. Static JavaScript, CSS and MF files remain in the application's standard output. MF-only projects also emit a UI manifest. Local HTML filenames use a stable hash of the view name. MF cards share `mcp-shell.html`.

The version 1 manifest contains `assetBase`, `remotes` and `views`. A local view has `{ html, ui }`. An MF view has `{ remote, expose, ui }`, with its remote declaring `{ entry, shell }`.

- HTML and shell paths resolve relative to the manifest location
- MF entry paths resolve relative to `assetBase`
- Absolute HTTP(S) sources are supported for independent deployments
- `ui` preserves CSP, permissions, domain and border preferences
- Optional `resource` declarations are preserved in the manifest. Without an explicit URI, the server generates `ui://app/<encoded-view-name>`. Multiple tools can share a card
- MF configuration is injected into resource HTML instead of tool results

`createBffHandlers()` associates the server plugin’s manifest path and runtime mode with the current request. Call `registerUiResources(server, { request })` to resolve them automatically. Development uses the framework internal directory and production uses the runtime output directory. Explicit options override injected configuration. Independent services must provide a `manifest` file path or HTTP(S) URL. The `mode` option defaults to `production`. Relative HTML resolves against the manifest location.

Manifests are cached by source URL and environment. Production caches successful loads for the process lifetime, so updating the same location requires a process restart. Development detects local file changes and caches remote manifests for 60 seconds. Concurrent loads are coalesced and failures can be retried. HTML is read per resource request, and request-specific URLs and metadata remain isolated.

An absolute `output.assetPrefix` becomes `assetBase`. Otherwise request-origin resolution is used. Override `assetBase` in `registerUiResources` for a separate static origin or deployment path prefix. Request mode honors sanitized `x-forwarded-proto` headers. Reverse proxies must preserve the public host and sanitize forwarded headers.

Required asset, connection and base URI origins are added to CSP. MF entry origins are also added to connection permissions. The origin of an absolute or protocol-relative `output.assetPrefix` is added at build time, with `//cdn.example/` treated as `https://cdn.example`. Declare any other API, chunk/CDN or iframe origins in `mcp-views.json`, or pass domains computed in the config through `mcpAppsPlugin({ csp })`. Both are merged into every view. Deploy the manifest and HTML together with the application static assets and MF output.

Platforms may rewrite file and MF addresses to absolute URLs and combine cards into another manifest of the same version. Unknown versions are rejected.

## Package a Doubao workbench Plugin

Set `mcpServers` to generate a separate `plugin/` package inside the application output directory during production builds. Set `origin` to the public HTTP(S) application origin. The framework appends `bff.prefix` and `/mcp`, defaulting to `/api/mcp`. An array prefix uses its first item, matching development discovery. Origins cannot contain a path, query or fragment. For custom routes or gateway rewrites, provide a complete `url`, which takes precedence. Deployment environment variables can provide these values. The framework does not infer MCP endpoints from static asset URLs.

```ts
mcpAppsPlugin({
  views: './mcp-views.json',
  mcpServers: {
    // Workbench tool references use server: 'tasks'
    tasks: {
      type: 'streamable-http',
      origin: 'https://app.example.com',
      // Override with a complete URL for custom routes:
      // url: 'https://gateway.example.com/custom/mcp',
    },
  },
  plugin: {
    // Optional, relative to the application root, defaults to 'plugin'
    directory: './plugin',
    resources: ['com.doubao'],
  },
});
```

Create the user-owned `plugin/plugin.json`:

```json
{
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
  "name": "tasks-workbench",
  "version": "1.0.0",
  "description": "Task management workbench",
  "author": { "name": "Example developer" },
  "extensions": {
    "com.doubao": {
      "displayName": { "en": "Tasks" },
      "displayDescription": { "en": "View and manage tasks" },
      "icon": "./com.doubao/assets/plugin-icon.png"
    }
  }
}
```

Place the icon at the declared path. To customize navigation, also provide `com.doubao/workbench/manifest.json`. Workbench configuration references registered tools with `{ "server": "tasks", "name": "open_todos" }`. Define tool parameters, metadata, and handlers only in the MCP server. Follow the [Doubao Plugin workbench protocol](https://bytedance.larkoffice.com/docx/NrkgdZ25QoaMbBx0d5Fcy6kOnzm) for workbench declarations and resources.

```text
plugin/                         # User-owned source package
├─ plugin.json
└─ com.doubao/
   ├─ assets/plugin-icon.png
   └─ workbench/                # Optional configuration and resources
      ├─ manifest.json
      ├─ preinstall-resources.json
      ├─ assets/
      └─ web/

dist/plugin/                    # Generated Plugin package root
├─ plugin.json                  # Copied unchanged
├─ mcp.json                     # Generated by the framework
└─ com.doubao/                  # Copied unchanged
```

The generated `dist/plugin/mcp.json` contains:

```json
{
  "$schema": "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json",
  "mcpServers": {
    "tasks": {
      "type": "streamable-http",
      "url": "https://app.example.com/api/mcp"
    }
  }
}
```

The generated `mcp.json` contains only resolved complete `url` values, without the `origin` shorthand. Replace example domains with actual deployment domains.

The source `plugin.json` is always copied. Set `plugin.resources` to explicitly include additional files or directories relative to the source package, such as `['com.doubao']` for this example or `['assets', 'vendor.example']` for other hosts. The default is `[]`. Declared paths must exist and cannot be absolute, contain empty, `.` or `..` segments, or target the reserved `plugin.json` and `mcp.json` paths. Symbolic links in resource paths or their contents are rejected. A source `mcp.json` is not consumed. Source and output package directories must not overlap, and symbolic links are rejected. Each successful package build replaces `dist/plugin/` to remove stale resources. A custom application output directory also relocates its `plugin/` subdirectory. Without `mcpServers`, no package is generated. Providing `plugin` without `mcpServers` is an error. Development mode does not generate deployment packages.

Deploy the application server and MCP UI assets separately from this declaration and resource package. Packaging does not validate the full Doubao workbench protocol or discover remote tools. It does not generate navigation, compile `web/` pages, or add startup result claims. Author these configurations and pages according to the host protocol and publish them together with the MCP server.

## Native resource metadata

Each component or expose view accepts an optional `resource` declaration:

```json
{
  "views": {
    "sales-overview": {
      "component": "./src/components/SalesOverview.tsx",
      "resource": {
        "uri": "ui://app/sales-overview",
        "mimeType": "text/html;profile=mcp-app",
        "_meta": {
          "ui": {
            "availableDisplayModes": ["inline", "fullscreen"],
            "preferredDisplayMode": "inline",
            "prefersBorder": true,
            "permissions": {},
            "csp": { "connectDomains": ["https://api.example.com"] }
          },
          "vendor/custom": { "enabled": true }
        }
      }
    }
  }
}
```

`resource._meta` is open to host extensions, including unknown fields inside `ui`. The framework preserves these fields in the build manifest, resource registration (`resources/list`), and resource contents (`resources/read`). `resource.mimeType` overrides the SDK default. `resource.uri` overrides the generated `ui://app/<encoded-name>` URI. Define tools and their metadata directly in the MCP server, using `_meta.ui.resourceUri` to reference the registered resource URI.

Per-view `resource._meta.ui` overrides shared UI defaults. The four known CSP domain arrays are merged and deduplicated with shared configuration and page requirements. Unknown CSP fields are preserved. Explicit `permissions`, including `{}`, replaces shared permissions. Other metadata values replace defaults without interpretation. Resource declaration fields such as `title` and `description` are passed to SDK registration. HTML content is generated by the framework, so `text` and `blob` cannot be configured.

Keep tool metadata in the MCP server tool definition’s `_meta`. Resource metadata is not automatically copied into tools or URL-source metadata. Host extensions such as `preferredDisplayMode` are only declarations: the host decides whether to interpret them. They do not change `mcpCapabilities`, request fullscreen, or alter the SDK handshake. URL delivery continues to return `text/html` and uses the existing host-specific tool declaration.

## Card capabilities

Cards advertise `inline` and `fullscreen` by default. Both local component modules and MF exposes can export `mcpCapabilities` to declare additional capabilities or override the display modes.


```tsx
import type { McpCapabilities } from '@modern-js/mcp-apps/react'

export const mcpCapabilities = {
  availableDisplayModes: ['inline'],
} satisfies McpCapabilities

export default function Card() {
  return <div>My card</div>
}
```

You can also pass capabilities as the third argument to `createMcpView`. Explicit display mode arrays replace the defaults. MF modules are loaded before initialization so the handshake includes their capabilities. Declaring fullscreen support does not add a fullscreen button or switch modes automatically.

## Connect to a deployed service

After building and deploying the MCP service, the application developer shares its MCP endpoint with users, for example `https://example.com/api/mcp`. Users do not need to clone the application or Modern.js repository or run `pnpm dev` locally. The service must remain running, and the client must support MCP Apps to display cards.

### Direct HTTP connection

If the client supports Streamable HTTP, select that transport and enter `https://example.com/api/mcp` as the server URL. Configure authentication in the client as required by the service.

### Connect over STDIO

For clients that only support STDIO, users first install Node.js 20 or later (including npm and `npx`), then configure the `modern-mcp-stdio` bridge command. `npx` downloads and runs the specified package version, so users do not need to install Modern.js beforehand.

Replace `<version>` below with a published `@modern-js/mcp-apps` version containing `modern-mcp-stdio`, and replace the URL with the deployed endpoint. Application providers should give users a specific version they have verified.

```json
{
  "mcpServers": {
    "app": {
      "command": "npx",
      "args": [
        "-y",
        "--package=@modern-js/mcp-apps@<version>",
        "modern-mcp-stdio",
        "--url",
        "https://example.com/api/mcp"
      ]
    }
  }
}
```

In clients with a configuration form, enter `npx` as the command and add each item in `args` as a separate argument. If the client cannot find `npx`, enter the absolute path to `npx` on the user's computer. For authentication, append `--header` and `Authorization: Bearer <token>` as two arguments. Repeat this pair for additional headers.

This configuration uses `--url` to connect to the deployed HTTP service. The `--cwd` option and local script paths in the debugging section below are for development and do not need to be shared with end users. The bridge does not start or deploy the application service.

To bundle local component cards as self-contained HTML in production, application developers set `inline: true` in `mcpAppsPlugin` before building and deploying. `inline: 'dev'` only applies in development. MF cards still require the host to access their remote assets.

## Local stdio debugging

For local MCP hosts that connect over stdio or restrict sandboxed iframes from loading localhost assets, enable `inline` in `mcpAppsPlugin` and run `pnpm dev` to start the development server.

```ts
mcpAppsPlugin({
  views: './mcp-views.json',
  // 'dev' inlines local views during dev only, true applies to both dev and build
  inline: 'dev',
});
```

When `pnpm dev` starts, the terminal prints a ready-to-copy connector config using the built-in lightweight `modern-mcp-stdio` bridge script, which forwards stdio JSON-RPC messages directly to the running HTTP dev server (for example `http://localhost:8088/api/mcp`):

```json
{
  "mcpServers": {
    "app": {
      "command": "node",
      "args": [
        "<app>/node_modules/@modern-js/mcp-apps/bin/modern-mcp-stdio.js",
        "--cwd",
        "<app>"
      ]
    }
  }
}
```

- **Request handling**: The development server handles HTTP requests through the application’s BFF routes, custom Hono middleware, and server plugins. Pass `--header "Authorization: Bearer <token>"` (repeatable) if your middleware expects custom headers.
- **Dynamic port discovery**: The generated connector uses `--cwd <app-dir>` to read `node_modules/.modern-js/mcp-apps/dev-server.json` written by `modern dev` on each request. A fixed HTTP MCP URL is also supported.
- **Incremental rebuilds**: In inline mode, local component views are built by an isolated watch compiler into self-contained HTML (inlining JS, CSS, and imported assets, up to 5 MiB per view, without injecting `<base>` or localhost CSP). Edits take effect on the next card read without affecting normal app page HMR. If `mcp-views.json` mixes local views and Module Federation views, local views are inlined while MF views use the HTTP shell.
- **Clean stdio stream**: Dev logs stay in your `pnpm dev` terminal while the bridge reserves `stdout` strictly for JSON-RPC. If `modern dev` is stopped or restarting, the bridge returns a JSON-RPC error instead of exiting and recovers automatically once the dev server is back.

Entry connection browser events are notifications for non-React consumers, not state snapshots. The bootstrap emits `mcp-app-teardown` when the host closes the view. Late results and connection callbacks are ignored after teardown. React consumers should use `useEntryMcpApp` to read the retained snapshot and subscribe to changes. Its initial status is `standalone` until the bootstrap starts connecting. Embedding in an iframe triggers a handshake attempt and does not by itself establish that the parent is an MCP host.

For applications also embedded in ordinary iframes, set `mcpAppsPlugin({ entryAutoConnect: false })` to disable the injected handshake. Call `connectEntryMcpApp()` from `@modern-js/mcp-apps/react` only when your application integration explicitly selects MCP mode. Repeated calls reuse the active connection. Top-level and server-side calls do nothing. A failed connection releases the App instance so an explicit call can retry. Host identity is established by the SDK handshake, not by iframe detection.
