Overview
downloadFile requests the host to download one or more files on behalf of the app. Since MCP Apps run in sandboxed iframes where direct downloads are blocked by browser security policies, this method provides a host-mediated mechanism for file exports.
Files can be provided in three ways:
- Embedded text — inline text content (JSON, CSV, HTML, etc.) with a MIME type
- Embedded binary — base64-encoded binary data (images, PDFs, etc.)
- Resource link — a URL that the host fetches and downloads on behalf of the user
isError will be true in the response.
Signature
Parameters
The download parameters.
Array of resources to download. Each entry is either an
EmbeddedResource containing inline content or a ResourceLink pointing to a fetchable URL.An inline resource with content included in the request.
Must be
"resource".A URI identifying the file (e.g.,
"file:///export.json"). The host uses the filename portion for the download name.MIME type of the content (e.g.,
"application/json", "image/png").Text content of the file. Use this for text-based formats. Mutually exclusive with
blob.Base64-encoded binary content. Use this for binary formats. Mutually exclusive with
text.Optional request configuration.
An
AbortSignal to cancel the request.Returns
true if the host denied or failed to process the download request. When absent or false, the download was initiated.Usage
Download embedded text content
Export generated text data such as JSON, CSV, or HTML:Download embedded binary content
Export binary data such as images or PDFs using base64 encoding:Download via resource link
Let the host fetch and download a file from an external URL:Download multiple files at once
Related
- Requests overview — all available View-to-host request methods
useDownloadFile— sunpeak React convenience hook- Core Types —
EmbeddedResourceandResourceLinktype definitions