Skip to main content
The OneDrive VFS 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

OneDriveVFS(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

Fields marked secret are redacted in snapshots.

Naming the drive

drive_id, site_id, group_id and user_id are four ways of saying which drive the mount is, so set at most one. Setting two raises at config time rather than silently addressing whichever came first, which otherwise surfaces much later as an unexplained 404. Setting none means /me/drive, the signed-in user’s own drive, which requires delegated auth; app-only auth must set one selector and the permissions to read that target.

The service root

Mounts address https://graph.microsoft.com/v1.0 unless graph_base_url says otherwise. Set it to reach anything else: a sovereign cloud, a private endpoint, or a test server. Give the full root including the version segment, for example https://graph.microsoft.us/v1.0. This matters most for the sovereign deployments, which are network-isolated instances rather than regions: a token minted for one is rejected by the others, so a mount pointed at the wrong root fails outright rather than degrading. mirage does not ship a table of their hostnames, since it has no way to verify one; take the root from Microsoft’s national cloud documentation for your tenant. Because the root is read from the config rather than a module constant, two mounts in one process can address different deployments.

VFS.md

The VFS.md an agent reads with OneDrive mounted at /<path>.

Virtual Filesystem

Supported Unix Commands for VFS

Unix commands work on each path as on a local filesystem, as far as the path supports them:

Limitations of Unix Commands for VFS

Where a path differs from a local filesystem:Run man <cmd> or <cmd> --help for one command’s usage.
The OneDrive VFS 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 VFS 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 file the agent read to its driveItem version id. Replaying a snapshot reads /versions/{id}/content, giving the exact bytes captured at snapshot time. A file the agent wrote carries no version and is not checked on replay.

Cache

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

Example

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

Shell Commands

The OneDrive VFS 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

Integration

What OneDrive answers through its own API, so fewer files are read. Integration explains each command. grep -rw and rg -w read only the files Microsoft Graph search names; every file is read when the search fails or finds nothing. walk_limit: -1 in the mount’s "@all" command limit reads every file instead, since Graph searches the text it extracted, not the bytes grep reads, and indexes a write some time after it lands, so a file that holds the word can be left out: an office file, PDF or archive, the end of a large file, or a word Graph splits differently (foo.bar).

Scoping a VFS 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.”