@modelcontextprotocol/ext-apps 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,7 @@ export type McpUiDisplayMode = "inline" | "fullscreen" | "pip";
28
28
  /**
29
29
  * @description CSS variable keys available to MCP apps for theming.
30
30
  */
31
- export type McpUiStyleVariableKey = "--color-background-primary" | "--color-background-secondary" | "--color-background-tertiary" | "--color-background-inverse" | "--color-background-ghost" | "--color-background-info" | "--color-background-danger" | "--color-background-success" | "--color-background-warning" | "--color-background-disabled" | "--color-text-primary" | "--color-text-secondary" | "--color-text-tertiary" | "--color-text-inverse" | "--color-text-info" | "--color-text-danger" | "--color-text-success" | "--color-text-warning" | "--color-text-disabled" | "--color-border-primary" | "--color-border-secondary" | "--color-border-tertiary" | "--color-border-inverse" | "--color-border-ghost" | "--color-border-info" | "--color-border-danger" | "--color-border-success" | "--color-border-warning" | "--color-border-disabled" | "--color-ring-primary" | "--color-ring-secondary" | "--color-ring-inverse" | "--color-ring-info" | "--color-ring-danger" | "--color-ring-success" | "--color-ring-warning" | "--font-sans" | "--font-mono" | "--font-weight-normal" | "--font-weight-medium" | "--font-weight-semibold" | "--font-weight-bold" | "--font-text-xs-size" | "--font-text-sm-size" | "--font-text-md-size" | "--font-text-lg-size" | "--font-heading-xs-size" | "--font-heading-sm-size" | "--font-heading-md-size" | "--font-heading-lg-size" | "--font-heading-xl-size" | "--font-heading-2xl-size" | "--font-heading-3xl-size" | "--font-text-xs-line-height" | "--font-text-sm-line-height" | "--font-text-md-line-height" | "--font-text-lg-line-height" | "--font-heading-xs-line-height" | "--font-heading-sm-line-height" | "--font-heading-md-line-height" | "--font-heading-lg-line-height" | "--font-heading-xl-line-height" | "--font-heading-2xl-line-height" | "--font-heading-3xl-line-height" | "--border-radius-xs" | "--border-radius-sm" | "--border-radius-md" | "--border-radius-lg" | "--border-radius-xl" | "--border-radius-full" | "--border-width-regular" | "--shadow-hairline" | "--shadow-sm" | "--shadow-md" | "--shadow-lg";
31
+ export type McpUiStyleVariableKey = "--color-background-primary" | "--color-background-secondary" | "--color-background-tertiary" | "--color-background-inverse" | "--color-background-ghost" | "--color-background-info" | "--color-background-danger" | "--color-background-success" | "--color-background-warning" | "--color-background-disabled" | "--color-text-primary" | "--color-text-secondary" | "--color-text-tertiary" | "--color-text-inverse" | "--color-text-info" | "--color-text-danger" | "--color-text-success" | "--color-text-warning" | "--color-text-disabled" | "--color-text-ghost" | "--color-border-primary" | "--color-border-secondary" | "--color-border-tertiary" | "--color-border-inverse" | "--color-border-ghost" | "--color-border-info" | "--color-border-danger" | "--color-border-success" | "--color-border-warning" | "--color-border-disabled" | "--color-ring-primary" | "--color-ring-secondary" | "--color-ring-inverse" | "--color-ring-info" | "--color-ring-danger" | "--color-ring-success" | "--color-ring-warning" | "--font-sans" | "--font-mono" | "--font-weight-normal" | "--font-weight-medium" | "--font-weight-semibold" | "--font-weight-bold" | "--font-text-xs-size" | "--font-text-sm-size" | "--font-text-md-size" | "--font-text-lg-size" | "--font-heading-xs-size" | "--font-heading-sm-size" | "--font-heading-md-size" | "--font-heading-lg-size" | "--font-heading-xl-size" | "--font-heading-2xl-size" | "--font-heading-3xl-size" | "--font-text-xs-line-height" | "--font-text-sm-line-height" | "--font-text-md-line-height" | "--font-text-lg-line-height" | "--font-heading-xs-line-height" | "--font-heading-sm-line-height" | "--font-heading-md-line-height" | "--font-heading-lg-line-height" | "--font-heading-xl-line-height" | "--font-heading-2xl-line-height" | "--font-heading-3xl-line-height" | "--border-radius-xs" | "--border-radius-sm" | "--border-radius-md" | "--border-radius-lg" | "--border-radius-xl" | "--border-radius-full" | "--border-width-regular" | "--shadow-hairline" | "--shadow-sm" | "--shadow-md" | "--shadow-lg";
32
32
  /**
33
33
  * @description Style variables for theming MCP apps.
34
34
  *
@@ -172,12 +172,21 @@ export interface McpUiToolCancelledNotification {
172
172
  reason?: string;
173
173
  };
174
174
  }
175
+ /**
176
+ * @description CSS blocks that can be injected by apps.
177
+ */
178
+ export interface McpUiHostCss {
179
+ /** @description CSS for font loading (@font-face rules or @import statements). Apps must apply using applyHostFonts(). */
180
+ fonts?: string;
181
+ }
175
182
  /**
176
183
  * @description Style configuration for theming MCP apps.
177
184
  */
