Yolk SDK
Connectors

Transfer connector files

Download bytes and create or update files through bounded host-only ports.

Use these helpers in trusted host code, not connector action arrays. They return Uint8Array bytes or allowlisted write metadata. Your host authorizes the operation, supplies the transport, materializes and scans files, and extracts content for an agent. A skill cannot perform downloads, and makeConnectorToolModule does not expose these helpers. Existing base64 attachment actions remain available for compatibility; do not route the new byte results through generic tool JSON.

Start with a bounded download

Install matching package versions as described in Connectors. Host integration fragment:

import { downloadGoogleDriveFile } from '@yolk-sdk/connectors/google'

const budget = {
  maxBytes: 20_000_000,
  maxMetadataBytes: 1_000_000,
  maxErrorBodyBytes: 16_384
}

const program = downloadGoogleDriveFile(
  googleIntegration, // host-owned integration with a google.oauth binding
  { fileId: selectedFile.id, resourceKey: selectedFile.resourceKey },
  budget
)
// Provide CredentialResolver + ConnectorBinaryHttpClient, then run in the host runtime.
// Result: { bytes, byteLength, source }. Store/scan/extract; never serialize raw bytes to an agent.

Budgets are trusted host configuration, not model parameters. maxBytes bounds downloaded or uploaded file bytes; maxMetadataBytes separately bounds JSON responses; maxErrorBodyBytes bounds unsuccessful/redirect bodies. Zero-length files are supported. Gmail needs a metadata budget large enough for JSON plus base64 expansion. Existing downloadDropboxFile retains its two-field budget without maxMetadataBytes; existing OneDrive download keeps its original API.

Capability matrix

