Skip to main content
The OneDrive resource mounts a Microsoft OneDrive (or SharePoint document library) at some prefix such as /onedrive/. All operations involve network I/O to Microsoft Graph. Files are served as raw bytes (no Office filetype conversion). Uses aiohttp for async Graph access. Compatible with: personal OneDrive, OneDrive for Business, and SharePoint document libraries (driveItems on Microsoft Graph v1.0). For credential setup (tokens, drive ids, app vs delegated auth), see the OneDrive Setup guide.

Config

OneDriveResource(config) takes an OneDriveConfig object with a Microsoft Graph bearer token and optional drive/site targeting. Both READ and WRITE modes are supported.

Config Reference

Drive resolution order: drive_id, then the site_id site’s default drive, then /me/drive.

Filesystem Layout

The OneDrive resource maps Graph driveItems (path-addressed) to virtual paths under the mount prefix. Folders are real driveItems, so the tree matches what you see in OneDrive. For example, if the drive contains:
Then mounting at /onedrive/ exposes:
Path mapping: virtual /onedrive/Documents/file.txt maps to the driveItem at /root:/Documents/file.txt.

Versioning and Snapshots

OneDrive keeps per-file version history. The resource exposes it the same way the S3 backend does:
  • Fingerprint is the driveItem cTag, so normal reads and stat reflect the current content without extra Graph calls.
  • Snapshots pin each path to a Graph driveItem version id. Replaying a snapshot reads /versions/{id}/content, giving time-travel to the exact bytes captured at snapshot time.
  • Restore writes a previous version back as the current one.
This makes the OneDrive resource SUPPORTS_SNAPSHOT = True.

Cache

The OneDrive resource caches directory listings via IndexCacheStore to reduce repeated Graph calls during traversal.

Example

A runnable version lives at examples/python/onedrive/onedrive.py.

Shell Commands

The OneDrive resource supports the full set of shell commands since it operates on real file content (text, binary, JSON, CSV, etc.). Large files benefit from range reads to avoid downloading entire items.

Read Commands

File Operations

Path Utilities

Use Cases

  • AI agents accessing org documents: Mount OneDrive/SharePoint for agents to read and process files
  • Versioned document workflows: Snapshot and replay exact file states over time
  • Sandboxed access: Restrict agent operations to a specific drive and sub-folder via key_prefix
  • FUSE mounting: Expose a OneDrive through a virtual FUSE mount for external tools

Scoping a resource to a folder

Pass key_prefix: str | None = None to OneDriveConfig to transparently scope every operation to a sub-folder of the drive:
When set, every read/write/list/stat/copy/rename/delete operation is scoped to that sub-folder. Agents see clean paths like /data/notes.md; the underlying driveItem is users/{user_id}/data/notes.md. Useful for multi-tenant systems. Normalization: leading slashes are stripped and a trailing slash is added automatically. Both None and an empty string are treated as “no prefix.”