178
185
  export interface McpUiHostStyles {
179
186
  /** @description CSS variables for theming the app. */
180
187
  variables?: McpUiStyles;
188
+ /** @description CSS blocks that apps can inject. */
189
+ css?: McpUiHostCss;
181
190
  }
182
191
  /**
183
192
  * @description Rich context about the host environment provided to Guest UIs.
@@ -87,3 +87,55 @@ export declare function applyDocumentTheme(theme: McpUiTheme): void;
87
87
  * @see {@link McpUiHostContext} for the full host context structure
88
88
  */
89
89
  export declare function applyHostStyleVariables(styles: McpUiStyles, root?: HTMLElement): void;
90
+ /**
91
+ * Apply host font CSS to the document.
92
+ *
93
+ * This function takes the `css.fonts` string from `McpUiHostContext.styles` and
94
+ * injects it as a `<style>` tag. The CSS can contain `@font-face` rules for
95
+ * self-hosted fonts, `@import` statements for Google Fonts or other font services,
96
+ * or a combination of both.
97
+ *
98
+ * The styles are only injected once. Subsequent calls will not create duplicate
99
+ * style tags.
100
+ *
101
+ * @param fontCss - CSS string containing @font-face rules and/or @import statements
102
+ *
103
+ * @example Apply fonts from host context
104
+ * ```typescript
105
+ * import { applyHostFonts } from '@modelcontextprotocol/ext-apps';
106
+ *
107
+ * app.onhostcontextchanged = (params) => {
108
+ * if (params.styles?.css?.fonts) {
109
+ * applyHostFonts(params.styles.css.fonts);
110
+ * }
111
+ * };
112
+ * ```
113
+ *
114
+ * @example Host providing self-hosted fonts
115
+ * ```typescript
116
+ * hostContext.styles.css.fonts = `
117
+ * @font-face {
118
+ * font-family: "Anthropic Sans";
119
+ * src: url("https://assets.anthropic.com/.../Regular.otf") format("opentype");
120
+ * font-weight: 400;
121
+ * }
122
+ * `;
123
+ * ```
124
+ *
125
+ * @example Host providing Google Fonts
126
+ * ```typescript
127
+ * hostContext.styles.css.fonts = `
128
+ * @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
129
+ * `;
130
+ * ```
131
+ *
132
+ * @example Use host fonts in CSS
133
+ * ```css
134
+ * body {
135
+ * font-family: "Anthropic Sans", sans-serif;
136
+ * }
137
+ * ```
138
+ *
139
+ * @see {@link McpUiHostContext} for the full host context structure
140
+ */
141
+ export declare function applyHostFonts(fontCss: string): void;
@@ -8,9 +8,9 @@
8
8
  * @see generated/schema.ts for auto-generated Zod schemas
9
9
  * @see generated/schema.test.ts for compile-time verification
10
10
  */
