File downloads
Give an agent a whole Microsoft 365 file through a download link, and allow the gateway host if its setup blocks it
An agent that needs the bytes of a file, to open a PDF, convert a Word document or attach a presentation, cannot get them from the text tools of an MCP server.
The download_file tool of Microsoft 365 Graph returns a download link to the whole file that works once, for about a minute.
The agent downloads it with its own tools.
The gateway does not read the file, and the agent never sees Microsoft's own download address.
What the agent receives
The agent passes the drive-id and driveItem-id of a file, which search_drive and list_recent_files return as the item's parentReference.driveId and id.
The tool returns one text block with these fields:
| Field | Meaning |
|---|---|
name | The filename |
mimeType | The file type, or application/octet-stream when Microsoft doesn't say |
size | The size in bytes |
digest | A SHA-256 digest, only when Microsoft provides one |
url | The download link on your gateway host |
expiresAt | When the download link stops working |
credentials | Always omit: the agent fetches the download link without sending any credentials |
The text also names the gateway host, so a blocked agent can tell the user what to allow. The tool refuses folders, OneNote notebooks, and empty files.
How the download link works
- One use.
The first request streams the file.
Any later request returns
410, or404once the expired record has been cleaned up. - About 60 seconds.
A download link that has expired returns
410, or404once the expired record has been cleaned up. Call the tool again for a new one. - Unknown download links return
404. - Up to 500 MB. A larger file is refused when the agent asks for the download link.
- Claude.ai holds up to 30 MB. Claude.ai's own sandbox caps the files it can hold at 30 MB, which is a Claude.ai limit (vendor documentation), not ours.
- No sign-in. Anyone who holds the download link can use it once, so it expires fast and the agent should fetch it at once.
The gateway streams the file from Microsoft to the agent as it arrives and keeps no copy.
It serves every file as application/octet-stream, so the agent takes the file type from mimeType and the extension of name.
A gateway restart or deploy during a download ends it, and Downloaded records the outcome as incomplete.
Which agents can use it
The agent needs a way to fetch a URL from its own environment. That is a separate network request from the MCP call, so what works depends on where the agent runs. MCP calls reach the gateway whatever these settings are.
The results below are what we tested or what the vendor documents. We have not yet confirmed every agent with a real download link from the tool, so try one file first. Claude.ai results come from downloading a public file by a URL the tester typed. Any agent not in the table is unknown.
| Agent | Expected | What you allow | Basis |
|---|---|---|---|
| Claude.ai, Pro | Downloaded a typed public URL once you allow the host; not yet tested with a download link from the tool | The user turns on Use the internet while making files and adds the gateway host | Tested |
| Claude.ai Team or Enterprise | Unknown, not tested with the host allowed | An organization owner sets Organization settings → Capabilities to allow the host | Unknown |
| Claude Code | Expected, with a prompt you approve | The user approves the fetch when Claude Code prompts | Vendor documentation |
| Claude Code on the web | Expected, once you allow the host | Add the gateway host to the environment's allowed domains | Vendor documentation |
| Codex cloud | Expected, once you allow the host | Add the gateway host to the environment's allowed domains | Vendor documentation |
| Cursor cloud agents | Expected | Nothing, internet access is on by default | Vendor documentation |
| Cowork | Unlikely | Shell fetch needs all domains allowed; whether the setting is honored is unknown | Vendor documentation |
| ChatGPT chat | Cannot save a file today: the code sandbox can't resolve hosts, and browsing read a PDF but saved no bytes | Nothing you can allow | Tested |
| Claude API with the MCP connector | No | Not possible | Vendor documentation |
| Copilot Studio | No | Not possible | Vendor documentation |
Allow the gateway host
When the agent's environment blocks the download, the tool's message names the host to allow.
It is the host of your gateway URL, the one in url.
On Claude.ai the block shows as a failed CONNECT with response 403, and the error names the setting that controls it.
- In the agent's settings, find the list of allowed domains.
- Add the gateway host.
- Ask the agent to call the tool again, because the first download link was used or has expired.
Control who can download
download_file is a Graph tool like the others, so access rules and approvals apply to it.
It carries the write tag, so a rule that covers only read-only tools does not cover it.
Allow it for the agents that need whole files, and require approval where you want a person to decide first.
A usage limit on the download_file tool caps how many download links an agent or a user can create.
The agent uses the signed-in person's own Microsoft 365 access, so it can download only files that person can open.
Audit
Each download link and each download is recorded in Agent Trail:
| Event | What it records |
|---|---|
| Download Link Created | The person, the agent, the filename, the size, where the file lives (drive-id and driveItem-id) |
| Downloaded | The same, with the outcome (complete, incomplete, or an upstream error) and the bytes sent |
Neither event records the download link or Microsoft's download address.
Next steps
You can now let an agent download a whole Microsoft 365 file, and you know which agents need a setting changed first. Next, decide which agents may call the tool.
- Control MCP tool access – allow
download_filefor some agents only - Microsoft 365 Graph – every tool the connection offers