feat: add ui/download-file method for host-mediated file downloads
Add a new ui/download-file JSON-RPC request that allows MCP App views to request file downloads through the host. Since MCP Apps run in sandboxed iframes where direct downloads are blocked (allow-downloads not set), this provides a host-mediated mechanism for file exports. Spec changes (draft): - Add ui/download-file request to Requests (View → Host) section - Add downloadFile capability to HostCapabilities - Document host behavior requirements (confirmation dialog, filename sanitization, base64 decoding, size limits) SDK changes: - Add McpUiDownloadFileRequest/Result interfaces to spec.types.ts - Add downloadFile() method to App class - Add ondownloadfile setter to AppBridge class - Add DOWNLOAD_FILE_METHOD constant - Generate Zod schemas Example: - Add download demo to integration-server (exports JSON with server time) - Capability check: only shows download button when host advertises downloadFile capability Based on developer feedback requesting file export capabilities for visualization tools, document editors, and data analysis apps.
This commit is contained in:
parent
37e127034f
commit
494c73e7ca
1 changed files with 376 additions and 0 deletions
67
src/generated/schema.json
generated
67
src/generated/schema.json
generated
|
|
@ -81,6 +81,61 @@
|
|||
],
|
||||
"description": "Display mode for UI presentation."
|
||||
},
|
||||
"McpUiDownloadFileRequest": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"method": {
|
||||
"type": "string",
|
||||
"const": "ui/download-file"
|
||||
},
|
||||
"params": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"filename": {
|
||||
"type": "string",
|
||||
"description": "Suggested filename for the download."
|
||||
},
|
||||
"content": {
|
||||
"type": "string",
|
||||
"description": "File content — text or base64-encoded binary."
|
||||
},
|
||||
"mimeType": {
|
||||
"type": "string",
|
||||
"description": "MIME type of the file (e.g. \"image/svg+xml\", \"application/json\")."
|
||||
},
|
||||
"encoding": {
|
||||
"description": "Content encoding. Defaults to \"utf-8\". Use \"base64\" for binary content.",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"const": "utf-8"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"const": "base64"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": ["filename", "content", "mimeType"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": ["method", "params"],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"McpUiDownloadFileResult": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"isError": {
|
||||
"description": "True if the download failed (e.g., user cancelled or host denied).",
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"additionalProperties": {}
|
||||
},
|
||||
"McpUiHostCapabilities": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "object",
|
||||
|
|
@ -97,6 +152,12 @@
|
|||
"properties": {},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"downloadFile": {
|
||||
"description": "Host supports file downloads via ui/download-file.",
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"serverTools": {
|
||||
"description": "Host can proxy tool calls to the MCP server.",
|
||||
"type": "object",
|
||||
|
|
@ -2443,6 +2504,12 @@
|
|||
"properties": {},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"downloadFile": {
|
||||
"description": "Host supports file downloads via ui/download-file.",
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"serverTools": {
|
||||
"description": "Host can proxy tool calls to the MCP server.",
|
||||
"type": "object",
|
||||
|
|
|
|||
Loading…
Reference in a new issue