@modelcontextprotocol/ext-apps - v1.1.2
    Preparing search index...

    Function getUiCapability

    • Get MCP Apps capability settings from client capabilities.

      This helper retrieves the capability object from the extensions field where MCP Apps advertises its support.

      Note: The clientCapabilities parameter extends the SDK's ClientCapabilities type with an extensions field (pending SEP-1724). Once extensions is added to the SDK, this can use ClientCapabilities directly.

      Parameters

      • clientCapabilities:
            | {
                elicitation?: {
                    form?: { applyDefaults?: boolean; [key: string]: unknown };
                    url?: object;
                    [key: string]: unknown;
                };
                experimental?: { [key: string]: object };
                roots?: { listChanged?: boolean };
                sampling?: { context?: object; tools?: object };
                tasks?: {
                    cancel?: object;
                    list?: object;
                    requests?: {
                        elicitation?: { create?: object; [key: string]: unknown };
                        sampling?: { createMessage?: object; [key: string]: unknown };
                        [key: string]: unknown;
                    };
                    [key: string]: unknown;
                };
            } & { extensions?: Record<string, unknown> }
            | null
            | undefined

        The client capabilities from the initialize response

      Returns McpUiClientCapabilities | undefined

      The MCP Apps capability settings, or undefined if not supported

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

      if (uiCap?.mimeTypes?.includes(RESOURCE_MIME_TYPE)) {
      // App-enhanced tool
      registerAppTool(
      server,
      "weather",
      {
      description: "Get weather information with interactive dashboard",
      _meta: { ui: { resourceUri: "ui://weather/dashboard" } },
      },
      weatherHandler,
      );
      } else {
      // Text-only fallback
      server.registerTool(
      "weather",
      {
      description: "Get weather information",
      },
      textWeatherHandler,
      );
      }
      };