Skip to main content
MCP Apps SDK
import { App } from "@modelcontextprotocol/ext-apps";

Overview

getHostCapabilities() returns the capabilities the host advertised during the initialization handshake. Use this for feature detection — check whether a capability exists before calling the corresponding method. Returns undefined before connect() completes.

Signature

getHostCapabilities(): McpUiHostCapabilities | undefined

Returns

return
McpUiHostCapabilities | undefined
The host’s capabilities, or undefined if the app has not connected yet. See McpUiHostCapabilities for the full type definition.

Usage

Check before calling server tools

await app.connect();

const caps = app.getHostCapabilities();
if (caps?.serverTools) {
  const result = await app.callServerTool({
    name: "get_weather",
    arguments: { location: "Tokyo" },
  });
}

Check before sending messages

if (app.getHostCapabilities()?.message) {
  await app.sendMessage({
    role: "user",
    content: [{ type: "text", text: "Show details" }],
  });
}

Check before downloading files

if (app.getHostCapabilities()?.downloadFile) {
  await app.downloadFile({
    contents: [{
      type: "resource",
      resource: {
        uri: "file:///export.json",
        mimeType: "application/json",
        text: JSON.stringify(data),
      },
    }],
  });
}

Build a capabilities summary

const caps = app.getHostCapabilities();
const features = {
  canCallTools: !!caps?.serverTools,
  canReadResources: !!caps?.serverResources,
  canSendMessages: !!caps?.message,
  canUpdateContext: !!caps?.updateModelContext,
  canOpenLinks: !!caps?.openLinks,
  canDownloadFiles: !!caps?.downloadFile,
  canLog: !!caps?.logging,
};

Capability Fields

FieldEnables
openLinksopenLink()
downloadFiledownloadFile()
serverToolscallServerTool()
serverResourcesreadServerResource(), listServerResources()
loggingsendLog()
updateModelContextupdateModelContext()
messagesendMessage()
sandboxHost-enforced sandbox permissions and CSP