# MCP file transfers

Pass files to and from MCP tools without putting their bytes in the conversation: file arguments, upload targets, downloads, and the hosted tools that use them.

The MCP file extension (`io.modelcontextprotocol/files`) moves a spreadsheet, a PDF or a photo between a client and a tool without spending the model's context on its bytes. The specification is an experimental draft from the MCP file uploads working group and its wire format may still change, so treat it as an addition to a tool that also works without it.

## How a file reaches a tool

A tool marks an argument as a file with `x-mcp-file`, and the client sends a description in its place: an `id`, a media type, a size and, when it can, a digest. The bytes then take one of two routes.

**Inline.** A small file travels in the call as base64 `data`, up to the total the server advertises as `maxInlineBytes`.

**Out of band.** The client leaves `data` out. The server answers `resultType: "upload_required"` with an upload target for each file and an opaque `requestState`. The client sends the bytes to the target and repeats the call with the same arguments and that state.

```json
{
  "name": "import_photo",
  "arguments": {
    "photo": {
      "id": "photo-1",
      "name": "jacket.jpg",
      "mimeType": "image/jpeg",
      "size": 48213,
      "digest": { "algorithm": "sha-256", "value": "base64url-digest-without-padding" }
    }
  }
}
```

A result returns files the other way. It lists download targets under `_meta["io.modelcontextprotocol/files"].downloads`, each with a name, media type, size and digest, and the client fetches them without showing the bytes to the model.

## On Ferrite's hosted server

`https://mcp.ferrite.cloud/mcp` advertises `{"upload": {}, "maxInlineBytes": 1048576}`. Four tools use the extension:

| Tool | Direction | What it does |
| --- | --- | --- |
| `rcs_commit_file` | Upload | Commits one text or binary file, such as an image or a font, to your application's repository |
| `rcs_checkout` | Download | Offers the checked-out source as a file |
| `logs`, `account_statement` | Download | Offers the log tail or the statement as a file |

`rcs_commit_file` takes a file of up to 1 MiB inline, or up to 15 MiB through an upload target, and needs its `id`, `mimeType` and `size`. A target is a path on `mcp.ferrite.cloud` that takes the client's own credential and one write. The bytes wait in Ferrite's replicated Object Storage until the call that uses them, and each target and each `requestState` is used once. When the call includes a `digest`, send `sha-256` with the value in base64url without padding, as in the example above; the server compares it with the bytes before it returns the commit. The three download tools list a file target only for a client that declares `download`. A client that does not support file arguments sends text files with `rcs_commit` as before.

Claude transfers files for connectors listed in its directory. See [Anthropic's connector guide](https://claude.com/docs/connectors/building/files) for the client's own limits.

## Accept a file in your own tool

In an application built with [`agent-ready`](/developers/agent-native-apps/), turn the capability on and describe the argument. A call to your application is a request body of up to 256 KiB, so set the inline limit to 180 KiB, which leaves room for base64 and the rest of the call. [An upload route](/developers/mcp-interactive-tools/#take-files-up-to-64-mib) takes files of up to 64 MiB:

```rust filename="src/agent.rs"
fn mcp_files_config(&self) -> FilesConfig {
    FilesConfig { upload: false, max_inline_bytes: Some(180 * 1024), download: false }
}
```

```rust filename="src/agent.rs"
let input_schema = json!({
    "type": "object",
    "properties": {
        "photo": files::file_input_schema(
            &["image/png", "image/jpeg"], Some(180 * 1024), false, Some("The item, as a photo."),
        )
    },
    "required": ["photo"]
});
```

Parse the argument in the handler. `parse_file_input` checks the description, decodes the bytes, and compares the size and any digest:

```rust filename="src/agent.rs"
pub fn import_photo(args: &Value) -> ToolOutcome {
    let photo = match files::parse_file_input(&args["photo"], Some(180 * 1024), 180 * 1024, false) {
        Ok(photo) => photo,
        Err(reason) => return ToolOutcome::err(json!({"error": reason})),
    };
    let Some(bytes) = photo.inline_bytes else {
        return ToolOutcome::err(json!({"error": "Send a photo of at most 180 KiB in the call."}));
    };
    // Store `bytes` in Object Storage, then answer with your own reference to it.
    ToolOutcome::ok(json!({"stored": bytes.len()}))
}
```

Put `x-mcp-file` on a top-level argument, as the helper does, and keep `allOf`, `anyOf` and `oneOf` away from the root of the input schema. Check the media type of what arrived before you use it: the description is the client's claim.

## Return a file

A person can always open a link, so give every export an access-checked URL in your application and return it in the tool's result. [Object Storage](/developers/object-storage/) holds the bytes. For a client that declares the extension's `download` setting, attach the same file as a download target as well. [Interactive MCP tools](/developers/mcp-interactive-tools/#receive-a-file) shows uploads outside the call and downloads, with the package's own file staging.

## Next

[MCP Servers](/developers/mcp-servers/) covers the endpoint, and [Ask before acting](/developers/mcp-elicitation/) covers a confirmation before a file replaces something.
