open-mcp-app 0.1.2 → 0.1.4

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.
@@ -217,33 +217,72 @@ interface WebSocketClient<TSend = unknown, TReceive = unknown> {
217
217
  interface UnifiedHostClientEvents extends BaseHostClientEvents, McpAppsHostClientEvents {
218
218
  }
219
219
  /**
220
- * Unified host client interface.
220
+ * Experimental host APIs that are not part of the MCP Apps spec.
221
221
  *
222
- * This is the primary interface returned by `createHost()`.
223
- * It combines the base interface with host-specific extensions,
224
- * providing a consistent API across all platforms.
222
+ * These APIs may change or be removed in future versions. They provide
223
+ * access to Creature-specific features and other non-standard extensions.
224
+ *
225
+ * Similar to Vercel AI SDK's `experimental_*` pattern, these APIs are
226
+ * grouped under a separate namespace to clearly indicate their status.
225
227
  */
226
- interface UnifiedHostClient {
227
- /** Get current state */
228
- getState(): HostClientState;
229
- /** Subscribe to state changes. Returns unsubscribe function. */
230
- subscribe(listener: StateListener): () => void;
231
- /** Call a tool on the MCP server */
232
- callTool<T = Record<string, unknown>>(toolName: string, args: Record<string, unknown>): Promise<ToolResult<T>>;
228
+ interface ExperimentalHostApi {
233
229
  /**
234
- * Send a notification to the host.
230
+ * Send a raw notification to the host.
231
+ *
232
+ * This is a low-level API for sending custom notifications. Most apps
233
+ * should use higher-level methods like `setWidgetState` or `setTitle`.
235
234
  *
236
235
  * MCP Apps only - no-op on ChatGPT.
236
+ *
237
+ * @param method - The notification method name (e.g., "ui/notifications/...")
238
+ * @param params - The notification parameters
237
239
  */
238
240
  sendNotification(method: string, params: unknown): void;
239
- /** Set widget state */
241
+ /**
242
+ * Set widget state and notify the host.
243
+ *
244
+ * Widget state is synchronized with the host for persistence across
245
+ * sessions and visibility to the AI model.
246
+ *
247
+ * **Non-spec extension:** On MCP Apps hosts, this sends a
248
+ * `ui/notifications/widget-state-changed` notification (Creature extension).
249
+ * On ChatGPT, this uses the native `window.openai.setWidgetState` bridge.
250
+ *
251
+ * @param state - New widget state (or null to clear)
252
+ */
240
253
  setWidgetState(state: WidgetState | null): void;
241
254
  /**
242
255
  * Set the pip/widget title displayed in the host UI.
243
256
  *
244
- * Creature extension - no-op on ChatGPT and generic MCP Apps hosts.
257
+ * **Creature-only extension:** This sends a `ui/notifications/title-changed`
258
+ * notification. No-op on ChatGPT and generic MCP Apps hosts.
259
+ *
260
+ * @param title - The new title to display
245
261
  */
246
262
  setTitle(title: string): void;
263
+ /**
264
+ * Get Creature-specific CSS style variables.
265
+ *
266
+ * **Creature-only extension:** Returns custom CSS variables provided by the
267
+ * Creature host via `hostContext.creatureStyles`. Returns null when not
268
+ * running in Creature or styles are not available.
269
+ */
270
+ getCreatureStyles(): Record<string, string | undefined> | null;
271
+ }
272
+ /**
273
+ * Unified host client interface.
274
+ *
275
+ * This is the primary interface returned by `createHost()`.
276
+ * It combines the base interface with host-specific extensions,
277
+ * providing a consistent API across all platforms.
278
+ */
279
+ interface UnifiedHostClient {
280
+ /** Get current state */
281
+ getState(): HostClientState;
282
+ /** Subscribe to state changes. Returns unsubscribe function. */
283
+ subscribe(listener: StateListener): () => void;
284
+ /** Call a tool on the MCP server */
285
+ callTool<T = Record<string, unknown>>(toolName: string, args: Record<string, unknown>): Promise<ToolResult<T>>;
247
286
  /**
248
287
  * Request a display mode change from the host.
249
288
  */
@@ -282,6 +321,24 @@ interface UnifiedHostClient {
282
321
  * Returns null before connection is established.
283
322
  */
284
323
  getHostContext(): HostContext | null;
324
+ /**
325
+ * Experimental APIs that are not part of the MCP Apps spec.
326
+ *
327
+ * These APIs provide access to Creature-specific features and other
328
+ * non-standard extensions. They may change or be removed in future versions.
329
+ *
330
+ * @example
331
+ * ```typescript
332
+ * // Set widget state (non-spec extension)
333
+ * client.experimental.setWidgetState({ count: 42 });
334
+ *
335
+ * // Set title (Creature-only)
336
+ * if (client.isCreature) {
337
+ * client.experimental.setTitle("My Widget");
338
+ * }
339
+ * ```
340
+ */
341
+ readonly experimental: ExperimentalHostApi;
285
342
  }
286
343
  /**
287
344
  * The kind of adapter in use.
@@ -680,6 +737,11 @@ declare class McpAppsAdapter implements HostAdapter {
680
737
  * Base MCP Apps adapter returns false - CreatureAdapter overrides this.
681
738
  */
682
739
  get isCreature(): boolean;
740
+ /**
741
+ * Experimental APIs for non-spec extensions.
742
+ * Base MCP Apps adapter provides minimal implementations - CreatureAdapter overrides.
743
+ */
744
+ get experimental(): ExperimentalHostApi;
683
745
  /**
684
746
  * Get the host context received from the host.
685
747
  * Useful for checking host-specific capabilities.
@@ -688,13 +750,6 @@ declare class McpAppsAdapter implements HostAdapter {
688
750
  getState(): HostClientState;
689
751
  subscribe(listener: StateListener): () => void;
690
752
  callTool<T = Record<string, unknown>>(toolName: string, args: Record<string, unknown>): Promise<ToolResult<T>>;
691
- sendNotification(method: string, params: unknown): void;
692
- setWidgetState(state: WidgetState | null): void;
693
- /**
694
- * Set pip/widget title.
695
- * Sends a notification - hosts that support it will update the title.
696
- */
697
- setTitle(title: string): void;
698
753
  requestDisplayMode(params: {
699
754
  mode: DisplayMode;
700
755
  }): Promise<{
@@ -776,21 +831,14 @@ declare class UpgradingMcpAppsClient implements HostAdapter {
776
831
  get isCreature(): boolean;
777
832
  get environment(): Environment;
778
833
  /**
779
- * Get Creature-specific styles if available.
780
- * Returns null when not running in Creature.
834
+ * Experimental APIs with dynamic Creature support.
835
+ * Methods like setTitle will only work when isCreature is true.
781
836
  */
782
- getCreatureStyles(): Record<string, string | undefined> | null;
837
+ get experimental(): ExperimentalHostApi;
783
838
  getHostContext(): HostContext | null;
784
839
  getState(): HostClientState;
785
840
  subscribe(listener: StateListener): () => void;
786
841
  callTool<T = Record<string, unknown>>(toolName: string, args: Record<string, unknown>): Promise<ToolResult<T>>;
787
- sendNotification(method: string, params: unknown): void;
788
- setWidgetState(state: WidgetState | null): void;
789
- /**
790
- * Set pip/widget title.
791
- * Sends a notification - hosts that support it will update the title.
792
- */
793
- setTitle(title: string): void;
794
842
  requestDisplayMode(params: {
795
843
  mode: DisplayMode;
796
844
  }): Promise<{
@@ -874,10 +922,9 @@ declare class CreatureAdapter extends McpAppsAdapter {
874
922
  */
875
923
  get isCreature(): boolean;
876
924
  /**
877
- * Get Creature-specific styles if available.
878
- * Returns null when not running in Creature.
925
+ * Experimental APIs with Creature-specific implementations.
879
926
  */
880
- getCreatureStyles(): Record<string, string | undefined> | null;
927
+ get experimental(): ExperimentalHostApi;
881
928
  }
882
929
 
883
930
  /**
@@ -907,6 +954,11 @@ declare class ChatGptAdapter implements HostAdapter {
907
954
  static detect(): boolean;
908
955
  get environment(): Environment;
909
956
  get isCreature(): boolean;
957
+ /**
958
+ * Experimental APIs for ChatGPT.
959
+ * Most are no-ops since ChatGPT doesn't support MCP Apps extensions.
960
+ */
961
+ get experimental(): ExperimentalHostApi;
910
962
  /**
911
963
  * Get host context - returns null for ChatGPT as it doesn't use MCP Apps protocol.
912
964
  */
@@ -914,15 +966,6 @@ declare class ChatGptAdapter implements HostAdapter {
914
966
  getState(): HostClientState;
915
967
  subscribe(listener: StateListener): () => void;
916
968
  callTool<T = Record<string, unknown>>(toolName: string, args: Record<string, unknown>): Promise<ToolResult<T>>;
917
- /**
918
- * Send notification - not supported on ChatGPT.
919
- */
920
- sendNotification(_method: string, _params: unknown): void;
921
- setWidgetState(state: WidgetState | null): void;
922
- /**
923
- * Set pip/widget title - not supported on ChatGPT.
924
- */
925
- setTitle(_title: string): void;
926
969
  requestDisplayMode(params: {
927
970
  mode: DisplayMode;
928
971
  }): Promise<{
@@ -962,6 +1005,11 @@ declare class StandaloneAdapter implements HostAdapter {
962
1005
  static detect(): boolean;
963
1006
  get environment(): Environment;
964
1007
  get isCreature(): boolean;
1008
+ /**
1009
+ * Experimental APIs for standalone mode.
1010
+ * All methods are logged for development/debugging purposes.
1011
+ */
1012
+ get experimental(): ExperimentalHostApi;
965
1013
  /**
966
1014
  * Get host context - returns null for standalone mode.
967
1015
  */
@@ -969,15 +1017,6 @@ declare class StandaloneAdapter implements HostAdapter {
969
1017
  getState(): HostClientState;
970
1018
  subscribe(listener: StateListener): () => void;
971
1019
  callTool<T = Record<string, unknown>>(toolName: string, args: Record<string, unknown>): Promise<ToolResult<T>>;
972
- /**
973
- * Send notification - logged in standalone mode.
974
- */
975
- sendNotification(method: string, params: unknown): void;
976
- setWidgetState(state: WidgetState | null): void;
977
- /**
978
- * Set pip/widget title - logged in standalone mode.
979
- */
980
- setTitle(title: string): void;
981
1020
  requestDisplayMode(params: {
982
1021
  mode: DisplayMode;
983
1022
  }): Promise<{
@@ -1168,4 +1207,4 @@ declare function createHost(config: HostClientConfig): UnifiedHostClient;
1168
1207
  */
1169
1208
  declare function createHostAsync(config: HostClientConfig): Promise<UnifiedHostClient>;
1170
1209
 
1171
- export { type AdapterKind, type BaseHostClient, type BaseHostClientEvents, CHATGPT_DARK_DEFAULTS, CHATGPT_LIGHT_DEFAULTS, CHATGPT_SHARED_DEFAULTS, ChatGptAdapter, ChatGptBaseHostClient, CreatureAdapter, type DisplayMode, type Environment, type HostAdapter, type HostClientConfig, type HostClientState, type HostContext, type HostIdentity, type InitStylesOptions, KNOWN_HOSTS, type LogLevel, MCP_APPS_DARK_DEFAULTS, MCP_APPS_LIGHT_DEFAULTS, MCP_APPS_SHARED_DEFAULTS, McpAppsAdapter, McpAppsBaseHostClient, type McpAppsHostClientEvents, StandaloneAdapter, StandaloneBaseHostClient, type StateListener, type StructuredWidgetState, type Theme, type ToolResult, type UnifiedHostClient, type UnifiedHostClientEvents, UpgradingMcpAppsClient, type WebSocketClient, type WebSocketClientConfig, type WebSocketStatus, type WidgetState, applyStyles, createHost, createHostAsync, createWebSocket, detectEnvironment, detectTheme, getChatGptDefaultStyles, getHostIdentity, getMcpAppDefaultStyles, initStyles, isHost, parseHostUserAgent };
1210
+ export { type AdapterKind, type BaseHostClient, type BaseHostClientEvents, CHATGPT_DARK_DEFAULTS, CHATGPT_LIGHT_DEFAULTS, CHATGPT_SHARED_DEFAULTS, ChatGptAdapter, ChatGptBaseHostClient, CreatureAdapter, type DisplayMode, type Environment, type ExperimentalHostApi, type HostAdapter, type HostClientConfig, type HostClientState, type HostContext, type HostIdentity, type InitStylesOptions, KNOWN_HOSTS, type LogLevel, MCP_APPS_DARK_DEFAULTS, MCP_APPS_LIGHT_DEFAULTS, MCP_APPS_SHARED_DEFAULTS, McpAppsAdapter, McpAppsBaseHostClient, type McpAppsHostClientEvents, StandaloneAdapter, StandaloneBaseHostClient, type StateListener, type StructuredWidgetState, type Theme, type ToolResult, type UnifiedHostClient, type UnifiedHostClientEvents, UpgradingMcpAppsClient, type WebSocketClient, type WebSocketClientConfig, type WebSocketStatus, type WidgetState, applyStyles, createHost, createHostAsync, createWebSocket, detectEnvironment, detectTheme, getChatGptDefaultStyles, getHostIdentity, getMcpAppDefaultStyles, initStyles, isHost, parseHostUserAgent };
@@ -275,6 +275,24 @@ var ChatGptAdapter = class _ChatGptAdapter {
275
275
  get isCreature() {
276
276
  return false;
277
277
  }
278
+ /**
279
+ * Experimental APIs for ChatGPT.
280
+ * Most are no-ops since ChatGPT doesn't support MCP Apps extensions.
281
+ */
282
+ get experimental() {
283
+ return {
284
+ sendNotification: (_method, _params) => {
285
+ },
286
+ setWidgetState: (state) => {
287
+ this.base.setWidgetState(state);
288
+ },
289
+ setTitle: (_title) => {
290
+ },
291
+ getCreatureStyles: () => {
292
+ return null;
293
+ }
294
+ };
295
+ }
278
296
  /**
279
297
  * Get host context - returns null for ChatGPT as it doesn't use MCP Apps protocol.
280
298
  */
@@ -290,19 +308,6 @@ var ChatGptAdapter = class _ChatGptAdapter {
290
308
  async callTool(toolName, args) {
291
309
  return this.base.callTool(toolName, args);
292
310
  }
293
- /**
294
- * Send notification - not supported on ChatGPT.
295
- */
296
- sendNotification(_method, _params) {
297
- }
298
- setWidgetState(state) {
299
- this.base.setWidgetState(state);
300
- }
301
- /**
302
- * Set pip/widget title - not supported on ChatGPT.
303
- */
304
- setTitle(_title) {
305
- }
306
311
  async requestDisplayMode(params) {
307
312
  return this.base.requestDisplayMode(params);
308
313
  }
@@ -457,6 +462,26 @@ var StandaloneAdapter = class _StandaloneAdapter {
457
462
  get isCreature() {
458
463
  return false;
459
464
  }
465
+ /**
466
+ * Experimental APIs for standalone mode.
467
+ * All methods are logged for development/debugging purposes.
468
+ */
469
+ get experimental() {
470
+ return {
471
+ sendNotification: (method, params) => {
472
+ console.debug(`[Standalone] experimental.sendNotification("${method}")`, params);
473
+ },
474
+ setWidgetState: (state) => {
475
+ this.base.setWidgetState(state);
476
+ },
477
+ setTitle: (title) => {
478
+ console.debug(`[Standalone] experimental.setTitle("${title}")`);
479
+ },
480
+ getCreatureStyles: () => {
481
+ return null;
482
+ }
483
+ };
484
+ }
460
485
  /**
461
486
  * Get host context - returns null for standalone mode.
462
487
  */
@@ -472,21 +497,6 @@ var StandaloneAdapter = class _StandaloneAdapter {
472
497
  async callTool(toolName, args) {
473
498
  return this.base.callTool(toolName, args);
474
499
  }
475
- /**
476
- * Send notification - logged in standalone mode.
477
- */
478
- sendNotification(method, params) {
479
- console.debug(`[Standalone] sendNotification("${method}")`, params);
480
- }
481
- setWidgetState(state) {
482
- this.base.setWidgetState(state);
483
- }
484
- /**
485
- * Set pip/widget title - logged in standalone mode.
486
- */
487
- setTitle(title) {
488
- console.debug(`[Standalone] setTitle("${title}")`);
489
- }
490
500
  async requestDisplayMode(params) {
491
501
  return this.base.requestDisplayMode(params);
492
502
  }
@@ -10153,14 +10163,29 @@ var UpgradingMcpAppsClient = class _UpgradingMcpAppsClient {
10153
10163
  return this.base.getState().environment;
10154
10164
  }
10155
10165
  // ============================================================================
10156
- // Creature-Specific Extensions (gracefully no-op when not in Creature)
10166
+ // Experimental APIs
10157
10167
  // ============================================================================
10158
10168
  /**
10159
- * Get Creature-specific styles if available.
10160
- * Returns null when not running in Creature.
10169
+ * Experimental APIs with dynamic Creature support.
10170
+ * Methods like setTitle will only work when isCreature is true.
10161
10171
  */
10162
- getCreatureStyles() {
10163
- return this.base.getCreatureStyles();
10172
+ get experimental() {
10173
+ return {
10174
+ sendNotification: (method, params) => {
10175
+ this.base.sendNotification(method, params);
10176
+ },
10177
+ setWidgetState: (state) => {
10178
+ this.base.setWidgetState(state);
10179
+ },
10180
+ setTitle: (title) => {
10181
+ if (this.isCreature) {
10182
+ this.base.sendNotification("ui/notifications/title-changed", { title });
10183
+ }
10184
+ },
10185
+ getCreatureStyles: () => {
10186
+ return this.base.getCreatureStyles();
10187
+ }
10188
+ };
10164
10189
  }
10165
10190
  // ============================================================================
10166
10191
  // UnifiedHostClient Implementation
@@ -10177,19 +10202,6 @@ var UpgradingMcpAppsClient = class _UpgradingMcpAppsClient {
10177
10202
  async callTool(toolName, args) {
10178
10203
  return this.base.callTool(toolName, args);
10179
10204
  }
10180
- sendNotification(method, params) {
10181
- this.base.sendNotification(method, params);
10182
- }
10183
- setWidgetState(state) {
10184
- this.base.setWidgetState(state);
10185
- }
10186
- /**
10187
- * Set pip/widget title.
10188
- * Sends a notification - hosts that support it will update the title.
10189
- */
10190
- setTitle(title) {
10191
- this.base.sendNotification("ui/notifications/title-changed", { title });
10192
- }
10193
10205
  async requestDisplayMode(params) {
10194
10206
  return this.base.requestDisplayMode(params);
10195
10207
  }
@@ -10259,6 +10271,25 @@ var McpAppsAdapter = class _McpAppsAdapter {
10259
10271
  get isCreature() {
10260
10272
  return false;
10261
10273
  }
10274
+ /**
10275
+ * Experimental APIs for non-spec extensions.
10276
+ * Base MCP Apps adapter provides minimal implementations - CreatureAdapter overrides.
10277
+ */
10278
+ get experimental() {
10279
+ return {
10280
+ sendNotification: (method, params) => {
10281
+ this.base.sendNotification(method, params);
10282
+ },
10283
+ setWidgetState: (state) => {
10284
+ this.base.setWidgetState(state);
10285
+ },
10286
+ setTitle: (_title) => {
10287
+ },
10288
+ getCreatureStyles: () => {
10289
+ return null;
10290
+ }
10291
+ };
10292
+ }
10262
10293
  /**
10263
10294
  * Get the host context received from the host.
10264
10295
  * Useful for checking host-specific capabilities.
@@ -10275,19 +10306,6 @@ var McpAppsAdapter = class _McpAppsAdapter {
10275
10306
  async callTool(toolName, args) {
10276
10307
  return this.base.callTool(toolName, args);
10277
10308
  }
10278
- sendNotification(method, params) {
10279
- this.base.sendNotification(method, params);
10280
- }
10281
- setWidgetState(state) {
10282
- this.base.setWidgetState(state);
10283
- }
10284
- /**
10285
- * Set pip/widget title.
10286
- * Sends a notification - hosts that support it will update the title.
10287
- */
10288
- setTitle(title) {
10289
- this.base.sendNotification("ui/notifications/title-changed", { title });
10290
- }
10291
10309
  async requestDisplayMode(params) {
10292
10310
  return this.base.requestDisplayMode(params);
10293
10311
  }
@@ -10385,11 +10403,25 @@ var CreatureAdapter = class _CreatureAdapter extends McpAppsAdapter {
10385
10403
  return this.base.isCreatureHost();
10386
10404
  }
10387
10405
  /**
10388
- * Get Creature-specific styles if available.
10389
- * Returns null when not running in Creature.
10406
+ * Experimental APIs with Creature-specific implementations.
10390
10407
  */
10391
- getCreatureStyles() {
10392
- return this.base.getCreatureStyles();
10408
+ get experimental() {
10409
+ return {
10410
+ sendNotification: (method, params) => {
10411
+ this.base.sendNotification(method, params);
10412
+ },
10413
+ setWidgetState: (state) => {
10414
+ this.base.setWidgetState(state);
10415
+ },
10416
+ setTitle: (title) => {
10417
+ if (this.isCreature) {
10418
+ this.base.sendNotification("ui/notifications/title-changed", { title });
10419
+ }
10420
+ },
10421
+ getCreatureStyles: () => {
10422
+ return this.base.getCreatureStyles();
10423
+ }
10424
+ };
10393
10425
  }
10394
10426
  };
10395
10427