Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Upload Asset

Use this to store an image, PDF, media clip, script, or dataset as an App asset, outside the 1024 KiB cap every App file but styles.css shares.

MCP name: upload_asset

Tool contract

{
  "annotations": {
    "destructiveHint": true,
    "openWorldHint": true,
    "readOnlyHint": false,
    "title": "Upload Asset"
  },
  "description": "Use this to store an image, PDF, media clip, script, or dataset as an App asset, outside the 1024 KiB cap every App file but styles.css shares. How the App reads it back: read_docs({ path: \"capabilities/data-storage.md\" }).",
  "execution": {
    "taskSupport": "forbidden"
  },
  "inputSchema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "properties": {
      "appId": {
        "description": "The app id (app_modules.id) to attach the asset to. Must be an app you own.",
        "type": "string"
      },
      "contentType": {
        "description": "MIME type. Defaults: text/javascript for a .js or .mjs key (also when a sourceUrl serves it as text/plain or application/octet-stream), otherwise text/plain for text, sniffed for sourceUrl, application/octet-stream otherwise.",
        "type": "string"
      },
      "dataBase64": {
        "description": "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.",
        "type": "string"
      },
      "key": {
        "description": "Asset name, e.g. \"dataset_v1.json\". URL-safe [a-zA-Z0-9._-], <=128 chars, no leading dot. A .js or .mjs key (a module or worker script) needs edit access to the app. Caps: 10 MiB per asset, 50 assets and 100 MiB per app.",
        "type": "string"
      },
      "sourceUrl": {
        "description": "https URL the server fetches, following redirects, and stores. Preferred for any binary: the bytes never pass through this tool call. Provide exactly one of text, sourceUrl, or dataBase64.",
        "format": "uri",
        "type": "string"
      },
      "text": {
        "description": "UTF-8 text payload (datasets, JSON, CSV). No base64. Provide exactly one of text, sourceUrl, or dataBase64.",
        "type": "string"
      }
    },
    "required": [
      "appId",
      "key"
    ],
    "type": "object"
  },
  "name": "upload_asset",
  "outputSchema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "additionalProperties": false,
    "properties": {
      "advisories": {
        "description": "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.",
        "items": {
          "additionalProperties": false,
          "properties": {
            "data": {
              "additionalProperties": {},
              "description": "Kind-specific structured payload. Shape varies per advisory kind.",
              "propertyNames": {
                "type": "string"
              },
              "type": "object"
            },
            "doc_url": {
              "description": "Optional docs pointer for this advisory kind.",
              "type": "string"
            },
            "kind": {
              "description": "Stable advisory identifier (e.g. \"legacy-bridge\").",
              "type": "string"
            },
            "severity": {
              "description": "Severity; omitted advisories are treated as 'info'.",
              "enum": [
                "info",
                "warn"
              ],
              "type": "string"
            },
            "summary": {
              "description": "Agent-facing summary. Self-sufficient; no extra context required.",
              "type": "string"
            },
            "userSummary": {
              "description": "End-user-facing summary. Set when the advisory should render in-app.",
              "type": "string"
            }
          },
          "required": [
            "kind",
            "summary"
          ],
          "type": "object"
        },
        "type": "array"
      },
      "appId": {
        "description": "UUID of the asset-owning app.",
        "type": "string"
      },
      "bytes": {
        "description": "Stored byte length of the asset payload after decode/fetch.",
        "maximum": 9007199254740991,
        "minimum": -9007199254740991,
        "type": "integer"
      },
      "contentType": {
        "description": "Effective MIME type stored with the asset (supplied, sniffed from sourceUrl, or defaulted).",
        "type": "string"
      },
      "key": {
        "description": "The asset key it was stored under. Same value passed in.",
        "type": "string"
      },
      "ok": {
        "const": true,
        "description": "Indicates success. Errors arrive as content with isError:true.",
        "type": "boolean"
      },
      "url": {
        "description": "Same-origin URL serving the asset. Use in <img src>/<a href>/fetch, or read in the backend via `import { assets } from 'charming:storage/[email protected]'` and assets.get(key). Equivalent to window.charming.assets.getUrl(key). An uploaded script runs through import() or new Worker() only at the standalone app URL; chat embeds cannot run it. An App saved before packages reads the asset as env.assets.get(key) and must list charming:storage/[email protected] in manifest.capabilities.imports.",
        "type": "string"
      }
    },
    "required": [
      "ok",
      "appId",
      "key",
      "bytes",
      "contentType",
      "url"
    ],
    "type": "object"
  }
}

Was this page helpful?