11
- export { LATEST_PROTOCOL_VERSION, type McpUiTheme, type McpUiDisplayMode, type McpUiStyleVariableKey, type McpUiStyles, type McpUiHostStyles, type McpUiOpenLinkRequest, type McpUiOpenLinkResult, type McpUiMessageRequest, type McpUiMessageResult, type McpUiSandboxProxyReadyNotification, type McpUiSandboxResourceReadyNotification, type McpUiSizeChangedNotification, type McpUiToolInputNotification, type McpUiToolInputPartialNotification, type McpUiToolResultNotification, type McpUiToolCancelledNotification, type McpUiHostContext, type McpUiHostContextChangedNotification, type McpUiResourceTeardownRequest, type McpUiResourceTeardownResult, type McpUiHostCapabilities, type McpUiAppCapabilities, type McpUiInitializeRequest, type McpUiInitializeResult, type McpUiInitializedNotification, type McpUiResourceCsp, type McpUiResourceMeta, type McpUiRequestDisplayModeRequest, type McpUiRequestDisplayModeResult, type McpUiToolVisibility, type McpUiToolMeta, } from "./spec.types.js";
11
+ export { LATEST_PROTOCOL_VERSION, type McpUiTheme, type McpUiDisplayMode, type McpUiStyleVariableKey, type McpUiStyles, type McpUiHostCss, type McpUiHostStyles, type McpUiOpenLinkRequest, type McpUiOpenLinkResult, type McpUiMessageRequest, type McpUiMessageResult, type McpUiSandboxProxyReadyNotification, type McpUiSandboxResourceReadyNotification, type McpUiSizeChangedNotification, type McpUiToolInputNotification, type McpUiToolInputPartialNotification, type McpUiToolResultNotification, type McpUiToolCancelledNotification, type McpUiHostContext, type McpUiHostContextChangedNotification, type McpUiResourceTeardownRequest, type McpUiResourceTeardownResult, type McpUiHostCapabilities, type McpUiAppCapabilities, type McpUiInitializeRequest, type McpUiInitializeResult, type McpUiInitializedNotification, type McpUiResourceCsp, type McpUiResourceMeta, type McpUiRequestDisplayModeRequest, type McpUiRequestDisplayModeResult, type McpUiToolVisibility, type McpUiToolMeta, } from "./spec.types.js";
12
12
  import type { McpUiInitializeRequest, McpUiOpenLinkRequest, McpUiMessageRequest, McpUiResourceTeardownRequest, McpUiRequestDisplayModeRequest, McpUiHostContextChangedNotification, McpUiToolInputNotification, McpUiToolInputPartialNotification, McpUiToolResultNotification, McpUiToolCancelledNotification, McpUiSandboxResourceReadyNotification, McpUiInitializedNotification, McpUiSizeChangedNotification, McpUiSandboxProxyReadyNotification, McpUiInitializeResult, McpUiOpenLinkResult, McpUiMessageResult, McpUiResourceTeardownResult, McpUiRequestDisplayModeResult } from "./spec.types.js";