All names below are exported through the indicated @yolk-sdk/connectors/* subpath.

Provider/subpathHost byte retrievalHost byte writesDiscovery and limits
Dropbox (dropbox)downloadDropboxFile, streamDropboxFile, getDropboxTemporaryLinkcreateDropboxFile, updateDropboxFileExisting metadata actions; 150,000,000-byte single upload, upload sessions past it (at most 350 GB)
OneDrive (microsoft)downloadOneDriveItem, streamOneDriveItem, getOneDriveDownloadUrlcreateOneDriveFile, updateOneDriveFileExisting drive actions; 250,000,000-byte single upload, upload sessions past it (at most 250 GB)
R2 (r2-storage)getR2ObjectcreateR2Object, updateR2ObjectHost supplies bucket/key and R2ObjectClient; 100,000,000-byte PUT cap
Drive (google)downloadGoogleDriveFile, exportGoogleDriveFile, streamGoogleDriveFile, streamGoogleDriveExport, exportGoogleDriveTextNot addedBlob versus explicit native export; 10,000,000-byte export cap
Fortnox (fortnox)downloadFortnoxInvoicePreview, streamFortnoxInvoicePreview, downloadFortnoxOfferPreview, streamFortnoxOfferPreview, downloadFortnoxArchiveFile, streamFortnoxArchiveFile, downloadFortnoxInboxFile, streamFortnoxInboxFileuploadFortnoxInboxFile, uploadFortnoxArchiveFilefortnox.list_supplier_invoice_files, fortnox.get_inbox_folder; previews are generated PDFs; 50 MiB inbox and archive upload caps
Notion (notion)downloadNotionFile, streamNotionFileNot addedPage/property/block file objects; required host URL policy
Gmail (google)downloadGmailAttachment, streamGmailAttachmentNot addedExisting attachment discovery; canonical base64url decoded inside host helper; streamed send and draft twins (below)
Outlook (microsoft)downloadOutlookAttachment, streamOutlookAttachmentaddOutlookAttachment (drafts)Existing discovery; file attachments only, raw /$value; uploads up to 150 MiB
IMAP/POP3 (email)downloadEmailAttachment, streamEmailAttachmentNot addedOptional EmailClient.getAttachmentBytes; no MIME library bundled
Telegram (telegram)downloadTelegramFile, streamTelegramFileNot addedFile IDs from messages available to the bot; 20,000,000-byte hosted download cap
Todoist (todoist)downloadTodoistAttachment, streamTodoistAttachmentNot addedtodoist.list_comments with task/project selection; download by comment ID
GitHub (github)Not addeduploadGithubAttachmentUndocumented user-attachments endpoint; user token only; 10 MB image / 100 MB video cap
Afloat (afloat)Reuse remote MCP file grantsReuse remote MCP upload intentsDynamic discovery owns exact contracts; no duplicate SDK file wrappers
Figma (figma)Reuse remote MCP asset exportsReuse remote MCP asset/design toolsNo whole .fig download or arbitrary file-upload claim

Stream, or skip the download

A buffered download holds the whole file in the host's memory until it returns. Where memory is shared (several sessions in one isolate, for example), skip the download where the provider allows it and stream where it does not.

import { Redacted } from 'effect'
import { getDropboxTemporaryLink } from '@yolk-sdk/connectors/dropbox'
import { getOneDriveDownloadUrl } from '@yolk-sdk/connectors/microsoft'

const dropboxLink = getDropboxTemporaryLink(dropboxIntegration, { path: selectedFile.id })
const oneDriveLink = getOneDriveDownloadUrl(microsoftIntegration, { itemId, driveId }, budget)
// Result: { url: Redacted<string>, expiresAt, source, requested }.
// Hand Redacted.value(result.url) only to the component allowed to fetch the file.

Both answer the provider's own short-lived link to the file's content, which works without credentials, so another component (a parser Worker, for example) can fetch the file and the host never holds it. getDropboxTemporaryLink calls POST /2/files/get_temporary_link over ConnectorHttpClient with the files.content.read slot and needs no budget (there is no body to bound). getOneDriveDownloadUrl runs the downloadOneDriveItem metadata walk (same slots, guards, remote items and size check) and selects @microsoft.graph.downloadUrl. Inputs, identity checks and error codes match the downloads.

  • Links are secrets. Anyone holding one reads the file until it expires. url is a Redacted<string>: logs, String() and JSON.stringify print <redacted>, and no error ever carries it. Your host decides who may use it and must not log it either.
  • Lifetime. expiresAt (epoch ms) is conservative: the request time plus the provider's documented lifetime, minus connectorLinkExpiryMarginMs (5 minutes, so a link is not handed on just before it ends): dropboxTemporaryLinkLifetimeMs (4 hours; then Dropbox answers 410) and oneDriveDownloadUrlLifetimeMs (about 1 hour, treated as an upper bound; Graph documents it only as short-lived). A link may stop working sooner, and removing a permission may not invalidate a Graph link at once.
  • Network policy. The SDK screens a link's syntax (public HTTPS) only. The component that fetches it must apply the binary port's policy: public DNS and socket IP on every hop, TLS, no cookies or ambient credentials.
  • Drive blobs (webContentLink needs a Google session) and Todoist attachments (files.todoist.com needs the token) have no credential-free link: stream them.

Google-native files as text

exportGoogleDriveText(integration, { fileId, resourceKey? }, budget) exports a Google Doc as Markdown, a Sheet as CSV (the first sheet only) and Slides as plain text (googleDriveTextExportTypes), through Drive's export and its 10,000,000-byte cap. It answers { text, byteLength, source }: UTF-8 text without a leading byte order mark, so no binary download or document parser is needed. The format follows the file's type, read from its metadata first; other types, blobs included, fail with not_downloadable before any content request, and text that is not UTF-8 fails with invalid_metadata.

Streamed downloads

import { Effect } from 'effect'
import { streamOneDriveItem } from '@yolk-sdk/connectors/microsoft'

const stored = Effect.scoped(
  Effect.gen(function* () {
    const file = yield* streamOneDriveItem(microsoftIntegration, { itemId, driveId }, budget)
    // file: { body: Stream<Uint8Array, OneDriveDownloadError>, contentLength, source, requested }
    return yield* hostStorage.put(key, file.body, file.contentLength) // app-owned sink
  })
)

streamDropboxFile, streamOneDriveItem, streamGoogleDriveFile, streamGoogleDriveExport, streamTodoistAttachment, streamOutlookAttachment, streamNotionFile, streamTelegramFile, streamFortnoxInvoicePreview, streamFortnoxOfferPreview, streamFortnoxArchiveFile and streamFortnoxInboxFile take the same arguments as their buffered twins and send the same requests (same slots, redirect rules and errors); a Fortnox preview's PDF magic bytes are checked as the body streams. They answer the same source metadata plus body and contentLength (ConnectorFileStream): the exact length a completed body has, when the provider reported a size (Dropbox, Drive blobs, Telegram's file_size) or the response declared a decoded one. OneDrive's metadata size is no byte snapshot, so, as in the buffered helper, it only bounds the download against maxBytes. The body is only readable inside the scope that opened it; closing the scope closes the connection, read or not.

streamGmailAttachment is the one exception to the same requests and checks: Gmail answers its attachment as base64url inside JSON, so it decodes data as the response streams (the JSON, its base64 and the file are never whole). It sends the buffered twin's URL and headers with a larger bound, the base64 of maxBytes plus maxMetadataBytes: every byte but data's base64 counts against maxMetadataBytes, where the twin bounds the whole JSON by it. The body fails with response_too_large past either limit or on a size over maxBytes, and with invalid_metadata, never partial_content, on JSON or base64 that is not Gmail's or a length other than Gmail's size. A size read before data is checked before any byte and binds the decoding at once. It declares no contentLength (the decoded length is known only at the end).

Without a provider size or a declared length (OneDrive, Drive exports, Todoist, Outlook, Notion, Fortnox, Telegram without file_size), nothing in the SDK can tell a body that ends early but cleanly from a whole one, in the buffered helpers as here: your port must never answer a body cut before the response's own end (short of its Content-Length, or chunked without its last chunk) as complete, but fail it with transport_failed.

  • Every check that does not need the body runs before it opens: metadata, identity, canDownload, and the provider's size against maxBytes.
  • The SDK counts the body on top of the host: more than maxBytes fails it with response_too_large, a declared length over maxBytes fails before reading, and a body that does not end at exactly the provider's size (or the declared length) fails with partial_content. With either, a body that completes is never a truncated file.
  • Each request opens in its own child of your scope: a redirect hop, an error answer, or a check that fails before the body closes its connection at once, so a redirect chain holds one connection at a time. Only the final body stays open until your scope closes.
  • Non-200 answers stay bounded bytes and are classified exactly as the buffered helpers classify them.
  • A host whose port has no stream still works: the helpers fall back to request and answer its bytes as one chunk. That is still bounded by maxBytes, but buffered.
  • For reuse caches, key on the provider's file revision in source (streamed, buffered and link results alike): Dropbox rev, OneDrive cTag (content) or eTag (any change), Drive headRevisionId (blobs) or version (any change); Todoist reports none, so key on commentId. When you need a content hash, compute it while piping the body (for example with Stream.tap, or crypto.DigestStream on Workers); the SDK verifies none.

Not streamed: fortnox.get_sie_file (an agent action whose bytes become a file through fileOutput; at most 50 MiB), Gmail and the other base64 attachment reads (base64 inside a JSON body; Gmail caps a message at 25 MB), and the small, bounded Telegram, Teams transcript and Fortnox preview, archive and inbox reads.

Create and update explicitly

Host integration fragment (credentials, approval, transport and execution omitted):

import { createDropboxFile, updateDropboxFile } from '@yolk-sdk/connectors/dropbox'
import { createOneDriveFile, updateOneDriveFile } from '@yolk-sdk/connectors/microsoft'

const create = createDropboxFile(dropboxIntegration, { path: '/reports/new.pdf', bytes }, budget)
const update = updateDropboxFile(
  dropboxIntegration,
  { fileId: selectedDropboxFile.id, expectedRev: selectedDropboxFile.rev, bytes },
  budget
)
const createDrive = createOneDriveFile(
  microsoftIntegration,
  { driveId, parentItemId, name: 'new.pdf', bytes },
  budget
)
const overwriteDrive = updateOneDriveFile(
  microsoftIntegration,
  { driveId, itemId, bytes, acknowledgeOverwrite: true },
  budget
)

Each also takes body: { size, stream } (ConnectorUploadBody) as an alternative to bytes (callers passing bytes are unaffected; the input types are now generic type aliases, no longer interfaces; addOutlookAttachment takes it too, below; R2, Fortnox and GitHub take bytes only): a stored file goes to the provider as it is read: up to the single-upload caps in one request (through the optional ConnectorBinaryWriteHttpClient.requestStream, content-length: size, never chunked; without it the body is collected and sent through request), past them in an upload session, one part held at a time (below). The limits are checked against size first, the body is held to exactly size (partial_content otherwise), and a body that fails fails the write with its own error.

  • Dropbox: create uses mode: 'add'; update uses a stable id: and concrete expected rev. Both send strict_conflict: true and autorename: false. Missing/deleted targets and stale revisions cannot silently turn an update into a create. Permission hint: files.content.write. content_hash is not a revision. Returned revision metadata is validated, not a verified checksum. Up to 150,000,000 bytes (dropboxSingleUploadMaxBytes) one files/upload; past it, up to 350 GB (dropboxUploadSessionMaxBytes), an upload session through the write port's request: upload_session/start with the first 8 MiB part (dropboxUploadSessionPartBytes), append_v2 with each next part at its offset, finish with the last part and the same commit. A 409 on finish is conflict; before it, the session's own error is upstream_failed. Dropbox has no session cancellation: a session that fails is never finished (no file exists) and expires; a session lasts at most 7 days, so a slower upload fails midway.
  • OneDrive: creation sends @microsoft.graph.conflictBehavior=fail, never the provider default replace. Update replaces bytes by stable ID and requires explicit acknowledgeOverwrite: true. This is unconditional overwrite, not compare-and-swap. No If-Match guarantee is invented for Graph's simple /content upload. A concurrent edit can be overwritten. Hosts must obtain informed overwrite approval, or decline the operation when atomic concurrency is required. Write hints use Files.ReadWrite, or Files.ReadWrite.All for delegated_all/application; application mode requires driveId before credentials are resolved. Up to 250,000,000 bytes (oneDriveSingleUploadMaxBytes) one content PUT; past it, up to 250 GB (oneDriveUploadSessionMaxBytes), an upload session, which needs the write port's uploadSession and ConnectorHttpClient (upload_session_required before credentials or network without them): createUploadSession (conflict behavior fail on create, replace on update), then sequential 10 MiB ranges (oneDriveUploadSessionRangeBytes) to its uploadUrl, with no Authorization. The uploadUrl must be on a host of oneDriveUploadSessionHosts (*.sharepoint.com, api.onedrive.com, *.1drv.com, *.microsoftpersonalcontent.com), over https without userinfo or a port, else network_policy_rejected uncontacted; only the host is enforced. The paths sessions are seen with (/up/… on *.1drv.com, …/_api/v2.0/…/uploadSession on SharePoint and *.microsoftpersonalcontent.com, /rup… on api.onedrive.com) are informative only, not enforced. A range's error status maps as the single upload's; any failure after the session exists cancels it (one best-effort DELETE). A session expires at its expirationDateTime when no range arrives before then (a stalled upload fails not_found).
  • R2: createR2Object and updateR2Object accept { bucket, key, bytes }; update additionally requires expectedEtag. getR2Object accepts { bucket, key, expectedEtag? }. The host's R2ObjectClient.put must atomically enforce condition: { kind: 'absent' } using If-None-Match: *, or { kind: 'etag', etag } using a concrete If-Match. Never HEAD-then-PUT. Preserve HTTP ETag quotes; translate representation explicitly for binding adapters. Failed conditional PUT (null from R2 bindings) is conflict, not success. Missing GET is not_found; conditional GET metadata without a body is conflict, never an empty file. The host selects authorized integration/bucket/key access and resolves credentials or bindings. No AWS dependency is bundled. ETag conditions do not distinguish every identical-content rewrite. Existing R2Presigner and r2_storage.upload_url are unchanged and do not inherit these conditions.

R2 uploads are single-request, memory-bounded only: larger files fail upload_session_required before transport. Dropbox and OneDrive files past their single upload, and Outlook draft attachments of 3 MiB or more (below), use upload sessions; past the session limits, or a smaller host budget, the helpers fail response_too_large. No session is resumed, and these helpers do not claim atomic conditional R2 multipart completion. No write retries occur. Transport errors, timeouts, cancellation or an invalid success response may follow a committed write: reconcile with provider metadata before trying again; never remove a precondition or silently switch to another write mode.

Attach a file to an Outlook draft

Host integration fragment (approval, transport layers and execution omitted):

import { addOutlookAttachment } from '@yolk-sdk/connectors/microsoft'

const attach = addOutlookAttachment(
  microsoftIntegration,
  { messageId: draft.id, name: 'report.pdf', contentType: 'application/pdf', bytes, mailbox },
  budget
)
// Result: { attachmentId?, name, size }. Send later with outlook.send_draft after review.

It also takes the file as body: { size, stream }, as an alternative to bytes (callers passing bytes are unaffected; OutlookAddAttachmentInput<E> is now a generic type alias, no longer an interface). The session ranges are then read from the stream a range at a time, one range held; a file under 3 MiB is collected for its one JSON request. The body is held to exactly size (partial_content otherwise), and a body that fails fails the call with its own error; either way the session is cancelled.

addOutlookAttachment adds one file to an existing draft and never sends it. It uses the Outlook write slot (Mail.ReadWrite; Mail.ReadWrite.Shared for a delegated mailbox that is not the connected account) and the application-mode mailbox guard. Files under 3 MiB (outlookAttachmentSingleRequestMaxBytes) use one Graph POST .../messages/{id}/attachments with a #microsoft.graph.fileAttachment body; Graph echoes the base64 content, so the success budget is maxMetadataBytes plus that base64 length. Files from 3 MiB up to 150 MiB (outlookAttachmentUploadSessionMaxBytes) use POST .../attachments/createUploadSession, then sequential 3,932,160-byte ranges (outlookAttachmentUploadChunkBytes, 12 x 320 KiB) sent with PUT, Content-Range: bytes start-end/total, Content-Type: application/octet-stream and no Authorization header to the pre-authenticated uploadUrl. Each intermediate 200 must name exactly the next expected range, and the final range must return 201; its Location header supplies attachmentId when parseable. A 200/201 POST or final 201 without a readable ID still succeeds, without attachmentId. See Microsoft's large attachment guide, including its known issue for shared or delegated mailboxes.

The helper requires CredentialResolver and ConnectorHttpClient. Both authenticated Graph POSTs (fileAttachment and createUploadSession) go through the regular ConnectorHttpClient as ASCII-only JSON string bodies with Bearer, JSON accept/content-type and Prefer: IdType="ImmutableId" headers, redirect: 'manual' and credentials: 'omit'. Your HTTP adapter must allow those Graph POSTs and a success body of maxMetadataBytes plus the echoed base64 content (about 4 MiB for a file just under 3 MiB). The adapter must not log, trace or persist these request or response bodies: they carry file content and the token-bearing uploadUrl. Status codes map the same way as the binary port; success bodies are bounded after the adapter returns them, so enforce your own streaming cap. The helper never reads error bodies from these Graph POSTs, so your adapter may truncate them for these requests (other connectors, such as Fortnox, do read error bodies); cap them without failing so the status still maps, because an adapter failure becomes transport_failed without a status.

Only session ranges need the optional ConnectorBinaryWriteHttpClient.uploadSession method; the helper reads that port optionally, so hosts without any binary write port can still attach files under 3 MiB. Hosts without it fail upload_session_required for files of 3 MiB or more, before credentials or network. The uploadUrl embeds an auth token: the SDK only contacts https://outlook.office.com/api/{v1.0,v2.0,gv1.0,beta}/.../AttachmentSessions('...') URLs (others fail network_policy_rejected without being contacted), never returns the URL, and sends one best-effort DELETE to cancel the session after any later failure or interruption. Failures are code/status-only ConnectorFileTransferErrors. The draft is never sent, but a failure after dispatch (transport error, timeout, malformed response) may still have attached the file: list the draft's attachments before retrying. No automatic retries occur.

Send or draft Gmail with streamed attachments

A host whose outgoing Gmail message carries its stored files never holds them: host-only twins send the message as one multipart media upload through ConnectorBinaryWriteHttpClient (requestStream when the host has it; otherwise the body is collected and sent through request), its size known before its first byte.

  • sendGmailMimeStreamed(integration, { mime: { size, stream }, threadId? }) is gmail.send_message's twin for a MIME the host streams: the same send authority, 35 MiB cap (checked on size first), threadId check and outcomes.
  • composeGmailDraftStreamed, updateGmailDraftStreamed and replyGmailDraftStreamed are the draft actions' twins: the action's input without attachments, and GmailDraftStreamedAttachments ({ filename, mimeType, body: { size, stream } }) checked as the action checks its attachments before any request; they write the bytes the held draft writes.
  • streamedMime builds a MIME from StreamedMimePiece.Text and StreamedMimePiece.Base64 pieces (streamBase64MimeLines: base64 in 76-character CRLF lines, a chunk at a time; base64MimeLinesLength their length).

A message that is not its declared size, or that holds the upload's random boundary, is refused before Gmail has all of it (a rejected ConnectorError, nothing sent or written); a body that fails fails the call with its own error; a transport failure leaves the outcome unknown (reconcile before another send).

Provider retrieval details

Drive

downloadGoogleDriveFile accepts { fileId, resourceKey? }; exportGoogleDriveFile additionally requires mimeType. Metadata is bounded and checked before content. Caller-specific capabilities.canDownload must be true; role restriction flags alone do not identify the caller's role. Google still enforces authorization when content is requested. Shared-drive downloads use supportsAllDrives=true; resource keys are validated and forwarded in the resource-key header. No abuse acknowledgement is sent. Folders, shortcuts, unsupported native files and incompatible exports fail; there is no shortcut chasing or Vids long-running download implementation.

Content consent defaults to GoogleDriveFileOAuthCredentialSlot (drive.file, app-created or explicitly selected/shared files). Only trusted hosts can select contentAccess: 'readonly' in GoogleDriveDownloadBudget, requesting GoogleDriveReadonlyOAuthCredentialSlot (drive.readonly, broad restricted scope). Metadata-only consent is insufficient. Hosts own Picker/per-file access, consent UX, OAuth verification and restricted-scope compliance. Slot hints are not access control.

Supported exports: Docs PDF, DOCX, ODT, RTF, plain text, HTML, ZIP, EPUB and Markdown; Sheets XLSX, ODS, PDF, CSV, TSV and ZIP; Slides PPTX, ODP, PDF and plain text; Drawings PDF, JPEG, PNG and SVG; Apps Script JSON. CSV/TSV export the first sheet only. Exports are generated representations, not original blob snapshots. See Google's export formats.

Fortnox and Notion

Fortnox preview input is { documentNumber }; archive input is { fileId }. documentNumber uses FortnoxDocumentNumber from @yolk-sdk/connectors/fortnox: decode external strings with that schema, or use .make for trusted values. fileId remains a plain string. Preview uses /3/invoices/{DocumentNumber}/preview, not /print, and does not set Sent true. The preview request sends no Accept header and success is verified by %PDF- magic bytes, not the response content type. Archive retrieval uses /3/archive/{id} with IDs from discovery, not supplier external-URL connections. fortnox.list_supplier_invoice_files takes { givenNumber, page?, limit? } and returns { files, pagination }; the filter is the internal GivenNumber, not the supplier InvoiceNumber. FortnoxConnectFileOAuthCredentialSlot requests connectfile; archive uses FortnoxArchiveOAuthCredentialSlot (archive); preview uses the invoice slot (invoice). All Fortnox scopes grant read and write at the provider. File discovery/download helpers remain separate from the customer/invoice action writes. These two new scopes are opt-in, not automatically added to the existing five-scope combined slot. Archive response modeling and generic list pagination in Fortnox OpenAPI are imperfect; validate sanitized provider responses before production, never infer a final page from missing metadata.

downloadFortnoxOfferPreview takes { documentNumber } and reads /3/offers/{DocumentNumber}/preview with the offer slot (offer); like the invoice preview it verifies PDF magic bytes and does not mark the offer Sent.

Inbox helpers use FortnoxInboxOAuthCredentialSlot (inbox). downloadFortnoxInboxFile takes { fileId } from fortnox.get_inbox_folder and reads /3/inbox/{Id}; it rejects root and the static folder IDs (fortnoxInboxStaticFolderIds), since a folder ID answers with folder JSON. uploadFortnoxInboxFile takes { folderId, fileName, contentType?, bytes } and sends one multipart/form-data POST (field file) to /3/inbox?folderid=… through ConnectorBinaryWriteHttpClient. It validates the file name, picks a boundary absent from the bytes, never retries, and returns the uploaded file metadata, failing with invalid_metadata when the reported Size differs from the bytes sent. Fortnox documents no upload limit; the helper caps uploads at fortnoxInboxUploadMaxBytes (50 MiB) and fails larger files with upload_session_required. Upload query key and form field follow Fortnox's archived docs and official SDK; they are not yet observed live.

uploadFortnoxArchiveFile takes { folderId?, fileName, contentType?, bytes } and sends the same single, never-retried multipart POST to /3/archive (?folderid=… when a folder is given; the archive root otherwise) with FortnoxArchiveOAuthCredentialSlot (archive). It returns FortnoxArchiveFile (Id, Name, Path, Size, Comments) and caps uploads at fortnoxArchiveUploadMaxBytes (50 MiB). The returned Id is the FileId that fortnox.create_voucher_file_connection attaches to a voucher; see Bookkeeping. Neither the archive upload nor the voucher file connection is observed live yet.

Notion input is a provider { type: 'file', file: { url, expiry_time? } } or { type: 'external', external: { url } } object from existing page/property/block reads. Pass a fourth argument NotionFileDownloadPolicy with allowHostedUrl(url); external downloads additionally require allowExternalUrl(url). Supply policy from trusted host code, not model-controlled URL approval. No Notion credentials are resolved or forwarded. URLs are temporary: reread the owning page/block/property after expiry. file_upload.id is an upload reference, not downloadable content.

Mail, Telegram and Todoist

Gmail and Outlook inputs are { messageId, attachmentId }; Outlook optionally accepts mailbox. Gmail validates the base64url alphabet, padding, decoded byte count and size, including empty files; unused pad bits are accepted. Inline Gmail parts without attachmentId remain outside this focused helper. Outlook checks the file discriminator before fetching /$value; item MIME/reference attachments are rejected. Graph's attachment metadata size is not treated as exact raw-byte length. Existing shared-mailbox, application-mailbox and immutable-ID guards remain in effect. In delegated mode, an explicit mailbox also triggers a scope-free microsoft.oauth identity lookup before the enforcing read slot; matching the connected identity keeps ordinary read scopes. Identity-resolution failures return credential_failed, not invalid_input. See Microsoft mailbox permissions.

downloadEmailAttachment takes { messageId, attachmentId, folder? } and uses the incoming connection and username/password slot. Adapters can add optional EmailClient.getAttachmentBytes without changing old methods. Return actual raw bytes, matching IDs and byteLength, optionally filename/contentType; never Buffer→base64→Buffer. Enforce MIME decoded-byte limits during streaming, release streams and use IMAP reads that preserve flags. POP3 rejects folders and may require fetching the whole message; hosts must also bound that larger fetch.

streamEmailAttachment is its stream twin over the optional EmailClient.streamAttachmentBytes (not part of the HTTP-binary stream family: the email port, not ConnectorBinaryHttpClient). Same input, slot and matching-ID checks; it answers { body, contentLength?, messageId, attachmentId, filename?, contentType? } (ConnectorFileStream). Without streamAttachmentBytes it fails not_downloadable. The host reads the attachment's decoded bytes as the body (IMAP BODY.PEEK, read flags preserved) inside the scope that opened it; closing the scope releases the message stream and the connection. The SDK counts the body again against maxBytes (response_too_large, never a short success), holds it to a declared contentLength (partial_content), and fails invalid_metadata before the body on a mismatched message/attachment or a contentLength that is not a byte count. Host errors carry codes only. POP3 still rejects folders and may fetch the whole UIDL-addressed message, which the host bounds.

Telegram input is { fileId }. Only api.telegram.org hosted Bot API is supported. getFile resolves a validated relative path; local Bot API absolute filesystem paths are rejected. Download URLs contain the bot token and must never enter logs. Returned source contains file IDs only: getFile does not preserve original filename/MIME. Links last at least one hour; call getFile again after expiry. No getUpdates calls or update acknowledgements are performed here.

Todoist discovery uses todoist.list_comments with exactly one taskId or projectId, optional cursor/limit, returning comments (Chunk) and nextCursor; metadata omits attachment URLs. downloadTodoistAttachment takes { commentId }, rereads bounded metadata, authenticates only the initial files.todoist.com download, and treats todoist.b-cdn.net and d1ysz50cxb9zwl.cloudfront.net as unauthenticated CDNs. At most five validated HTTPS redirects are followed; no authorization is reapplied, even on same-origin redirects. Unknown hosts fail closed.

Reuse MCP file capabilities

Afloat at https://useafloat.com/mcp exposes get-invoice-pdf, get-quote-pdf, get-receipt-download, get-logo-download and get-tax-return-download. These return one-hour same-origin opaque URL grants, as structuredContent: { url, expiresAt }. create-receipt-upload returns an upload intent, URL, expiry and required headers; complete-receipt-upload attaches or replaces the receipt atomically. Corresponding logo operations exist. Receipt upload inputs allow JPEG/PNG/WebP/GIF/PDF, length 1–2,147,483,647 and an optional SHA-256 checksum. The published schemas of these tools, and their provenance, are on the Afloat MCP conformance page. Use discovered schemas and enforce smaller host budgets; do not duplicate these operations as static SDK wrappers.

Figma discovery confirmed download_assets for node renders/source images/SVG temporary URLs, upload_assets (including SVG, 10 MB per asset), use_figma for edits and create_new_file for creation. Deployed node-selection parameters differ from published documentation; dynamic discovery owns the exact contract. These are asset/design operations, not whole .fig downloads. Authorize write-capable MCP tools as writes; do not assume use_figma is read-only. Hosts consume structured/multipart results and download/upload grants through a bounded private file pipeline, never expose credentials or signed grants in ordinary model text. No live provider writes were used to validate these capabilities.

Host transport contract and failures

The root exports ConnectorBinaryWriteHttpClient separately from the GET-only ConnectorBinaryHttpClient. Its optional stream method takes the same request as request and keeps every guarantee: one hop, no redirects or ambient credentials, public DNS and socket IP policy on every hop, and maxBytes enforced while streaming, so an oversize body fails with response_too_large instead of ending early. It runs in a Scope and answers ConnectorBinaryHttpStreamResponse.Stream({ status: 200, headers, contentLength?, body }) for HTTP 200 (contentLength is the decoded length; omit it for a Content-Encoding other than identity, whose Content-Length fetch keeps compressed) or ConnectorBinaryHttpStreamResponse.Bytes({ status, headers, bytes, bodyComplete }) for any other status, bounded by maxErrorBodyBytes. Close the connection when the scope closes, whether or not the body was read. Existing adapters without stream keep compiling. Write requests carry raw bytes, maxUploadBytes, successful metadata maxBytes, maxErrorBodyBytes, successStatuses: [200, 201], manual redirects and omitted ambient credentials. Reads accept HTTP 200 only. The optional uploadSession method takes a ConnectorBinaryUploadSessionRequest (PUT range or DELETE cancellation, success [200, 201] or [204]) for a provider-issued pre-authenticated URL. Implement it only with an origin and path allowlist (Outlook: https://outlook.office.com/api/{v1.0,v2.0,gv1.0,beta}/.../AttachmentSessions(...)), the URL sent unchanged, no Authorization or ambient credentials, no redirects or retries, no URL logging/tracing/persistence, and response headers (including Location) returned intact. Existing adapters without it keep compiling. The optional requestStream takes a ConnectorBinaryWriteStreamRequest (the write request with body: { size, stream } for bytes): declare content-length: size, send the body as it arrives, abort on a body of another length or one that fails (failing with that body's error). addOutlookAttachment uses this port only for uploadSession; its authenticated Graph JSON POSTs use ConnectorHttpClient. Host adapters must enforce limits while consuming streams, including decompression, cap headers independently, close/cancel I/O, verify TLS, implement timeouts/cancellation, and enforce public DNS and socket IP policy on every request/hop. Never use cookie jars, automatic redirects/retries, ambient auth or URL/header/body logging. R2 and email adapters have equivalent streaming, authorization and cancellation obligations.

SDK URL syntax screens and post-buffer checks are defense in depth, not proof of network isolation or pre-buffer limits. New transfers reject redirects except the bounded Todoist flow; existing OneDrive download retains its own unauthenticated redirect handling. Provider access, licensing, host materialization/storage/retention, malware scanning and format readers are not implemented here. No download metadata establishes a consistent provider snapshot.

New helpers fail with root ConnectorFileTransferError containing only code plus an optional HTTP status number: invalid_input, credential_failed, transport_failed, network_policy_rejected, response_too_large, upload_session_required, unauthorized, forbidden, not_found, conflict, rate_limited, upstream_failed, invalid_metadata, not_downloadable, unexpected_redirect, or partial_content. They never carry signed URLs, raw upstream errors or wrapped causes; only the link helpers return a provider link, and only as Redacted. Hosts must avoid adding those details in their own errors/telemetry. Existing Dropbox/OneDrive downloads keep their original error types. Deterministic fake-port tests prove request orchestration only, not live provider or host network enforcement.

On this page