Skip to main content
Glama

create_file

Transfer local files to OneDrive using specified paths and account details. Simplify file management through integration with Microsoft Graph API.

Instructions

Upload a local file to OneDrive

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
local_file_pathYes
onedrive_pathYes

Implementation Reference

  • The main handler function for the 'create_file' tool. It reads the content of a local file and uploads it to the specified OneDrive path using the Microsoft Graph API via the graph.upload_large_file helper.
    @mcp.tool def create_file( onedrive_path: str, local_file_path: str, account_id: str ) -> dict[str, Any]: """Upload a local file to OneDrive""" path = pl.Path(local_file_path).expanduser().resolve() data = path.read_bytes() result = graph.upload_large_file( f"/me/drive/root:/{onedrive_path}:", data, account_id ) if not result: raise ValueError(f"Failed to create file at path: {onedrive_path}") return result
  • Supporting helper function that performs the actual file upload to Microsoft Graph OneDrive. Handles both small files (direct PUT) and large files (via createUploadSession and chunked upload). Called directly by the create_file handler.
    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)

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