The client capabilities from the initialize response
The MCP Apps capability settings, or undefined if not supported
import { getUiCapability, RESOURCE_MIME_TYPE, registerAppTool } from "@modelcontextprotocol/ext-apps/server";
server.oninitialized = ({ clientCapabilities }) => {
const uiCap = getUiCapability(clientCapabilities);
if (uiCap?.mimeTypes?.includes(RESOURCE_MIME_TYPE)) {
registerAppTool(server, "weather", {
description: "Get weather with interactive dashboard",
_meta: { ui: { resourceUri: "ui://weather/dashboard" } },
}, weatherHandler);
} else {
// Register text-only fallback
server.registerTool("weather", {
description: "Get weather as text",
}, textWeatherHandler);
}
};
Get MCP Apps capability settings from client capabilities.
This helper retrieves the capability object from the
extensionsfield where MCP Apps advertises its support.Note: The
clientCapabilitiesparameter extends the SDK'sClientCapabilitiestype with anextensionsfield (pending SEP-1724). Onceextensionsis added to the SDK, this can useClientCapabilitiesdirectly.