Skip to main content
Glama

update_file

Sync local file changes to OneDrive by updating file content using the Microsoft Graph API. Specify file ID, local file path, and account ID for seamless integration.

Instructions

Update OneDrive file content from a local file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
file_idYes
local_file_pathYes

Implementation Reference

  • The core handler function for the 'update_file' tool. It reads the local file content and uploads it to the specified OneDrive file ID using the graph helper. The @mcp.tool decorator handles registration and schema generation.
    @mcp.tool
    def update_file(file_id: str, local_file_path: str, account_id: str) -> dict[str, Any]:
        """Update OneDrive file content from a local file"""
        path = pl.Path(local_file_path).expanduser().resolve()
        data = path.read_bytes()
        result = graph.upload_large_file(f"/me/drive/items/{file_id}", data, account_id)
        if not result:
            raise ValueError(f"Failed to update file with ID: {file_id}")
        return result
  • Supporting utility function called by the update_file handler to perform the actual large file upload to Microsoft Graph API, handling both small and large files with chunked upload sessions.
    def upload_large_file(
        path: str,
        data: bytes,
        account_id: str | None = None,
        item_properties: dict[str, Any] | None = None,
    ) -> dict[str, Any]:
        """Upload a large file using upload sessions"""
        file_size = len(data)
    
        if file_size <= UPLOAD_CHUNK_SIZE:
            result = request("PUT", f"{path}/content", account_id, data=data)
            if not result:
                raise ValueError("Failed to upload file")
            return result
    
        session = create_upload_session(path, account_id, item_properties)
        upload_url = session["uploadUrl"]
    
        headers = {"Authorization": f"Bearer {get_token(account_id)}"}
        return _do_chunked_upload(upload_url, data, headers)
  • Creation of the FastMCP server instance named 'microsoft-mcp'. All tools decorated with @mcp.tool, including update_file, are automatically registered to this instance upon module import.
    mcp = FastMCP("microsoft-mcp")
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks behavioral details. It implies a mutation (updating file content), but doesn't disclose permissions needed, whether it overwrites or merges content, error handling, or side effects. This is inadequate for a mutation tool with zero annotation coverage.

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, efficient sentence that front-loads the core action and resource. There is no wasted text or redundancy, 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 mutation tool with 3 parameters, 0% schema coverage, no annotations, and no output schema, the description is incomplete. It lacks details on behavior, parameters, usage context, and expected outcomes, leaving significant gaps for an AI agent to operate effectively.

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

Parameters1/5

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

Schema description coverage is 0%, and the description adds no parameter information beyond what's inferred from names. It doesn't explain what 'account_id', 'file_id', or 'local_file_path' mean, their formats, or constraints. For 3 undocumented parameters, this fails to compensate for the schema gap.

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 ('Update') and resource ('OneDrive file content'), specifying it updates from a local file. It distinguishes from siblings like 'create_file' (new) and 'delete_file' (remove), but doesn't explicitly differentiate from other update tools like 'update_contact' or 'update_event' beyond the resource type.

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 on when to use this tool versus alternatives is provided. It doesn't mention prerequisites (e.g., authentication), compare to similar tools like 'update_contact', or indicate scenarios where it's appropriate versus not. The description only states what it does, not when to use it.

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