13
- export { McpUiThemeSchema, McpUiDisplayModeSchema, McpUiHostStylesSchema, McpUiOpenLinkRequestSchema, McpUiOpenLinkResultSchema, McpUiMessageRequestSchema, McpUiMessageResultSchema, McpUiSandboxProxyReadyNotificationSchema, McpUiSandboxResourceReadyNotificationSchema, McpUiSizeChangedNotificationSchema, McpUiToolInputNotificationSchema, McpUiToolInputPartialNotificationSchema, McpUiToolResultNotificationSchema, McpUiToolCancelledNotificationSchema, McpUiHostContextSchema, McpUiHostContextChangedNotificationSchema, McpUiResourceTeardownRequestSchema, McpUiResourceTeardownResultSchema, McpUiHostCapabilitiesSchema, McpUiAppCapabilitiesSchema, McpUiInitializeRequestSchema, McpUiInitializeResultSchema, McpUiInitializedNotificationSchema, McpUiResourceCspSchema, McpUiResourceMetaSchema, McpUiRequestDisplayModeRequestSchema, McpUiRequestDisplayModeResultSchema, McpUiToolVisibilitySchema, McpUiToolMetaSchema, } from "./generated/schema.js";
13
+ export { McpUiThemeSchema, McpUiDisplayModeSchema, McpUiHostCssSchema, McpUiHostStylesSchema, McpUiOpenLinkRequestSchema, McpUiOpenLinkResultSchema, McpUiMessageRequestSchema, McpUiMessageResultSchema, McpUiSandboxProxyReadyNotificationSchema, McpUiSandboxResourceReadyNotificationSchema, McpUiSizeChangedNotificationSchema, McpUiToolInputNotificationSchema, McpUiToolInputPartialNotificationSchema, McpUiToolResultNotificationSchema, McpUiToolCancelledNotificationSchema, McpUiHostContextSchema, McpUiHostContextChangedNotificationSchema, McpUiResourceTeardownRequestSchema, McpUiResourceTeardownResultSchema, McpUiHostCapabilitiesSchema, McpUiAppCapabilitiesSchema, McpUiInitializeRequestSchema, McpUiInitializeResultSchema, McpUiInitializedNotificationSchema, McpUiResourceCspSchema, McpUiResourceMetaSchema, McpUiRequestDisplayModeRequestSchema, McpUiRequestDisplayModeResultSchema, McpUiToolVisibilitySchema, McpUiToolMetaSchema, } from "./generated/schema.js";
14
14
  import { CallToolRequest, CallToolResult, EmptyResult, ListPromptsRequest, ListPromptsResult, ListResourcesRequest, ListResourcesResult, ListResourceTemplatesRequest, ListResourceTemplatesResult, ListToolsRequest, ListToolsResult, LoggingMessageNotification, PingRequest, PromptListChangedNotification, ReadResourceRequest, ReadResourceResult, ResourceListChangedNotification, ToolListChangedNotification } from "@modelcontextprotocol/sdk/types.js";
15
15
  /**
16
16
  * All request types in the MCP Apps protocol.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "https://github.com/modelcontextprotocol/ext-apps"
6
6
  },
7
7
  "homepage": "https://github.com/modelcontextprotocol/ext-apps",
8
- "version": "0.2.0",
8
+ "version": "0.2.2",
9
9
  "license": "MIT",
10
10
  "description": "MCP Apps SDK — Enable MCP servers to display interactive user interfaces in conversational clients.",
11
11
  "type": "module",
@@ -97,17 +97,17 @@
97
97
  "prettier": "^3.6.2"
98
98
  },
99
99
  "optionalDependencies": {
100
- "@oven/bun-darwin-aarch64": "^1.3.4",
101
- "@oven/bun-darwin-x64": "^1.3.4",
102
- "@oven/bun-darwin-x64-baseline": "^1.3.4",
103
- "@oven/bun-linux-aarch64": "^1.3.4",
104
- "@oven/bun-linux-aarch64-musl": "^1.3.4",
105
- "@oven/bun-linux-x64": "^1.3.4",
106
- "@oven/bun-linux-x64-baseline": "^1.3.4",
107
- "@oven/bun-linux-x64-musl": "^1.3.4",
108
- "@oven/bun-linux-x64-musl-baseline": "^1.3.4",
109
- "@oven/bun-windows-x64": "^1.3.4",
110
- "@oven/bun-windows-x64-baseline": "^1.3.4",
100
+ "@oven/bun-darwin-aarch64": "^1.2.21",
101
+ "@oven/bun-darwin-x64": "^1.2.21",
102
+ "@oven/bun-darwin-x64-baseline": "^1.2.21",
103
+ "@oven/bun-linux-aarch64": "^1.2.21",
104
+ "@oven/bun-linux-aarch64-musl": "^1.2.21",
105
+ "@oven/bun-linux-x64": "^1.2.21",
106
+ "@oven/bun-linux-x64-baseline": "^1.2.21",
107
+ "@oven/bun-linux-x64-musl": "^1.2.21",
108
+ "@oven/bun-linux-x64-musl-baseline": "^1.2.21",
109
+ "@oven/bun-windows-x64": "^1.2.21",
110
+ "@oven/bun-windows-x64-baseline": "^1.2.21",
111
111
  "@rollup/rollup-darwin-arm64": "^4.53.3",
112
112
  "@rollup/rollup-darwin-x64": "^4.53.3",
113
113
  "@rollup/rollup-linux-arm64-gnu": "^4.53.3",