Skip to main content
Glama
Microsoft 365 MCP Server

Microsoft 365 MCP Server

by Softeria

download-bytes-to-file

Read-only

Save authenticated Microsoft Graph bytes, including mail attachments and meeting recordings, to an absolute local file without base64; returns path, content type, and byte count.

Instructions

Write authenticated Microsoft Graph byte content to a local file on the server, returning { path, contentType, bytesWritten } instead of base64. An out-of-band way to save mail attachments and meeting recordings. With --enable-attachment-urls in HTTP mode, prefer get-download-url to hand their bytes to an external downloader or converter. Also handles profile photos and Teams hosted content. Writes to an absolute outputPath and never overwrites an existing file. stdio mode, or HTTP with --http-local-file-tools. For OneDrive or SharePoint file content, get-download-url is preferred — it returns a pre-authenticated URL for fully out-of-band download without the server fetching the bytes.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "target": "<target>",
      "outputPath": "<outputPath>"
    },
    "name": "download-bytes-to-file"
  }
}

Input Schema

NameRequiredDescriptionDefault
acceptNoOptional Accept header. Set only when Graph asks for another format (transcript content: application/vnd.microsoft.graph.transcript+text).
targetYesRelative Microsoft Graph path starting with "/". Common paths: /drives/{drive-id}/items/{driveItem-id}/content (drive file content); /me/messages/{message-id}/attachments/{attachment-id}/$value (mail attachment, list-mail-attachments returns the IDs); /me/photo/$value or /users/{user-id}/photo/$value (profile photo); /chats/{chat-id}/messages/{chatMessage-id}/hostedContents/{chatMessageHostedContent-id}/$value (Teams chat hosted content, list-chat-message-hosted-contents returns the IDs); /teams/{team-id}/channels/{channel-id}/messages/{chatMessage-id}/hostedContents/{chatMessageHostedContent-id}/$value (Teams channel hosted content). For meeting recordings, use get-meeting-recording-content where available; Microsoft Graph returns authenticated recording bytes, not a pre-authenticated download URL.
outputPathYesAbsolute path on the server's filesystem where the bytes are written, e.g. /Users/me/downloads/invoice.pdf. Must be absolute; relative paths are rejected. The parent directory must already exist, and an existing file is never overwritten (the call errors if outputPath already exists).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.181.0
    • addedInput schema / properties / accept
      Added value: +{
      +  "description": "Optional Accept header. Set only when Graph asks for another format (transcript content: application/vnd.microsoft.graph.transcript+text).",
      +  "maxLength": 256,
      +  "pattern": "^(?:[\\x21-\\x7E](?:[\\x20-\\x7E]*[\\x21-\\x7E])?)?$",
      +  "type": "string"
      +}
  2. Addedv0.134.4

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only say readOnlyHint/openWorldHint; the description adds substantive behavior: the server fetches the bytes itself (no pre-authenticated URL), an existing file is never overwritten, the parent directory must pre-exist, and the tool is gated on transport mode/flags. The readOnlyHint=true is consistent because it writes to the local filesystem rather than mutating Graph state.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the purpose and return shape, then the alternatives and preconditions in decreasing priority. It is dense but a few clauses restate what the schema already says (absolute outputPath, no overwrite), which is the only waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, yet the description gives the exact return shape, plus failure conditions and transport gating. For a 3-parameter write-to-disk tool, everything an agent needs to invoke it correctly is present.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so target, accept, and outputPath are already fully documented with examples and constraints. The description's only added parameter meaning — absolute outputPath, never overwrites — duplicates the schema text verbatim rather than extending it. Baseline 3 applies when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource — writing authenticated Microsoft Graph byte content to a local server file — and disambiguates from near-identical siblings (download-bytes, get-download-url, get-mail-attachment-content) by naming the return shape { path, contentType, bytesWritten } instead of base64. An agent can route correctly without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly names the alternative and the condition that selects it: for OneDrive/SharePoint content or when --enable-attachment-urls is set in HTTP mode, prefer get-download-url, and for meeting recordings use get-meeting-recording-content. It also states the availability precondition (stdio mode, or HTTP with --http-local-file-tools), which is a genuine when-you-can-use-this rule.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools