msgraphfs

An fsspec filesystem interface to Microsoft Graph drives — SharePoint and OneDrive — for Python.

SDK
PyPI
v0.5
10stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
48/100Fair
Development Activity68
Maintenance56
Community20
Maturity36
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture72
Code Quality74
Innovation75
Learning Curve66

msgraphfs is a Python package that exposes drives behind the Microsoft Graph API (SharePoint document libraries and OneDrive) as an fsspec-compatible filesystem. It registers the msgd://, sharepoint://, and onedrive:// protocols in fsspec’s known-implementations registry, so any fsspec-aware library — pandas, pyarrow, Dask and friends — can read and write files stored in Microsoft 365 as if they were local paths.

Under the hood it authenticates with Authlib against Microsoft Entra (Azure AD) and talks to Graph over HTTP/2 via httpx, translating filesystem operations into Graph drive-item calls. Both single-site and multi-site URL forms are supported, letting you address a specific site and drive through storage options or embed them directly in the URL.

What You Get

  • fsspec protocols msgd://, sharepoint://, and onedrive:// registered for seamless use
  • Single-site and multi-site addressing (site/drive via storage options or in the URL)
  • Standard filesystem operations — open, read, write, ls, rm — over Graph drive items
  • OAuth2 authentication against Microsoft Entra via Authlib and client credentials
  • Drop-in integration with pandas, pyarrow, and other fsspec-aware libraries

Common Use Cases

  • Reading a CSV or Parquet file stored in a SharePoint document library directly into pandas
  • Writing analytics outputs back to a OneDrive or SharePoint folder from a data pipeline
  • Listing and browsing Microsoft 365 drive contents programmatically
  • Moving files between local storage and Microsoft Graph drives in ETL jobs

Under The Hood

Architecture — The package centres on a single MSGDriveFS class in src/msgraphfs/core.py (~2,300 lines) that subclasses fsspec’s AbstractFileSystem. It parses msgd/sharepoint/onedrive URLs, resolves site and drive identifiers through Microsoft Graph, and maps fsspec operations (ls, cat, put, rm, open) onto Graph drive-item REST endpoints. Protocols are registered via the fsspec.specs entry point declared in pyproject.toml, so they load automatically once the package is installed.

Tech Stack — Pure Python (>=3.10) with a lean dependency set: fsspec for the filesystem abstraction, httpx[http2] for HTTP/2 transport, and Authlib for OAuth2 against Microsoft Entra. Packaging uses Hatchling with hatch-vcs for version derivation from git tags.

Code Quality — The repository ships a substantive pytest suite (test_read, test_write, test_oauth2, test_url_parsing, test_fsspec_integration, plus live URL feature tests) with pytest-asyncio and coverage configuration, and a dedicated TESTING.md. Concentrating logic in one large core module keeps behaviour in one place but makes that file the main maintenance surface.

API Design — Developer experience is deliberately minimal: you never call the class directly, you pass a Graph URL and storage_options (client_id, tenant_id, client_secret, optional site/drive) to any fsspec consumer. The README’s pandas read_csv/read_parquet examples show the whole workflow, though users must still register an Entra application and understand SharePoint site/drive naming to get started.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search