Skip to content

fetch: return binary response bodies (base64) and response headers, for hosted file downloads #460

Closed

Description

@chrischall

Hosted MCP servers that read files through the browser bridge cannot get a file's bytes back. workvivo-mcp hit this. Its documents live on a signed, CDN-style file host outside the server's allowed outbound hosts, so on a hosted deployment the only route to the bytes is the user's browser, and the bridge cannot carry them today.

What blocks it today

  • The fetch verb decodes every response body with response.text(), in both the content-script and in-page paths. Binary bodies (PDF, docx/xlsx zips, images) come back corrupted: invalid UTF-8 becomes U+FFFD, which cannot be undone.
  • InnerResponseFetchOk is { op, status, url, body: string }. No response headers are relayed, so a server cannot check Content-Type, Content-Length or Content-Disposition before it trusts a body.
  • FetchInit has no field to ask for binary.
  • Responses are capped at 5 MB (MAX_RESPONSE_BODY_BYTES).
  • File hosts like this send no CORS headers, so even a binary-safe content-script fetch of the signed URL fails. It would have to run from the background/service worker with host_permissions, where CORS does not apply.

Proposal

  • Request option: an opt-in responseType: 'base64' (or bodyEncoding) on FetchInit.
  • Extension: read arrayBuffer() and return the body as base64, plus a relayed subset of headers: content-type, content-length, content-disposition.
  • Size cap: a separate, larger cap for binary bodies, refusing early when content-length is over it.
  • Where the fetch runs: from the background worker, so that a redirect to a no-CORS file host still works. Scope it to the hosts the pairing grants.
  • Capability flag: add one to the protocol, so a server can tell whether the paired extension supports binary and refuse cleanly when it doesn't.

Who is waiting on this

  • workvivo-mcp: hosted document reads currently refuse, with a clear "not supported on hosted servers yet".
  • Other browser-bridge servers that download attachments would benefit too.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions