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")

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