mcp-onedrive

v0.10.2
mcp-onedrive Checked 22 hours ago Published 27 days ago

MCP server that lets AI assistants work with OneDrive (web) through a Chrome/Edge extension bridge

An MCP server that lets AI assistants (Claude Code, Claude Desktop, Cursor and others) work with OneDrive on the web in Chrome or Edge. It needs no Azure app registration and no admin consent, because it uses the session of the OneDrive tab you already have open. Works with OneDrive for Business (-my.sharepoint.com), using SharePoint's REST API from inside the tab with the page's own cookies. Personal OneDrive (onedrive.live.com) is not supported yet. Delete, move and share (behind a confirmation window) come later. Paths are relative to your OneDrive root, e.g. Documents/Report.pdf.

Summary extracted from the README.

mcp-onedrive

An MCP server that lets AI assistants (Claude Code, Claude Desktop, Cursor and others) work with OneDrive on the web in Chrome or Edge. It needs no Azure app registration and no admin consent, because it uses the session of the OneDrive tab you already have open.

Built the same way as mcp-newoutlook.

AI client ──stdio(MCP)──► mcp-onedrive server ──ws://127.0.0.1:47392──► browser extension ──► OneDrive tab
                          (saves downloads,        (pairing token,          (runs OneDrive's own
                           reads local files)       extension origin only)    web API in the tab)

Status

Works with OneDrive for Business (<company>-my.sharepoint.com), using SharePoint's REST API from inside the tab with the page's own cookies. Personal OneDrive (onedrive.live.com) is not supported yet. Delete, move and share (behind a confirmation window) come later.

Tools

Paths are relative to your OneDrive root, e.g. Documents/Report.pdf.

Tool What it does
list_folder Files and subfolders of a folder (folders first), with size, modified time and editor. Paged with nextCursor.
find_files Finds files and folders by name (glob or text), folder, extension, size and modified date, sorted by any of them (e.g. the 20 largest files, or everything under Projects changed this week). Answers from a local index; see below.
search_files Full-text search (KQL, e.g. filetype:pdf budget) in your OneDrive, or with scope: "all" also SharePoint sites and files shared with you
read_file Returns a file's contents for the assistant to read, without saving it: the text of Word, Excel (every sheet, rows numbered and columns lettered), PowerPoint (slides and speaker notes), PDF, older Office formats (.doc, .xls, .ppt), RTF, OpenDocument, plain text, CSV, JSON and code, or the picture itself for PNG, JPEG, GIF and WebP. Long text comes in parts (nextOffset). Takes a path in your OneDrive, or a url from search_files for files on SharePoint sites or shared with you.
download_file Saves a file into the download folder (~/Downloads/mcp-onedrive), in 4 MB chunks. Never overwrites a local file. Takes a path, or a url from search_files.
upload_file Uploads a local file into an existing folder, in 4 MB chunks when large. Fails if the name is taken, unless replace: true: then it becomes a new version of that file, and the previous content stays in its version history. A replacement that fails midway leaves the file as it was. You confirm each upload (see Uploads are confirmed).
create_folder Creates a folder (the parent must exist)
get_version Server and extension versions, open OneDrive tabs, and the connection status
api_traffic Diagnostic, off by default: turn on "Record OneDrive API calls" in the extension's popup. Lists the API endpoints the OneDrive tab has called: method, host, API route (site names, file names and ids left out), status, header names and auth scheme. Header and query values are never recorded.

Setup

You need Node.js 20 or later, and Chrome or Edge. In a terminal:

npx mcp-onedrive setup

Setup shows what it will change and asks once. Then it:

  1. Registers the server with your AI apps: Claude Code, Claude Desktop (also the Microsoft Store app), Cursor, VS Code, Windsurf, Gemini CLI and Codex, whichever are installed. It only adds its own mcp-onedrive entry and keeps a copy of each changed file as *.mcp-onedrive.bak. Apps start it with npx -y mcp-onedrive@latest, so updates arrive by themselves.
  2. Sets up automatic pairing: a small helper that Chrome and Edge start only for this extension, to hand it the pairing token. There is no token to copy.
  3. Installs the extension into ~/.mcp-onedrive/extension and opens the Extensions page. There, turn on Developer mode and click Load unpacked with that folder: this is the one manual step, once per browser. Later releases update that folder and reload the extension by themselves.
  4. Checks OneDrive: if the extension doesn't know your OneDrive yet, setup opens it so you can sign in, once.

Then restart your AI app (in Claude Code: /mcp) and ask it about your OneDrive files.

Run setup again at any time; it only changes what is missing. npx mcp-onedrive uninstall removes everything it added (then remove the extension on the Extensions page).

Several AI apps at once: the first one running owns the connection to the browser; the others join it, and take over when it exits. get_version shows role: "hub" or "peer". Chrome and Edge at once work too: calls go to the browser with a OneDrive tab open.

After setup: the extension remembers your OneDrive page. With no OneDrive tab open, the next request opens it in a background tab (or a minimised window when the browser has none) without taking focus. If that tab lands on the sign-in page, the request asks you to sign in there. The toolbar icon is in colour when connected, grey while waiting for an AI app, and shows a red ! when pairing needs attention.

Without setup (another OS user, a locked-down machine): register npx -y mcp-onedrive@latest as a stdio MCP server in your AI app, load the extension/ folder of the package as above, and paste the output of npx mcp-onedrive token into the extension's popup.

How read_file reads files

The file is fetched through the OneDrive tab, like a download, and converted to text on your computer: Word, Excel and PowerPoint files are unpacked directly, and PDFs read with unpdf (pdf.js). Formats without a reader here (.doc, .xls, .ppt, .rtf, OpenDocument, .msg, .eml, .epub) are converted to PDF by SharePoint first. Files up to 100 MB can be read; scanned PDFs have no text to return (download them instead). The last few files read are kept in memory for 15 minutes, so reading a long file part by part fetches it once.

Files on SharePoint sites are reached by the url that search_files returns, through SharePoint's sharing API, with your own permissions. Only URLs on your organisation's SharePoint are accepted.

Compared with Claude's Microsoft 365 connector

Claude's Microsoft 365 connector reaches OneDrive, SharePoint, Outlook and Teams through Microsoft Graph. For files, mcp-onedrive differs in these ways:

Microsoft 365 connector mcp-onedrive
Setup A Microsoft Entra Global Administrator grants tenant consent; Team and Enterprise plans also need a Claude owner No admin, no app registration: uses your signed-in OneDrive tab
Where it runs claude.ai and Claude apps Any MCP client: Claude Code, Claude Desktop, Cursor, VS Code, Codex…
Find by name, folder, size, date Search, which can take minutes to see new files find_files: a local index that sees changes within seconds, with sorting (e.g. the largest files)
Read contents Word, Excel, PowerPoint, PDF, text The same, plus RTF, OpenDocument, code, and images; Excel cells addressable as e.g. C12
Local files No download_file to disk, upload_file from disk
Writes Create and update files, when an administrator enables write actions Upload, replace (as a new version) and create folders
Outlook, Teams Yes No (see mcp-newoutlook)

The file index behind find_files

The first time the extension connects with a OneDrive tab open, the server lists your whole drive in the background through OneDrive's change feed, then fetches only what changed: on each find_files call that is more than 30 seconds after the last one, and every 5 minutes while connected. New, renamed, moved and deleted files show up within seconds, unlike search_files, which can take minutes.

  • Only metadata is kept (name, folder, size, modified time and editor), never file contents. It lives in ~/.mcp-onedrive/index/, readable only by you, one file per account. Delete the folder to rebuild it.
  • A large drive takes a while to list the first time (about 400 items a second). Until then find_files returns what it has so far and says "state": "building". An interrupted listing continues where it stopped.
  • Background syncs never open a OneDrive tab; a find_files call does, like the other tools.
  • With several AI apps, the process that talks to the browser keeps the index and answers the others' queries.

Uploads are confirmed

upload_file sends a file from your computer to OneDrive, so it is the one tool an AI could misuse after reading instructions planted in a document. It is guarded in three layers:

  1. Never uploaded, whatever the settings: hidden files and folders (~/.ssh, ~/.aws, .env, .git, …), ~/Library (except the cloud-drive folders in it) and AppData, mcp-onedrive's own settings (which hold the pairing token), and key, certificate and credentials files (id_rsa, *.pem, *.key, *.p12, *.kdbx, *.ovpn, …). Checked after following symlinks.
  2. You confirm every upload. The AI app shows the file, its size and the OneDrive destination, with Proceed / Cancel (MCP elicitation, supported by Claude Code).
  3. Apps that cannot ask may only upload from uploadRoots, or by default from ~/Documents, ~/Desktop and ~/Downloads.

Browser permissions

The extension needs access to *.sharepoint.com only: it runs OneDrive's own API calls in your signed-in OneDrive tab. The other Microsoft sites the OneDrive app talks to are asked for only when you turn on Diagnostics in the popup, and given back when you turn it off.

Configuration

~/.mcp-onedrive/config.json is created on first run with a fresh pairing token. Each setting can also come from an environment variable.

Key Environment variable Default Meaning
token generated Pairing token. The server and extension prove to each other that they know it; it is never sent over the connection.
port ONEDRIVE_MCP_PORT 47392 Local WebSocket port for the extension
confirmTimeoutMs 300000 (5 min) How long an upload confirmation waits for your answer. 1000 or more; read at startup
chunkTimeoutMs 120000 (2 min) How long one chunk of a download or upload (or a conversion to PDF) may take before it fails. 1000 or more; read at startup
downloadDir ONEDRIVE_MCP_DOWNLOAD_DIR ~/Downloads/mcp-onedrive Where download_file saves files
uploadRoots ONEDRIVE_MCP_UPLOAD_ROOTS (separated by :, or ; on Windows) none Absolute local folders upload_file may read from. Symlinks are followed before checking. When set, files elsewhere are refused even with your confirmation; when not set, apps that cannot ask for confirmation are limited to ~/Documents, ~/Desktop and ~/Downloads.

Example:

{ "token": "…", "uploadRoots": ["/Users/me/Documents/to-onedrive"] }

Development

From a clone: npm install, npm run build, then npm run setup. It registers this copy (node <clone>/dist/index.js) instead of npx. After pulling changes: npm run build, /mcp in Claude Code; the extension folder is updated and reloaded when the server starts.

  • npm test type-checks, then runs the unit tests and an end-to-end test that runs dist/ over stdio with a fake extension.
  • Every pull request and push to main is scanned for committed secrets with gitleaks (.github/workflows/secret-scan.yml); known false positives are allowlisted in .gitleaks.toml. Run the same scan locally with gitleaks git ..
  • Versions are bumped automatically on push to main (.github/workflows/version.yml), from the commits since the last release tag. A BREAKING CHANGE: footer or type!: means major, feat: means minor, anything else means patch.
  • Publishing: the same workflow publishes each new version to npm through trusted publishing (OIDC). No npm token is stored anywhere; npm accepts only that workflow in this repository. (npm adds provenance attestations only for public repositories, so versions published while this repository is private have none.)