Skip to main content
Glama

get_file

Download files from OneDrive to a specified local path by providing the file ID, account ID, and download path. Enables efficient file management through Microsoft Graph API integration.

Instructions

Download a file from OneDrive to local path

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
download_pathYes
file_idYes

Implementation Reference

  • The handler function for the 'get_file' tool. It fetches file metadata from Microsoft Graph, retrieves the download URL, downloads the file using curl to the specified local path, and returns file information including path, name, size, and MIME type. The @mcp.tool decorator registers this function as an MCP tool.
    @mcp.tool def get_file(file_id: str, account_id: str, download_path: str) -> dict[str, Any]: """Download a file from OneDrive to local path""" import subprocess metadata = graph.request("GET", f"/me/drive/items/{file_id}", account_id) if not metadata: raise ValueError(f"File with ID {file_id} not found") download_url = metadata.get("@microsoft.graph.downloadUrl") if not download_url: raise ValueError("No download URL available for this file") try: subprocess.run( ["curl", "-L", "-o", download_path, download_url], check=True, capture_output=True, ) return { "path": download_path, "name": metadata.get("name", "unknown"), "size_mb": round(metadata.get("size", 0) / (1024 * 1024), 2), "mime_type": metadata.get("file", {}).get("mimeType") if metadata else None, } except subprocess.CalledProcessError as e: raise RuntimeError(f"Failed to download file: {e.stderr.decode()}")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/elyxlz/microsoft-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server