@modelcontextprotocol/ext-apps 0.0.7 → 0.2.0

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @modelcontextprotocol/ext-apps
2
2
 
3
- [![API Documentation](https://img.shields.io/badge/docs-API%20Reference-blue)](https://modelcontextprotocol.github.io/ext-apps/api/)
3
+ [![npm version](https://img.shields.io/npm/v/@modelcontextprotocol/ext-apps.svg)](https://www.npmjs.com/package/@modelcontextprotocol/ext-apps) [![API Documentation](https://img.shields.io/badge/docs-API%20Reference-blue)](https://modelcontextprotocol.github.io/ext-apps/api/)
4
4
 
5
5
  This repo contains the SDK and [specification](https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/draft/apps.mdx) for MCP Apps Extension ([SEP-1865](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/1865)).
6
6
 
@@ -55,7 +55,7 @@ The [`examples/`](https://github.com/modelcontextprotocol/ext-apps/tree/main/exa
55
55
 
56
56
  To run all examples together:
57
57
 
58
- ```
58
+ ```bash
59
59
  npm install
60
60
  npm run examples:start
61
61
  ```
@@ -1,11 +1,38 @@
1
1
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
2
  import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
3
- import { Implementation, LoggingMessageNotification, Notification, PingRequest, Request, Result } from "@modelcontextprotocol/sdk/types.js";
3
+ import { CallToolRequest, CallToolResult, Implementation, ListPromptsRequest, ListPromptsResult, ListResourcesRequest, ListResourcesResult, ListResourceTemplatesRequest, ListResourceTemplatesResult, LoggingMessageNotification, PingRequest, PromptListChangedNotification, ReadResourceRequest, ReadResourceResult, ResourceListChangedNotification, ToolListChangedNotification } from "@modelcontextprotocol/sdk/types.js";
4
4
  import { Protocol, ProtocolOptions, RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
5
- import { type McpUiSandboxResourceReadyNotification, type McpUiSizeChangedNotification, type McpUiToolInputNotification, type McpUiToolInputPartialNotification, type McpUiToolResultNotification, McpUiAppCapabilities, McpUiHostCapabilities, McpUiHostContext, McpUiHostContextChangedNotification, McpUiInitializedNotification, McpUiMessageRequest, McpUiMessageResult, McpUiOpenLinkRequest, McpUiOpenLinkResult, McpUiResourceTeardownRequest, McpUiSandboxProxyReadyNotification } from "./types";
5
+ import { type AppNotification, type AppRequest, type AppResult, type McpUiSandboxResourceReadyNotification, type McpUiSizeChangedNotification, type McpUiToolCancelledNotification, type McpUiToolInputNotification, type McpUiToolInputPartialNotification, type McpUiToolResultNotification, McpUiAppCapabilities, McpUiHostCapabilities, McpUiHostContext, McpUiHostContextChangedNotification, McpUiInitializedNotification, McpUiMessageRequest, McpUiMessageResult, McpUiOpenLinkRequest, McpUiOpenLinkResult, McpUiResourceTeardownRequest, McpUiSandboxProxyReadyNotification, McpUiRequestDisplayModeRequest, McpUiRequestDisplayModeResult } from "./types";
6
6
  export * from "./types";
7
7
  export { RESOURCE_URI_META_KEY, RESOURCE_MIME_TYPE } from "./app";
8
8
  export { PostMessageTransport } from "./message-transport";
9
+ /**
10
+ * Extract UI resource URI from tool metadata.
11
+ *
12
+ * Supports both the new nested format (`_meta.ui.resourceUri`) and the
13
+ * deprecated flat format (`_meta["ui/resourceUri"]`). The new nested format
14
+ * takes precedence if both are present.
15
+ *
16
+ * @param tool - A tool object with optional `_meta` property
17
+ * @returns The UI resource URI if valid, undefined if not present
18
+ * @throws Error if resourceUri is present but invalid (not starting with "ui://")
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // New nested format (preferred)
23
+ * const uri = getToolUiResourceUri({
24
+ * _meta: { ui: { resourceUri: "ui://server/app.html" } }
25
+ * });
26
+ *
27
+ * // Deprecated flat format (still supported)
28
+ * const uri = getToolUiResourceUri({
29
+ * _meta: { "ui/resourceUri": "ui://server/app.html" }
30
+ * });
31
+ * ```
32
+ */
33
+ export declare function getToolUiResourceUri(tool: {
34
+ _meta?: Record<string, unknown>;
35
+ }): string | undefined;
9
36
  /**
10
37
  * Options for configuring AppBridge behavior.
11
38
  *
@@ -53,7 +80,7 @@ type RequestHandlerExtra = Parameters<Parameters<AppBridge["setRequestHandler"]>
53
80
  * 2. **Connect**: Call `connect()` with transport to establish communication
54
81
  * 3. **Wait for init**: Guest UI sends initialize request, bridge responds
55
82
  * 4. **Send data**: Call `sendToolInput()`, `sendToolResult()`, etc.
56
- * 5. **Teardown**: Call `sendResourceTeardown()` before unmounting iframe
83
+ * 5. **Teardown**: Call `teardownResource()` before unmounting iframe
57
84
  *
58
85
  * @example Basic usage
59
86
  * ```typescript
@@ -90,7 +117,7 @@ type RequestHandlerExtra = Parameters<Parameters<AppBridge["setRequestHandler"]>
90
117
  * await bridge.connect(transport);
91
118
  * ```
92
119
  */
93
- export declare class AppBridge extends Protocol<Request, Notification, Result> {
120
+ export declare class AppBridge extends Protocol<AppRequest, AppNotification, AppResult> {
94
121
  private _client;
95
122
  private _hostInfo;
96
123
  private _capabilities;
@@ -100,12 +127,15 @@ export declare class AppBridge extends Protocol<Request, Notification, Result> {
100
127
  /**
101
128
  * Create a new AppBridge instance.
102
129
  *
103
- * @param _client - MCP client connected to the server (for proxying requests)
130
+ * @param _client - MCP client connected to the server, or `null`. When provided,
131
+ * {@link connect} will automatically set up forwarding of MCP requests/notifications
132
+ * between the Guest UI and the server. When `null`, you must register handlers
133
+ * manually using the `oncalltool`, `onlistresources`, etc. setters.
104
134
  * @param _hostInfo - Host application identification (name and version)
105
135
  * @param _capabilities - Features and capabilities the host supports
106
136
  * @param options - Configuration options (inherited from Protocol)
107
137
  *
108
- * @example
138
+ * @example With MCP client (automatic forwarding)
109
139
  * ```typescript
110
140
  * const bridge = new AppBridge(
111
141
  * mcpClient,
@@ -113,8 +143,18 @@ export declare class AppBridge extends Protocol<Request, Notification, Result> {
113
143
  * { openLinks: {}, serverTools: {}, logging: {} }
114
144
  * );
115
145
  * ```
146
+ *
147
+ * @example Without MCP client (manual handlers)
148
+ * ```typescript
149
+ * const bridge = new AppBridge(
150
+ * null,
151
+ * { name: "MyHost", version: "1.0.0" },
152
+ * { openLinks: {}, serverTools: {}, logging: {} }
153
+ * );
154
+ * bridge.oncalltool = async (params, extra) => { ... };
155
+ * ```
116
156
  */
117
- constructor(_client: Client, _hostInfo: Implementation, _capabilities: McpUiHostCapabilities, options?: HostOptions);
157
+ constructor(_client: Client | null, _hostInfo: Implementation, _capabilities: McpUiHostCapabilities, options?: HostOptions);
118
158
  /**
119
159
  * Get the Guest UI's capabilities discovered during initialization.
120
160
  *
@@ -331,6 +371,39 @@ export declare class AppBridge extends Protocol<Request, Notification, Result> {
331
371
  * @see {@link McpUiOpenLinkResult} for the result type
332
372
  */
333
373
  set onopenlink(callback: (params: McpUiOpenLinkRequest["params"], extra: RequestHandlerExtra) => Promise<McpUiOpenLinkResult>);
374
+ /**
375
+ * Register a handler for display mode change requests from the Guest UI.
376
+ *
377
+ * The Guest UI sends `ui/request-display-mode` requests when it wants to change
378
+ * its display mode (e.g., from "inline" to "fullscreen"). The handler should
379
+ * check if the requested mode is in `availableDisplayModes` from the host context,
380
+ * update the display mode if supported, and return the actual mode that was set.
381
+ *
382
+ * If the requested mode is not available, the handler should return the current
383
+ * display mode instead.
384
+ *
385
+ * @param callback - Handler that receives the requested mode and returns the actual mode set
386
+ * - params.mode - The display mode being requested ("inline" | "fullscreen" | "pip")
387
+ * - extra - Request metadata (abort signal, session info)
388
+ * - Returns: Promise<McpUiRequestDisplayModeResult> with the actual mode set
389
+ *
390
+ * @example
391
+ * ```typescript
392
+ * bridge.onrequestdisplaymode = async ({ mode }, extra) => {
393
+ * const availableModes = hostContext.availableDisplayModes ?? ["inline"];
394
+ * if (availableModes.includes(mode)) {
395
+ * setDisplayMode(mode);
396
+ * return { mode };
397
+ * }
398
+ * // Return current mode if requested mode not available
399
+ * return { mode: currentDisplayMode };
400
+ * };
401
+ * ```
402
+ *
403
+ * @see {@link McpUiRequestDisplayModeRequest} for the request type
404
+ * @see {@link McpUiRequestDisplayModeResult} for the result type
405
+ */
406
+ set onrequestdisplaymode(callback: (params: McpUiRequestDisplayModeRequest["params"], extra: RequestHandlerExtra) => Promise<McpUiRequestDisplayModeResult>);
334
407
  /**
335
408
  * Register a handler for logging messages from the Guest UI.
336
409
  *
@@ -359,21 +432,216 @@ export declare class AppBridge extends Protocol<Request, Notification, Result> {
359
432
  * ```
360
433
  */
361
434
  set onloggingmessage(callback: (params: LoggingMessageNotification["params"]) => void);
435
+ /**
436
+ * Register a handler for tool call requests from the Guest UI.
437
+ *
438
+ * The Guest UI sends `tools/call` requests to execute MCP server tools. This
439
+ * handler allows the host to intercept and process these requests, typically
440
+ * by forwarding them to the MCP server.
441
+ *
442
+ * @param callback - Handler that receives tool call params and returns a
443
+ * {@link CallToolResult}
444
+ * @param callback.params - Tool call parameters (name and arguments)
445
+ * @param callback.extra - Request metadata (abort signal, session info)
446
+ *
447
+ * @example
448
+ * ```typescript
449
+ * bridge.oncalltool = async ({ name, arguments: args }, extra) => {
450
+ * return mcpClient.request(
451
+ * { method: "tools/call", params: { name, arguments: args } },
452
+ * CallToolResultSchema,
453
+ * { signal: extra.signal }
454
+ * );
455
+ * };
456
+ * ```
457
+ *
458
+ * @see {@link CallToolRequest} for the request type
459
+ * @see {@link CallToolResult} for the result type
460
+ */
461
+ set oncalltool(callback: (params: CallToolRequest["params"], extra: RequestHandlerExtra) => Promise<CallToolResult>);
462
+ /**
463
+ * Notify the Guest UI that the MCP server's tool list has changed.
464
+ *
465
+ * The host sends `notifications/tools/list_changed` to the Guest UI when it
466
+ * receives this notification from the MCP server. This allows the Guest UI
467
+ * to refresh its tool cache or UI accordingly.
468
+ *
469
+ * @param params - Optional notification params (typically empty)
470
+ *
471
+ * @example
472
+ * ```typescript
473
+ * // In your MCP client notification handler:
474
+ * mcpClient.setNotificationHandler(ToolListChangedNotificationSchema, () => {
475
+ * bridge.sendToolListChanged();
476
+ * });
477
+ * ```
478
+ *
479
+ * @see {@link ToolListChangedNotification} for the notification type
480
+ */
481
+ sendToolListChanged(params?: ToolListChangedNotification["params"]): Promise<void>;
482
+ /**
483
+ * Register a handler for list resources requests from the Guest UI.
484
+ *
485
+ * The Guest UI sends `resources/list` requests to enumerate available MCP
486
+ * resources. This handler allows the host to intercept and process these
487
+ * requests, typically by forwarding them to the MCP server.
488
+ *
489
+ * @param callback - Handler that receives list params and returns a
490
+ * {@link ListResourcesResult}
491
+ * @param callback.params - Request params (may include cursor for pagination)
492
+ * @param callback.extra - Request metadata (abort signal, session info)
493
+ *
494
+ * @example
495
+ * ```typescript
496
+ * bridge.onlistresources = async (params, extra) => {
497
+ * return mcpClient.request(
498
+ * { method: "resources/list", params },
499
+ * ListResourcesResultSchema,
500
+ * { signal: extra.signal }
501
+ * );
502
+ * };
503
+ * ```
504
+ *
505
+ * @see {@link ListResourcesRequest} for the request type
506
+ * @see {@link ListResourcesResult} for the result type
507
+ */
508
+ set onlistresources(callback: (params: ListResourcesRequest["params"], extra: RequestHandlerExtra) => Promise<ListResourcesResult>);
509
+ /**
510
+ * Register a handler for list resource templates requests from the Guest UI.
511
+ *
512
+ * The Guest UI sends `resources/templates/list` requests to enumerate available
513
+ * MCP resource templates. This handler allows the host to intercept and process
514
+ * these requests, typically by forwarding them to the MCP server.
515
+ *
516
+ * @param callback - Handler that receives list params and returns a
517
+ * {@link ListResourceTemplatesResult}
518
+ * @param callback.params - Request params (may include cursor for pagination)
519
+ * @param callback.extra - Request metadata (abort signal, session info)
520
+ *
521
+ * @example
522
+ * ```typescript
523
+ * bridge.onlistresourcetemplates = async (params, extra) => {
524
+ * return mcpClient.request(
525
+ * { method: "resources/templates/list", params },
526
+ * ListResourceTemplatesResultSchema,
527
+ * { signal: extra.signal }
528
+ * );
529
+ * };
530
+ * ```
531
+ *
532
+ * @see {@link ListResourceTemplatesRequest} for the request type
533
+ * @see {@link ListResourceTemplatesResult} for the result type
534
+ */
535
+ set onlistresourcetemplates(callback: (params: ListResourceTemplatesRequest["params"], extra: RequestHandlerExtra) => Promise<ListResourceTemplatesResult>);
536
+ /**
537
+ * Register a handler for read resource requests from the Guest UI.
538
+ *
539
+ * The Guest UI sends `resources/read` requests to retrieve the contents of an
540
+ * MCP resource. This handler allows the host to intercept and process these
541
+ * requests, typically by forwarding them to the MCP server.
542
+ *
543
+ * @param callback - Handler that receives read params and returns a
544
+ * {@link ReadResourceResult}
545
+ * @param callback.params - Read parameters including the resource URI
546
+ * @param callback.extra - Request metadata (abort signal, session info)
547
+ *
548
+ * @example
549
+ * ```typescript
550
+ * bridge.onreadresource = async ({ uri }, extra) => {
551
+ * return mcpClient.request(
552
+ * { method: "resources/read", params: { uri } },
553
+ * ReadResourceResultSchema,
554
+ * { signal: extra.signal }
555
+ * );
556
+ * };
557
+ * ```
558
+ *
559
+ * @see {@link ReadResourceRequest} for the request type
560
+ * @see {@link ReadResourceResult} for the result type
561
+ */
562
+ set onreadresource(callback: (params: ReadResourceRequest["params"], extra: RequestHandlerExtra) => Promise<ReadResourceResult>);
563
+ /**
564
+ * Notify the Guest UI that the MCP server's resource list has changed.
565
+ *
566
+ * The host sends `notifications/resources/list_changed` to the Guest UI when it
567
+ * receives this notification from the MCP server. This allows the Guest UI
568
+ * to refresh its resource cache or UI accordingly.
569
+ *
570
+ * @param params - Optional notification params (typically empty)
571
+ *
572
+ * @example
573
+ * ```typescript
574
+ * // In your MCP client notification handler:
575
+ * mcpClient.setNotificationHandler(ResourceListChangedNotificationSchema, () => {
576
+ * bridge.sendResourceListChanged();
577
+ * });
578
+ * ```
579
+ *
580
+ * @see {@link ResourceListChangedNotification} for the notification type
581
+ */
582
+ sendResourceListChanged(params?: ResourceListChangedNotification["params"]): Promise<void>;
583
+ /**
584
+ * Register a handler for list prompts requests from the Guest UI.
585
+ *
586
+ * The Guest UI sends `prompts/list` requests to enumerate available MCP
587
+ * prompts. This handler allows the host to intercept and process these
588
+ * requests, typically by forwarding them to the MCP server.
589
+ *
590
+ * @param callback - Handler that receives list params and returns a
591
+ * {@link ListPromptsResult}
592
+ * @param callback.params - Request params (may include cursor for pagination)
593
+ * @param callback.extra - Request metadata (abort signal, session info)
594
+ *
595
+ * @example
596
+ * ```typescript
597
+ * bridge.onlistprompts = async (params, extra) => {
598
+ * return mcpClient.request(
599
+ * { method: "prompts/list", params },
600
+ * ListPromptsResultSchema,
601
+ * { signal: extra.signal }
602
+ * );
603
+ * };
604
+ * ```
605
+ *
606
+ * @see {@link ListPromptsRequest} for the request type
607
+ * @see {@link ListPromptsResult} for the result type
608
+ */
609
+ set onlistprompts(callback: (params: ListPromptsRequest["params"], extra: RequestHandlerExtra) => Promise<ListPromptsResult>);
610
+ /**
611
+ * Notify the Guest UI that the MCP server's prompt list has changed.
612
+ *
613
+ * The host sends `notifications/prompts/list_changed` to the Guest UI when it
614
+ * receives this notification from the MCP server. This allows the Guest UI
615
+ * to refresh its prompt cache or UI accordingly.
616
+ *
617
+ * @param params - Optional notification params (typically empty)
618
+ *
619
+ * @example
620
+ * ```typescript
621
+ * // In your MCP client notification handler:
622
+ * mcpClient.setNotificationHandler(PromptListChangedNotificationSchema, () => {
623
+ * bridge.sendPromptListChanged();
624
+ * });
625
+ * ```
626
+ *
627
+ * @see {@link PromptListChangedNotification} for the notification type
628
+ */
629
+ sendPromptListChanged(params?: PromptListChangedNotification["params"]): Promise<void>;
362
630
  /**
363
631
  * Verify that the guest supports the capability required for the given request method.
364
632
  * @internal
365
633
  */
366
- assertCapabilityForMethod(method: Request["method"]): void;
634
+ assertCapabilityForMethod(method: AppRequest["method"]): void;
367
635
  /**
368
636
  * Verify that a request handler is registered and supported for the given method.
369
637
  * @internal
370
638
  */
371
- assertRequestHandlerCapability(method: Request["method"]): void;
639
+ assertRequestHandlerCapability(method: AppRequest["method"]): void;
372
640
  /**
373
641
  * Verify that the host supports the capability required for the given notification method.
374
642
  * @internal
375
643
  */
376
- assertNotificationCapability(method: Notification["method"]): void;
644
+ assertNotificationCapability(method: AppNotification["method"]): void;
377
645
  /**
378
646
  * Verify that task creation is supported for the given request method.
379
647
  * @internal
@@ -510,6 +778,37 @@ export declare class AppBridge extends Protocol<Request, Notification, Result> {
510
778
  * @see {@link sendToolInput} for sending tool arguments before results
511
779
  */
512
780
  sendToolResult(params: McpUiToolResultNotification["params"]): Promise<void>;
781
+ /**
782
+ * Notify the Guest UI that tool execution was cancelled.
783
+ *
784
+ * The host MUST send this notification if tool execution was cancelled for any
785
+ * reason, including user action, sampling error, classifier intervention, or
786
+ * any other interruption. This allows the Guest UI to update its state and
787
+ * display appropriate feedback to the user.
788
+ *
789
+ * @param params - Optional cancellation details:
790
+ * - `reason`: Human-readable explanation for why the tool was cancelled
791
+ *
792
+ * @example User-initiated cancellation
793
+ * ```typescript
794
+ * // User clicked "Cancel" button
795
+ * bridge.sendToolCancelled({ reason: "User cancelled the operation" });
796
+ * ```
797
+ *
798
+ * @example System-level cancellation
799
+ * ```typescript
800
+ * // Sampling error or timeout
801
+ * bridge.sendToolCancelled({ reason: "Request timeout after 30 seconds" });
802
+ *
803
+ * // Classifier intervention
804
+ * bridge.sendToolCancelled({ reason: "Content policy violation detected" });
805
+ * ```
806
+ *
807
+ * @see {@link McpUiToolCancelledNotification} for the notification type
808
+ * @see {@link sendToolResult} for sending successful results
809
+ * @see {@link sendToolInput} for sending tool arguments
810
+ */
811
+ sendToolCancelled(params: McpUiToolCancelledNotification["params"]): Promise<void>;
513
812
  /**
514
813
  * Send HTML resource to the sandbox proxy for secure loading.
515
814
  *
@@ -542,7 +841,7 @@ export declare class AppBridge extends Protocol<Request, Notification, Result> {
542
841
  * @example
543
842
  * ```typescript
544
843
  * try {
545
- * await bridge.sendResourceTeardown({});
844
+ * await bridge.teardownResource({});
546
845
  * // Guest UI is ready, safe to unmount iframe
547
846
  * iframe.remove();
548
847
  * } catch (error) {
@@ -550,18 +849,22 @@ export declare class AppBridge extends Protocol<Request, Notification, Result> {
550
849
  * }
551
850
  * ```
552
851
  */
553
- sendResourceTeardown(params: McpUiResourceTeardownRequest["params"], options?: RequestOptions): Promise<import("./types").McpUiResourceTeardownResult>;
554
- private forwardRequest;
555
- private forwardNotification;
852
+ teardownResource(params: McpUiResourceTeardownRequest["params"], options?: RequestOptions): Promise<Record<string, unknown>>;
853
+ /** @deprecated Use {@link teardownResource} instead */
854
+ sendResourceTeardown: AppBridge["teardownResource"];
556
855
  /**
557
- * Connect to the Guest UI via transport and set up message forwarding.
856
+ * Connect to the Guest UI via transport and optionally set up message forwarding.
857
+ *
858
+ * This method establishes the transport connection. If an MCP client was passed
859
+ * to the constructor, it also automatically sets up request/notification forwarding
860
+ * based on the MCP server's capabilities, proxying the following to the Guest UI:
861
+ * - Tools (tools/call, notifications/tools/list_changed)
862
+ * - Resources (resources/list, resources/read, resources/templates/list, notifications/resources/list_changed)
863
+ * - Prompts (prompts/list, notifications/prompts/list_changed)
558
864
  *
559
- * This method establishes the transport connection and automatically sets up
560
- * request/notification forwarding based on the MCP server's capabilities.
561
- * It proxies the following server capabilities to the Guest UI:
562
- * - Tools (tools/call, tools/list_changed)
563
- * - Resources (resources/list, resources/read, resources/templates/list, resources/list_changed)
564
- * - Prompts (prompts/list, prompts/list_changed)
865
+ * If no client was passed to the constructor, no automatic forwarding is set up
866
+ * and you must register handlers manually using the `oncalltool`, `onlistresources`,
867
+ * etc. setters.
565
868
  *
566
869
  * After calling connect, wait for the `oninitialized` callback before sending
567
870
  * tool input and other data to the Guest UI.
@@ -569,12 +872,12 @@ export declare class AppBridge extends Protocol<Request, Notification, Result> {
569
872
  * @param transport - Transport layer (typically PostMessageTransport)
570
873
  * @returns Promise resolving when connection is established
571
874
  *
572
- * @throws {Error} If server capabilities are not available. This occurs when
573
- * connect() is called before the MCP client has completed its initialization
574
- * with the server. Ensure `await client.connect()` completes before calling
575
- * `bridge.connect()`.
875
+ * @throws {Error} If a client was passed but server capabilities are not available.
876
+ * This occurs when connect() is called before the MCP client has completed its
877
+ * initialization with the server. Ensure `await client.connect()` completes
878
+ * before calling `bridge.connect()`.
576
879
  *
577
- * @example
880
+ * @example With MCP client (automatic forwarding)
578
881
  * ```typescript
579
882
  * const bridge = new AppBridge(mcpClient, hostInfo, capabilities);
580
883
  * const transport = new PostMessageTransport(
@@ -589,6 +892,18 @@ export declare class AppBridge extends Protocol<Request, Notification, Result> {
589
892
  *
590
893
  * await bridge.connect(transport);
591
894
  * ```
895
+ *
896
+ * @example Without MCP client (manual handlers)
897
+ * ```typescript
898
+ * const bridge = new AppBridge(null, hostInfo, capabilities);
899
+ *
900
+ * // Register handlers manually
901
+ * bridge.oncalltool = async (params, extra) => {
902
+ * // Custom tool call handling
903
+ * };
904
+ *
905
+ * await bridge.connect(transport);
906
+ * ```
592
907
  */
593
908
  connect(transport: Transport): Promise<void>;
594
909
  }