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()}")
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions downloading but lacks details on permissions required, file size limits, overwrite behavior at the local path, error handling, or response format. This leaves significant gaps for a tool that performs file operations.

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

Conciseness5/5

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

The description is a single, direct sentence that efficiently conveys the core action without unnecessary words. It's front-loaded and appropriately sized for the tool's complexity, making it easy to parse quickly.

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

Completeness2/5

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

For a tool with 3 parameters, 0% schema coverage, no annotations, and no output schema, the description is incomplete. It doesn't address key aspects like authentication needs, file handling behavior, or what happens on success/failure, leaving the agent with insufficient context for reliable use.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate but adds no parameter details. It doesn't explain what 'account_id', 'file_id', or 'download_path' represent, their formats, or constraints (e.g., path must be writable). This leaves all three parameters undocumented beyond their names.

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

Purpose4/5

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

The description clearly states the action ('Download') and resource ('a file from OneDrive') with the destination ('to local path'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get_attachment' or 'list_files' which might have overlapping functionality.

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

Usage Guidelines2/5

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

No guidance is provided about when to use this tool versus alternatives like 'get_attachment' (for email attachments) or 'list_files' (for browsing). The description implies downloading but doesn't specify prerequisites such as authentication or file accessibility.

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

Install Server

Other Tools

Related Tools

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