Support file uploads and downloads changedconnectors/building/files
Nearest release: v2.1.332, published 5 hours after upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 24 Nov 2026 17:01 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 24 Nov 2026 17:07 UTC.
# Support file uploads and downloads ## Requirements for file transfers ### Request approval for your hosts ### URLs, headers, and fields of a target ### Targets with `include` credentials ## Advertise the extension ### Check what each call declares ## Receive a file in a tool ### Mark the file argument ### Return an upload target #### Build the `requestState` value ### Accept the bytes of an upload ### Finish the upload on the second call ### SDK support for file transfers ## Return a file from a tool ### List the file in the result ### Serve the download ## Limits on file transfers ## Test file transfers ### Test your server with curl ### Test in Claude Code ## Troubleshoot file transfers ## Next steps
The whole hunk
612 lines, new pageA whole new page. There's nothing to diff it against, so here is what it says.
# Support file uploads and downloads > Let a tool on your MCP server receive files from Claude and return files to it: requirements, host approval, uploads, downloads, limits, and testing. File transfers let a tool on your MCP server receive a user's file from Claude (an upload) or return a file to Claude (a download). For example, when a user asks Claude to save a PDF to a folder in your product, your tool receives the PDF. When a user asks for an export from your product, your tool returns the export. This page is for developers whose remote MCP server already works as a connector in Claude. File transfers are in beta and use an experimental MCP extension, [File Uploads and Downloads](https://github.com/modelcontextprotocol/experimental-ext-file-uploads/blob/main/specification/draft/file-uploads.md) (`io.modelcontextprotocol/files`). Expect breaking changes to the extension. > [!NOTE] > > These cases are covered on other pages: > > * **Saving a file from an MCP App's view to the user's device**: see [Download files from your MCP App](https://claude.com/docs/connectors/building/mcp-apps/download-files.md) > * **Building your first MCP server**: see [Build your first MCP server for Claude](https://claude.com/docs/connectors/building/quickstart.md) First, [check the requirements](#requirements-for-file-transfers) and [advertise the extension](#advertise-the-extension). Then build uploads, downloads, or both: * **Uploads**: [receive a file in a tool](#receive-a-file-in-a-tool) * **Downloads**: [return a file from a tool](#return-a-file-from-a-tool) ## Requirements for file transfers Before you build, check that your connector, server, storage, and account meet these requirements: * **Directory listing**: Claude transfers files for connectors that people add from the [Connectors Directory](https://claude.com/docs/connectors/directory.md). The address that they connect to must exactly match an address on your listing. Adding your server by URL doesn't link the connector to your listing. If a connector isn't linked, Claude sends it no files and removes any files from its tools' results. Your server receives no error. * **Server URL**: your listing needs one URL that every user connects to, or a fixed set under [**Multiple URLs**](https://claude.com/docs/connectors/building/authentication.md#servers-with-per-customer-urls). If each customer enters their own URL, such as with a **URL pattern**, Claude doesn't transfer files. * **MCP revision**: serve [MCP revision 2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28) over Streamable HTTP, along with the revisions that you serve today * **Library**: use a version that supports revision 2026-07-28. To receive uploads, it must also let a tool return the `upload_required` result type, which the extension adds. See the tested versions under [SDK support for file transfers](#sdk-support-for-file-transfers). Version 1.32.2 of `@modelcontextprotocol/sdk`, the package that the [quickstart](https://claude.com/docs/connectors/building/quickstart.md) uses, supports neither uploads nor downloads. * **Storage**: for uploads, your storage must accept a whole file in one `PUT` or `POST` request. For downloads, it must serve a file to a `GET` request, in byte ranges if it can. * **Approved hosts**: Anthropic must approve the hosts that store your connector's files. Your connector needs at least one approved host, even if every file goes through your MCP server. [Request approval for your hosts](#request-approval-for-your-hosts) before you build on them. Claude can also get files from your MCP server's own host, and send files to it with [`include` credentials](#targets-with-include-credentials). Claude refuses a URL on any other host, on an IP address, or on another company's storage or CDN host that all its customers share. * **Account for testing**: use a Claude account that has access to file transfers. Name the account when you [request approval for your hosts](#request-approval-for-your-hosts). If it doesn't have access, or you aren't sure, ask Anthropic in the same email to turn on file transfers for testing. Use made-up files in your tests, not real ones. On Team and Enterprise plans, an Owner must also go to [**Organization settings > Connectors**](https://claude.ai/admin-settings/connectors). Under **File transfers**, the Owner turns on the **File uploads to connectors** toggle, the **File downloads from connectors** toggle, or both. Some organizations can't use file transfers, such as those with HIPAA settings, zero data retention, customer-managed encryption keys, an IP allowlist, or a default workspace that keeps data outside the US. ### Request approval for your hosts Before Claude transfers files for a listing, Anthropic approves the listing's hosts. If your connector isn't listed yet, [submit it](https://claude.com/docs/connectors/building/submission.md) first. To request approval, email `[email protected]` with the subject `Connector file hosts: <connector name>` and these details: * **Listing**: your listing's name and its server URLs * **Hosts**: the full name of each host that Claude sends files to or gets files from, in every region. You can name up to 50. If files go through your MCP server, include its host. If your storage generates host names, you can ask for a wildcard, such as `*.downloads.example.com`. Anthropic reviews each one, and you must control every name under it. * **Use of each host**: whether it's for production or testing, whether all your customers share it, and whether it's behind a CDN * **Ownership**: for a host on another domain of yours, a public page that shows that the domain is yours. For a bucket or account host on a storage provider's domain, a statement that the exact host name is yours. * **Test organization**: the email address of the Claude account that you test with. If that account is in a Team or Enterprise organization, also the **Organization ID**, which you copy from [**Organization settings > Organization and access**](https://claude.ai/admin-settings/organization). Wait for Anthropic to confirm the hosts and the test organization before you rely on them. An approval covers the hosts that Anthropic confirmed and the server URLs that your listing had at that time. Before you use a host that it doesn't cover, or a new server URL, email again. Claude doesn't transfer files there until Anthropic approves it. ### URLs, headers, and fields of a target A target is an object in your server's response that says where Claude sends or gets one file. In each upload target and download target, follow these rules: * **Address**: use `https` on port 443 and a host name that resolves to public IPv4 addresses, with a certificate from a public certificate authority. Use TLS 1.3, or TLS 1.2 with an ECDHE suite that uses AES-GCM or ChaCha20-Poly1305. Use a host on a domain that you own where you can. * **Authorization**: make the URL carry its own authorization, such as a short-lived signature, and set the target's `credentials` field to `"omit"`. If you sign the URL with temporary credentials, such as a cloud role's, use ones that last at least as long as the URL. Anyone who has the URL can use it until it expires, so make each URL work for one file, and either for its upload or for its download. For a URL on your MCP server itself, see [targets with `include` credentials](#targets-with-include-credentials). * **Characters**: percent-encode spaces and other characters that a URL's query can't contain, and leave out `#` * **Headers**: in the target's `headers` field, list only the headers that your storage needs, each name once. Headers that Claude refuses include `Authorization`, `Cookie`, `Host`, `Content-Length`, `Date`, and `User-Agent`. * **Fields**: add no fields that the extension doesn't define * **Logs**: keep target URLs, target headers, form fields, inline file data, and an upload's [`requestState`](#return-an-upload-target) out of logs, traces, and error reports If a target's host, query, header, or field breaks a rule, expect these results: * **Upload**: Claude refuses your server's whole response, including the targets for other files * **Download**: Claude leaves that target's file out of the result, or replaces the result with an error Have your storage answer at the target's URL directly. A redirect fails the transfer. Don't put a sign-in page, a bot challenge, or a filter on `User-Agent` or source address in front of the URL. ### Targets with `include` credentials If a target's URL has the same scheme, host, and port as your connector's address, you can set `credentials` to `"include"`. Claude then sends or gets the file with the `Authorization` header that it sent on the tool call. For an `include` target, follow these rules: * **Application**: name a URL that your MCP server's own application serves. Don't name one that another application on the same host serves, because that application would receive the user's token. * **User**: check that the token belongs to the user that you issued the target to * **Token lifetime**: a large upload can reach your server 20 minutes after the tool call, with that call's token. If your server can refuse the token by then, use `"omit"` for large files. * **Several uploads**: use `"omit"` if you return several upload targets. With `"include"`, Claude has to start each upload within five minutes of your response, and it can send the files one after another. * **Large downloads**: use `"omit"` for a large file. With `"include"`, Claude gets the whole file in one `GET` and doesn't resume it. * **Refusal**: use `"omit"` if Claude calls your server without an `Authorization` header, or if your listing says that the connector handles personal health data. Claude refuses `include` targets in these cases, and for some other connectors. ## Advertise the extension In your response to `server/discover`, list `io.modelcontextprotocol/files` under `capabilities.extensions`. If you take uploads, set it to `{ "upload": {} }`. If you only return files, set it to `{}`. `download` is a client setting, so leave it out. This example leaves out the response's other members: ```json theme={null} { "supportedVersions": ["2026-07-28"], "capabilities": { "extensions": { "io.modelcontextprotocol/files": { "upload": {} } } } } ``` Answer `server/discover` well within two seconds, in the same way for every user and on every instance of your server. A `401` for a missing or expired token has no effect on the extension. If any instance responds with another error, such as `-32601`, Claude can stop using the extension with your server for about a day after the last error. ### Check what each call declares In `params._meta`, each `tools/call` request of revision 2026-07-28 can declare that the client supports `upload`, `download`, both, or neither. Treat a request of an older revision as declaring neither. Read the declaration on every call. If the declaration has a `revision` field with a value that you don't know, treat the extension as not declared. This `_meta` value declares both: ```json theme={null} { "io.modelcontextprotocol/clientCapabilities": { "extensions": { "io.modelcontextprotocol/files": { "upload": {}, "download": {} } } } } ``` If a call doesn't declare what a tool needs, respond in this way: * **You advertise `upload`, the call doesn't declare it, and a [file argument](#mark-the-file-argument) has a `size` above 0 and no `data`**: return error `-32021` and don't run the tool. `data` is the extension's field for a file's bytes in the call itself. Claude doesn't send it in a call that declares `upload`. * **The call doesn't declare `download`**: respond without a download target. In `content`, say that no file was delivered and, if you can, where the user can get it. If the tool can't work without the download, return error `-32021` and don't run the tool. Name what is missing in the error's `data.requiredCapabilities`. On a call of revision 2026-07-28, send the error as a JSON body with HTTP status `400`. This error leaves out `jsonrpc` and `id`: ```json theme={null} { "error": { "code": -32021, "message": "This app can't send files to this connector, so the tool didn't run.", "data": { "requiredCapabilities": { "extensions": { "io.modelcontextprotocol/files": { "upload": {} } } } } } } ``` ## Receive a file in a tool In an upload, Claude calls your tool twice, and the bytes go to your storage between the two calls: 1. Claude calls the tool with the file's name, type, size, and digest 2. Your server responds with an upload target for the file 3. Anthropic's servers send the bytes to the target 4. Claude calls the tool again with the same arguments, and your server runs the tool The JSON examples of uploads leave out `jsonrpc`, `id`, and `_meta`. ### Mark the file argument A file argument is a tool argument that takes a user's file. To mark a file argument, add `x-mcp-file` to the object schema of a top-level argument. This tool takes a folder ID and a PDF: ```json theme={null} { "name": "save_to_folder", "description": "Save a file to a folder", "annotations": { "title": "Save to folder", "readOnlyHint": false, "destructiveHint": true }, "inputSchema": { "type": "object", "properties": { "folderId": { "type": "string" }, "file": { "type": "object", "description": "A PDF of up to 50 MiB.", "x-mcp-file": { "accept": ["application/pdf"], "maxSize": 52428800 }, "properties": { "id": { "type": "string", "minLength": 1, "maxLength": 128 }, "name": { "type": "string" }, "mimeType": { "type": "string" }, "size": { "type": "integer", "minimum": 0 }, "digest": { "type": "object", "properties": { "algorithm": { "const": "sha-256" }, "value": { "type": "string" } }, "required": ["algorithm", "value"] } }, "required": ["id", "mimeType", "size"] } }, "required": ["folderId", "file"] } } ``` Copy the file object's `properties` and `required`. If you change them, Claude might not recognize the argument, and then calls that set it don't reach your server, or don't declare `upload`. These variations work, with `x-mcp-file` on the file object itself: * **Optional file**: an `anyOf` of the file object and `{"type": "null"}` * **Several files**: an array whose `items` is the file object * **Digest that you verify**: `digest` added to the file object's `required` Keep `x-mcp-file`, `allOf`, `anyOf`, and `oneOf` off the root of `inputSchema`. If the root has any of them, calls of the tool might not reach your server. Other root keywords, such as `patternProperties`, can stop file transfers. Design the tool with these rules in mind: * **Size and type**: state your limits in `description` as well, and check the size and type yourself. Claude can refuse a file over `maxSize` before it calls your tool, and `accept` is a hint. * **Unknown types**: Claude takes `mimeType` from the file's name or its first bytes, and sends `application/octet-stream` for types that it doesn't know. Accept that value on the first call, and `text/plain` too if you take text files, such as JSON. Check the bytes on the second call. * **Unverified fields**: don't assume that a field of the file argument is correct. Rely on `digest`, the SHA-256 of the bytes in base64url with no padding, only after you verify it. * **New tool**: add the file argument to a new tool. A client without the extension can't reliably fill a file argument, so adding one to a tool that people use today can break that tool. * **Tool list**: include the tool in every `tools/list` response to an account that you show it to, even if the request doesn't declare the extension. Then [check what each call declares](#check-what-each-call-declares). * **Annotations**: in `annotations`, give a tool that saves a file a `title`, `readOnlyHint: false`, and `destructiveHint: true`. See [Provide tool annotations](https://claude.com/docs/connectors/building/review-criteria.md#provide-tool-annotations). * **Validation**: check each call's arguments in your own code, with a validator that accepts `x-mcp-file` * **Questions to the user**: don't return an input request from a tool that moves a file ### Return an upload target On the first call of an upload, Claude sends the file's details and no bytes: ```json theme={null} { "name": "save_to_folder", "arguments": { "folderId": "fld_8c1a", "file": { "id": "file-1", "name": "Q3 report.pdf", "mimeType": "application/pdf", "size": 41204133, "digest": { "algorithm": "sha-256", "value": "uU0nuZNNPgilLlLX2n2r-sSE7-N6U4D6ZVe-_rYh2sU" } } } } ``` Check that the user can write to the destination, and check the quota, the type, and the size. If you can take the file, don't run the tool yet. Respond with a result whose `resultType` is `upload_required`, which asks Claude to send the file. This result is an upload request. List one target for each file that has a `size` above 0 and no `data`: ```json theme={null} { "result": { "resultType": "upload_required", "uploads": [ { "fileId": "file-1", "url": "https://upload.example.com/u/01JD3V7K2M?sig=...", "headers": { "Content-Type": "application/pdf" }, "credentials": "omit" } ], "requestState": "..." } } ``` Return the upload request as your response to Claude's first `tools/call`, and follow these rules: * **Refusal**: if you can't take the file, return a result with `resultType` `"complete"`, `isError: true`, and a sentence in `content` that the user can act on. Refuse a call in which two files have the same `id`, or a file has `data` that you don't accept. * **Target**: set `fileId` to the file's `id`. Claude sends a `PUT` unless you set `method` to `"POST"`. If your MCP server takes the upload itself, list `Content-Type: application/octet-stream`, so that its JSON parser leaves the body alone. * **Form uploads**: if your storage takes nothing but `multipart/form-data`, use a target with the extension's [`form` field](https://github.com/modelcontextprotocol/experimental-ext-file-uploads/blob/main/specification/draft/file-uploads.md#upload-request). Set `method` to `"POST"` and list no `Content-Type` header. The form's fields can carry the authorization and the staging place instead of the URL. * **Lifetime**: keep the URL valid for at least 20 minutes after you return it, or 75 minutes if you return several targets. A large file can reach your storage that late. * **Staging**: point each URL at its own randomly named place in a staging location, which takes one write and enforces the declared size. Show no staged file to users until the second call succeeds. * **Signed headers**: if the URL's signature can cover headers, have it cover `Content-Length` and a write-once condition as headers, not in the query. Use a condition that your storage enforces, such as `If-None-Match: *`. List it in the target's `headers`, and leave `Content-Length` out. Without `form`, Claude sets `Content-Length` to the file's `size`. * **Signed headers with `boto3`**: create the client with the bucket's region and `Config(signature_version="s3v4", s3={"addressing_style": "virtual"})`. In some regions, the default signature covers neither header. Use a bucket with no dot in its name. A dot puts the URL on a host that all customers share. * **Checksum of an empty body**: if your signed URL's query holds `x-amz-checksum-crc32=AAAAAA%3D%3D`, it names the checksum of an empty body. Create your storage's JavaScript client with `requestChecksumCalculation: "WHEN_REQUIRED"`. * **Empty files**: return no target for a file whose `size` is 0. If your schema requires `digest` and the digest doesn't match, return a result with `isError: true`. If no file needs a target, run the tool and return its result. * **Repeated calls**: the first call can arrive more than once. Respond with a new target and a new `requestState` each time. #### Build the `requestState` value With `requestState`, your server matches the second call to the upload request that it issued. Your server creates this string, and Claude sends it back unchanged. Build it with these properties: * **Contents**: tie it to the tool name, the arguments, each target, and the signed-in user's ID, and record that you issued an upload request. Leave out the access token, which can change between the two calls. * **Protection**: keep the contents in storage that all your instances share, and use a random ID that looks them up as `requestState`. If you put the contents in the string itself, seal them with authenticated encryption and a key that all your instances hold. * **Expiry**: make it expire after about an hour, or about two hours if you return several targets. Each target has to stop working before `requestState` expires. ### Accept the bytes of an upload After your server returns an upload request, Anthropic's servers send each file to its target at most once. Unless the target has a `form` field, the body of the request is the file, with a `Content-Type` if you listed one. With `form`, the request is `multipart/form-data`. Each request has a `Content-Length` and the headers that you listed. * **Success**: respond with a `2xx` status only after the whole file is stored. Claude ignores the response body. Send the response uncompressed. * **Time**: receive the file within the [limits on file transfers](#limits-on-file-transfers) * **Failure**: any other status fails the upload. If an upload fails, your server receives no second call, so delete staged bytes after `requestState` expires. ### Finish the upload on the second call The second call of an upload has the same arguments as the first and adds `requestState` to `params`. The call doesn't prove that the bytes arrived. Complete these steps in order: 1. **State**: verify that you issued `requestState`, and that it hasn't expired or been used. If a check fails, return JSON-RPC error `-32602`. 2. **Call**: compare the tool name, the arguments, and the user with what `requestState` holds. Compare the arguments as JSON values, so that member order and number spelling don't matter. If they differ, return `-32602`. 3. **Files**: if the target can still overwrite the staged file, copy the file to a place in staging that is new for each call and that the target can't write. Use the copy from here on. Confirm with your storage that each file that you gave a target arrived, and check its size. Check its bytes if the tool restricts the type, and verify its digest if your schema requires one. If a check fails, return a result with `isError: true` and don't run the tool. 4. **Repeats**: if it's unsafe to run the tool twice, mark `requestState` as used in one atomic write to storage that all your instances share. If the string holds sealed contents, mark a random ID that you sealed in them, because another string can decode to the same contents. Keep the mark until `requestState` expires. If another call used it first, return `-32602`. 5. **Result**: finalize the file that you checked, copying it out of staging. Run the tool, and return its result. If you can't finalize the file, return a result with `isError: true` and don't run the tool. Keep the staged bytes until `requestState` expires. Follow these rules as you check the files and return the result: * **Digest**: hash the bytes yourself, or compare a SHA-256 that your storage computed. A value from the client or a weaker hash doesn't verify the file. * **No second upload request**: don't answer the second call with another upload request * **Secrets**: keep the upload URL and `requestState` out of results and errors * **Time**: respond well within 60 seconds. If Claude doesn't receive your response in 60 seconds, it can tell the user that it doesn't know whether the tool ran. ### SDK support for file transfers To receive uploads, use the low-level `Server` in the TypeScript or Python SDK. The samples were run with these versions: * **TypeScript**: `@modelcontextprotocol/server` 2.4.0, served with `createMcpHandler`. Add `"content": []` to the upload request. Without it, the SDK responds with error `-32602`. * **Python**: `mcp` 2.3.0. Return results as dictionaries that include `resultType`, and in `tools/list` results also `ttlMs` and `cacheScope`. Put a valid `content` list in each tool result. Without one, the SDK can drop `isError`, and a refusal looks like a success. Don't add `RequestStateBoundary`, which refuses the second call. In Python, `MCPServer` in `mcp` 2.3.0 and `FastMCP` in `fastmcp` 4.0.10 turn an upload request that a tool returns into an ordinary result, so Claude sends no file. The samples advertise the extension, require sign-in, read what a call declares, and answer the first call of an upload. They leave out your other tools, empty files, and your checks of the user's permissions, the quota, the type, and the size. Define these names yourself, above the sample: * **Tools**: `listTools`, `createTarget`, and `secondCall` (in Python, `list_tools`, `create_target`, and `second_call`). `createTarget` returns a signed URL and `requestState`. * **Sign-in in TypeScript**: `signIn` is Express middleware. It responds with a `401` that names [your discovery metadata](https://claude.com/docs/connectors/building/authentication.md#serve-discovery-metadata) to a request whose token is missing, invalid, expired, or issued for another server. For a valid token, it sets `req.auth`, which your code reads as `ctx.http?.authInfo`. * **Sign-in in Python**: `AUTH` is an `AuthSettings` from the SDK, with your authorization server's URL as `issuer_url` and your connector's address as `resource_server_url`. Keep `AUTH` and `TOKEN_VERIFIER` in the sample. Without them, a call with no token reaches your tool. * **Token check in Python**: `TOKEN_VERIFIER` is an object with an async `verify_token` method. It returns `None` for a token that is invalid, expired, or issued for another server, and an `AccessToken` for a valid one. Your code reads that with `get_access_token()` from `mcp.server.auth.middleware.auth_context`. > [tab] TypeScript >
Cut at 300 lines. The page has the rest.
No line in this hunk matches that.