> ## Documentation Index
> Fetch the complete documentation index at: https://sunpeak.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Apps Capability Detection

> Detect whether an MCP host supports Apps UI before registering tools. Use getUiCapability and EXTENSION_ID to check for MCP Apps support in ChatGPT, Claude, and other hosts.

<Badge color="green">MCP Apps SDK</Badge>

```ts theme={null}
import { getUiCapability, EXTENSION_ID, RESOURCE_MIME_TYPE } from "@modelcontextprotocol/ext-apps/server";
```

## Overview

Not all MCP hosts support Apps yet. Servers should check whether the connecting host supports MCP Apps before registering UI-enabled tools — if it doesn't, register text-only fallback tools instead. This keeps your server compatible with every host while delivering rich UIs where available.

## getUiCapability

Extracts the MCP Apps capability from the client's `extensions` field.

### Signature

```ts theme={null}
function getUiCapability(
  clientCapabilities: ClientCapabilities | null | undefined,
): McpUiClientCapabilities | undefined
```

### Returns

<ResponseField name="return" type="McpUiClientCapabilities | undefined">
  The capability object if the host supports MCP Apps, or `undefined` if not.

  <ResponseField name="mimeTypes" type="string[]">
    Supported MIME types. Must include `"text/html;profile=mcp-app"` for MCP Apps support.
  </ResponseField>
</ResponseField>

### Usage

Use `server.server.oninitialized` to check capabilities after the MCP handshake:

```ts theme={null}
import {
  getUiCapability,
  registerAppTool,
  RESOURCE_MIME_TYPE,
} from "@modelcontextprotocol/ext-apps/server";

server.server.oninitialized = () => {
  const clientCapabilities = server.server.getClientCapabilities();
  const uiCap = getUiCapability(clientCapabilities);

  if (uiCap?.mimeTypes?.includes(RESOURCE_MIME_TYPE)) {
    // Host supports MCP Apps — register tool with UI
    registerAppTool(
      server,
      "weather",
      {
        description: "Get weather with interactive dashboard",
        _meta: { ui: { resourceUri: "ui://weather/dashboard" } },
      },
      weatherHandler,
    );
  } else {
    // Host does not support MCP Apps — register text-only fallback
    server.registerTool(
      "weather",
      { description: "Get weather information" },
      textWeatherHandler,
    );
  }
};
```

## EXTENSION\_ID

The extension identifier used in the MCP `extensions` field for capability negotiation.

```ts theme={null}
const EXTENSION_ID = "io.modelcontextprotocol/ui";
```

Hosts advertise MCP Apps support by including this key in their `extensions` capabilities during the [MCP initialization](/docs/mcp-apps/mcp/overview#connection-lifecycle) [handshake](/docs/mcp-apps/lifecycle#2-initialization). `getUiCapability` reads from this key internally.

<Tip>
  In the [sunpeak framework](/docs/quickstart), capability detection is handled in the [Server Entry](/docs/app-framework/tools/server-entry).
</Tip>
