Skip to content

Idea: let agents upload media without pasting base64 into the tool call #250

Done

Description

@Madraka

A suggestion to consider, not a request. Close it if the trade-off isn't worth it.

What we ran into

To give an article a cover over MCP, an agent has to put the whole file into the upload_asset call as base64 (data, up to 4 MB decoded). For one 24 KB WebP cover, that was about 32,000 characters the model had to copy into a single tool call. That is slow and costly, and one wrong character corrupts the file. In this case it went fine: the agent checked that the returned sha256 matched the local file. fetch_asset_url is the alternative, but it needs a public https URL, and an agent working on local files usually has none.

Ideas (any one would help)

  1. Upload session with a signed URL: create_upload returns a short-lived PUT URL (and its asset id). The agent's client uploads the bytes directly (curl, a script, the MCP client), then complete_upload checks type, size and sha256 like upload_asset does today.
  2. Chunked upload: upload_asset_part calls with an upload id, part index and a part sha256, then a final call with the whole file's sha256.
  3. Expected checksum: let upload_asset take sha256, and refuse if the decoded bytes don't match. Cheap, and it turns a silent corruption into a clear error even without 1 or 2.

Option 1 keeps the bytes out of the model's context entirely, which is the biggest win. It needs the same SSRF-free, type-checked ingest as today, and the URL should expire quickly and work for one file only.

Reported by Claude (an AI agent) during a content session on cloudhal.com, at the site owner's request.


Generated by Claude Code

Activity

  1. added
    enhancement
    on Nov 15, 2026
  2. Madraka commented on Nov 28, 2026

    @Madraka
    ContributorAuthor

    Triage (no code yet), with the plan agreed for it.

    What exists

    Studio already uploads in two steps:

    • POST /api/sites/:id/assets/uploads opens single-use, signed tickets. Each is HMAC-bound to site, actor, size, type and SHA-256, and lasts 15 minutes.
    • A streamed PUT …/assets/uploads/:id then runs the media pipeline (RFC-0004 §5.5; packages/api/src/routes/assets.ts, uploads.ts).

    Agents cannot use it. REST is default-deny, and agent keys are refused everywhere except public/signed-in, because "they work through MCP" (RFC-0005 I15, packages/api/src/scopes.ts).

    Options

    • A. create_upload MCP tool (asset:upload).
      • The flow: the agent declares filename, size, type and sha256 and gets one ticket URL. Its shell or client PUTs the file there, and the asset comes back from the PUT (or from get_asset).
      • The URL must authorize itself: the agent's shell usually doesn't hold the MCP credential, especially with OAuth (RFC-0044). The ticket is bound to the exact sha256 and size, single use, for 15 minutes, so a leaked URL can only upload the identical file.
      • It needs: an amendment to RFC-0005 I15 (an exception for that one route), plus audit as the agent, run budgets and taint, and rate limits.
      • Benefit: it keeps the bytes out of the model's context entirely.
    • B. Optional sha256 on upload_asset. Refuse when the decoded bytes don't match. Additive, no RFC, and silent corruption becomes a clear error.
    • C. Chunked base64. Not recommended: the bytes still pass through the model's context, so it isn't cheaper, and it adds failure points.
    • D. path for the local stdio cloudhal mcp. Read a file inside the project directory, so no bytes go through the context. Local only, and it needs path sandboxing.

    Plan

    • B: a small PR, coming next.
    • A: waits for an RFC amendment to RFC-0005 I15, which goes to the owner first.
    • D: optional for now.

    🤖 Generated with Claude Code

  3. Madraka commented on Nov 29, 2026

    @Madraka
    ContributorAuthor

    Done with RFC-0048 (accepted 2026-11-29): option 3 was already in #299 (sha256 on upload_asset), and option 1 now ships as signed, single-use upload links. The rollout PRs: #340 (docs and the I15 amendment), #344 (store), #346 (the PUT route and signing), #348 (the MCP tools create_upload/complete_upload and the capability flag) and #349 (hosts: CLOUDHAL_UPLOAD_SECRET, cloudhal.json media.agentUploads/agentUploadBytes, Studio labels, the guide docs/guides/agent-uploads.md). Follow-up recorded in the RFC: an eval task once an agent-with-shell harness exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions