@modelcontextprotocol/ext-apps 1.1.1 → 1.1.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.
- package/dist/src/app-bridge.d.ts +44 -1
- package/dist/src/app-bridge.js +10 -10
- package/dist/src/app-with-deps.js +10 -10
- package/dist/src/app.d.ts +68 -1
- package/dist/src/app.js +11 -11
- package/dist/src/generated/schema.d.ts +72 -0
- package/dist/src/generated/schema.test.d.ts +2 -0
- package/dist/src/react/index.js +10 -10
- package/dist/src/react/react-with-deps.js +10 -10
- package/dist/src/server/index.js +10 -10
- package/dist/src/spec.types.d.ts +34 -1
- package/dist/src/types.d.ts +5 -5
- package/package.json +2 -2
package/dist/src/app-bridge.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
|
2
2
|
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
3
3
|
import { CallToolRequest, CallToolResult, EmptyResult, Implementation, ListPromptsRequest, ListPromptsResult, ListResourcesRequest, ListResourcesResult, ListResourceTemplatesRequest, ListResourceTemplatesResult, LoggingMessageNotification, PingRequest, PromptListChangedNotification, ReadResourceRequest, ReadResourceResult, ResourceListChangedNotification, Tool, ToolListChangedNotification } from "@modelcontextprotocol/sdk/types.js";
|
|
4
4
|
import { Protocol, ProtocolOptions, RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
5
|
-
import { type AppNotification, type AppRequest, type AppResult, type McpUiSandboxResourceReadyNotification, type McpUiSizeChangedNotification, type McpUiToolCancelledNotification, type McpUiToolInputNotification, type McpUiToolInputPartialNotification, type McpUiToolResultNotification, McpUiAppCapabilities, McpUiUpdateModelContextRequest, McpUiHostCapabilities, McpUiHostContext, McpUiHostContextChangedNotification, McpUiInitializedNotification, McpUiMessageRequest, McpUiMessageResult, McpUiOpenLinkRequest, McpUiOpenLinkResult, McpUiResourceTeardownRequest, McpUiSandboxProxyReadyNotification, McpUiRequestDisplayModeRequest, McpUiRequestDisplayModeResult, McpUiResourcePermissions } from "./types";
|
|
5
|
+
import { type AppNotification, type AppRequest, type AppResult, type McpUiSandboxResourceReadyNotification, type McpUiSizeChangedNotification, type McpUiToolCancelledNotification, type McpUiToolInputNotification, type McpUiToolInputPartialNotification, type McpUiToolResultNotification, McpUiAppCapabilities, McpUiUpdateModelContextRequest, McpUiHostCapabilities, McpUiHostContext, McpUiHostContextChangedNotification, McpUiInitializedNotification, McpUiMessageRequest, McpUiMessageResult, McpUiOpenLinkRequest, McpUiOpenLinkResult, McpUiDownloadFileRequest, McpUiDownloadFileResult, McpUiResourceTeardownRequest, McpUiSandboxProxyReadyNotification, McpUiRequestDisplayModeRequest, McpUiRequestDisplayModeResult, McpUiResourcePermissions } 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";
|
|
@@ -404,6 +404,49 @@ export declare class AppBridge extends Protocol<AppRequest, AppNotification, App
|
|
|
404
404
|
* @see {@link McpUiOpenLinkResult `McpUiOpenLinkResult`} for the result type
|
|
405
405
|
*/
|
|
406
406
|
set onopenlink(callback: (params: McpUiOpenLinkRequest["params"], extra: RequestHandlerExtra) => Promise<McpUiOpenLinkResult>);
|
|
407
|
+
/**
|
|
408
|
+
* Register a handler for file download requests from the View.
|
|
409
|
+
*
|
|
410
|
+
* The View sends `ui/download-file` requests when the user wants to
|
|
411
|
+
* download a file. The params contain an array of MCP resource content
|
|
412
|
+
* items — either `EmbeddedResource` (inline data) or `ResourceLink`
|
|
413
|
+
* (URI the host can fetch). The host should show a confirmation dialog
|
|
414
|
+
* and then trigger the download.
|
|
415
|
+
*
|
|
416
|
+
* @param callback - Handler that receives download params and returns a result
|
|
417
|
+
* - `params.contents` - Array of `EmbeddedResource` or `ResourceLink` items
|
|
418
|
+
* - `extra` - Request metadata (abort signal, session info)
|
|
419
|
+
* - Returns: `Promise<McpUiDownloadFileResult>` with optional `isError` flag
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* ```ts
|
|
423
|
+
* bridge.ondownloadfile = async ({ contents }, extra) => {
|
|
424
|
+
* for (const item of contents) {
|
|
425
|
+
* if (item.type === "resource") {
|
|
426
|
+
* // EmbeddedResource — inline content
|
|
427
|
+
* const res = item.resource;
|
|
428
|
+
* const blob = res.blob
|
|
429
|
+
* ? new Blob([Uint8Array.from(atob(res.blob), c => c.charCodeAt(0))], { type: res.mimeType })
|
|
430
|
+
* : new Blob([res.text ?? ""], { type: res.mimeType });
|
|
431
|
+
* const url = URL.createObjectURL(blob);
|
|
432
|
+
* const link = document.createElement("a");
|
|
433
|
+
* link.href = url;
|
|
434
|
+
* link.download = res.uri.split("/").pop() ?? "download";
|
|
435
|
+
* link.click();
|
|
436
|
+
* URL.revokeObjectURL(url);
|
|
437
|
+
* } else if (item.type === "resource_link") {
|
|
438
|
+
* // ResourceLink — host fetches or opens directly
|
|
439
|
+
* window.open(item.uri, "_blank");
|
|
440
|
+
* }
|
|
441
|
+
* }
|
|
442
|
+
* return {};
|
|
443
|
+
* };
|
|
444
|
+
* ```
|
|
445
|
+
*
|
|
446
|
+
* @see {@link McpUiDownloadFileRequest `McpUiDownloadFileRequest`} for the request type
|
|
447
|
+
* @see {@link McpUiDownloadFileResult `McpUiDownloadFileResult`} for the result type
|
|
448
|
+
*/
|
|
449
|
+
set ondownloadfile(callback: (params: McpUiDownloadFileRequest["params"], extra: RequestHandlerExtra) => Promise<McpUiDownloadFileResult>);
|
|
407
450
|
/**
|
|
408
451
|
* Register a handler for display mode change requests from the view.
|
|
409
452
|
*
|