@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.
@@ -51,6 +51,71 @@ import { McpUiHostContext } from "../types";
51
51
  *
52
52
  * @see {@link applyHostStyleVariables} for the underlying styles function
53
53
  * @see {@link applyDocumentTheme} for the underlying theme function
54
+ * @see {@link useHostFonts} for applying host fonts
54
55
  * @see {@link McpUiStyles} for available CSS variables
55
56
  */
56
57
  export declare function useHostStyleVariables(app: App | null, initialContext?: McpUiHostContext | null): void;
58
+ /**
59
+ * React hook that applies host fonts from CSS.
60
+ *
61
+ * This hook listens to host context changes and automatically applies:
62
+ * - `styles.css.fonts` as a `<style>` tag for custom fonts
63
+ *
64
+ * The CSS can contain `@font-face` rules for self-hosted fonts,
65
+ * `@import` statements for Google Fonts or other font services, or both.
66
+ *
67
+ * The hook also applies fonts from the initial host context when
68
+ * the app first connects.
69
+ *
70
+ * @param app - The connected App instance, or null during initialization
71
+ * @param initialContext - Initial host context from the connection (optional).
72
+ * If provided, fonts will be applied immediately on mount.
73
+ *
74
+ * @example Basic usage with useApp
75
+ * ```tsx
76
+ * import { useApp } from '@modelcontextprotocol/ext-apps/react';
77
+ * import { useHostFonts } from '@modelcontextprotocol/ext-apps/react';
78
+ *
79
+ * function MyApp() {
80
+ * const { app, isConnected } = useApp({
81
+ * appInfo: { name: "MyApp", version: "1.0.0" },
82
+ * capabilities: {},
83
+ * });
84
+ *
85
+ * // Automatically apply host fonts
86
+ * useHostFonts(app);
87
+ *
88
+ * return (
89
+ * <div style={{ fontFamily: 'var(--font-sans)' }}>
90
+ * Hello!
91
+ * </div>
92
+ * );
93
+ * }
94
+ * ```
95
+ *
96
+ * @example With initial context
97
+ * ```tsx
98
+ * const [hostContext, setHostContext] = useState<McpUiHostContext | null>(null);
99
+ *
100
+ * // ... get initial context from app.connect() result
101
+ *
102
+ * useHostFonts(app, hostContext);
103
+ * ```
104
+ *
105
+ * @see {@link applyHostFonts} for the underlying fonts function
106
+ * @see {@link useHostStyleVariables} for applying style variables and theme
107
+ */
108
+ export declare function useHostFonts(app: App | null, initialContext?: McpUiHostContext | null): void;
109
+ /**
110
+ * React hook that applies host styles, fonts, and theme.
111
+ *
112
+ * This is a convenience hook that combines {@link useHostStyleVariables} and
113
+ * {@link useHostFonts}. Use the individual hooks if you need more control.
114
+ *
115
+ * @param app - The connected App instance, or null during initialization
116
+ * @param initialContext - Initial host context from the connection (optional).
117
+ *
118
+ * @see {@link useHostStyleVariables} for style variables and theme only
119
+ * @see {@link useHostFonts} for fonts only
120
+ */
121
+ export declare function useHostStyles(app: App | null, initialContext?: McpUiHostContext | null): void;