Skip to Content
MCP GatewayConnect Agents

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:

FieldMeaning
nameThe filename
mimeTypeThe file type, or application/octet-stream when Microsoft doesn't say
sizeThe size in bytes
digestA SHA-256 digest, only when Microsoft provides one
urlThe download link on your gateway host
expiresAtWhen the download link stops working
credentialsAlways 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.

  • One use. The first request streams the file. Any later request returns 410, or 404 once the expired record has been cleaned up.
  • About 60 seconds. A download link that has expired returns 410, or 404 once 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.

AgentExpectedWhat you allowBasis
Claude.ai, ProDownloaded a typed public URL once you allow the host; not yet tested with a download link from the toolThe user turns on Use the internet while making files and adds the gateway hostTested
Claude.ai Team or EnterpriseUnknown, not tested with the host allowedAn organization owner sets Organization settings → Capabilities to allow the hostUnknown
Claude CodeExpected, with a prompt you approveThe user approves the fetch when Claude Code promptsVendor documentation
Claude Code on the webExpected, once you allow the hostAdd the gateway host to the environment's allowed domainsVendor documentation
Codex cloudExpected, once you allow the hostAdd the gateway host to the environment's allowed domainsVendor documentation
Cursor cloud agentsExpectedNothing, internet access is on by defaultVendor documentation
CoworkUnlikelyShell fetch needs all domains allowed; whether the setting is honored is unknownVendor documentation
ChatGPT chatCannot save a file today: the code sandbox can't resolve hosts, and browsing read a PDF but saved no bytesNothing you can allowTested
Claude API with the MCP connectorNoNot possibleVendor documentation
Copilot StudioNoNot possibleVendor 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.

  1. In the agent's settings, find the list of allowed domains.
  2. Add the gateway host.
  3. 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:

EventWhat it records
Download Link CreatedThe person, the agent, the filename, the size, where the file lives (drive-id and driveItem-id)
DownloadedThe 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.

On this page