upload_asset
UPLOAD A STATIC ASSET TO AN APP so app code stays small and the app reads it back same-origin. Use this when an app needs a large or static file — an image, PDF, audio clip, or a dataset bigger than a few KB — that would otherwise be inlined into module/ui and blow the 256 KiB source cap. Provide EXACTLY ONE of: sourceUrl (PREFERRED for any binary — the SERVER fetches the remote file, follows redirects, and the bytes never transit this tool call), text (UTF-8 dataset/JSON/CSV — no encoding needed), or dataBase64 (LAST RESORT, tiny binaries only: large base64 arguments can stall inside some MCP clients before ever reaching the server, so keep it under ~16 KB and use sourceUrl for anything bigger). The app reads the asset via window.charming.assets.getUrl(key) (for /) or env.assets.get(key) in its backend (the app must declare charming:storage/blob@1.0 in manifest.capabilities.imports to use env.assets). Caps: 10 MiB/asset, 50 assets/app, 100 MiB/app.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Asset name, e.g. "dataset_v1.json". URL-safe [a-zA-Z0-9._-], <=128 chars, no leading dot. | |
| text | No | UTF-8 text payload (datasets, JSON, CSV). No base64. | |
| appId | Yes | The app id (app_modules.id) to attach the asset to. Must be an app you own. | |
| sourceUrl | No | https URL the server fetches and stores. Bytes never pass through this tool call. | |
| dataBase64 | No | Base64 of a SMALL binary. Last resort — prefer sourceUrl: large base64 tool arguments can stall in some MCP clients before reaching the server. Keep the encoded string under ~16 KB; the server-side hard cap is 64 KiB decoded. | |
| contentType | No | MIME type. Defaults: text/plain for text, sniffed for sourceUrl, application/octet-stream otherwise. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | Indicates success. Errors arrive as content with isError:true. | |
| key | Yes | The asset key it was stored under. Same value passed in. | |
| url | Yes | Same-origin URL serving the asset. Use in <img src>/<a href>/fetch, or read in the backend via env.assets.get(key). Equivalent to window.charming.assets.getUrl(key). | |
| appId | Yes | UUID of the asset-owning app. | |
| bytes | Yes | Stored byte length of the asset payload after decode/fetch. | |
| advisories | No | Structured non-fatal advisories, including authoring issues and unread staff feedback responses. Each advisory.summary is also appended to the text content for the LLM path. | |
| contentType | Yes | Effective MIME type stored with the asset (supplied, sniffed from sourceUrl, or defaulted). |