Agent-callable tools for Microsoft OneDrive, over the Microsoft Graph API v1.0 (https://graph.microsoft.com/v1.0/me/drive/...): browse and search files and folders; upload, download and convert, move, copy, and delete them; and create and manage sharing links and per-person permissions. 20 scripts across drives, files & folders, and sharing & permissions. Every file tool defaults to the caller's own OneDrive and takes an optional driveId to target another drive; read tools resolve the ids the write tools need (itemId, driveId, permissionId, and the copy monitorUrl). Shared content is reached with findItemsByKql (search) or getItemByShareUrl (resolve a pasted link).
Independent, unofficial connector for Microsoft OneDrive. Not affiliated with, endorsed by, or sponsored by Microsoft OneDrive. "Microsoft OneDrive" is a trademark of its owner, used only to identify the service this connector works with.
When to use this
- An agent needs to find or read OneDrive content — check a drive's storage quota, list a folder's contents, search a drive, resolve a shared link, or read a file's metadata (with a short-lived download URL).
- An agent needs to work with files — create folders, upload text or binary files, replace a file's contents, move / rename, copy (async), export to PDF / HTML / JPG, or delete.
- An agent needs to share and manage access — create sharing links, invite named people, and list or revoke permissions.
- An agent needs to reach shared content — search across items shared with the caller via KQL, or turn a pasted OneDrive/SharePoint sharing URL into an actionable item.
Setup
This is an agentskills.io skill.
If the connector has not been installed as a skill yet, install it first with npx skills add zapier/connectors --skill microsoft-onedrive (or your harness's own skill-install mechanism), then continue here. Installing the skill copies these files, not dependencies. Before running the CLI, a local MCP server, or zapier-sdk auth commands, run npm install --omit=dev here once. Importing the published package as a dependency in your own project instead? That npm install already resolves everything — see references/use-as-sdk.md.
Want the actual repo source instead — to browse references/, run this connector's tests, or hack on it? See README.md for a scoped git clone.
The connector runs on Node.js 22.18+. Pick the reference that matches how you're running it, and load it before doing anything else:
| You have... | Load |
|---|---|
An MCP-aware client — tools may already be loaded (e.g. mcp__microsoft-onedrive__<tool>), or you can register a local server yourself (or guide the user to) |
references/use-as-mcp.md |
Terminal / subprocess access (you can run node) |
references/use-as-cli.md |
| Only your own code, importing this package as a dependency | references/use-as-sdk.md |
| No tool access, no terminal, no ability to import this package — you write your own code that calls the Microsoft OneDrive API directly (e.g. a code-execution sandbox) | references/use-as-recipe.md |
Scripts
All scripts use the single connection microsoft-onedrive, except getCopyStatus, which needs no connection (it polls a pre-authenticated monitor URL). Every file/folder tool takes an optional driveId — omit it for the caller's own OneDrive, or pass one from listDrives (or a shared item's remoteItem.parentReference.driveId) to target another drive.
| Script | Script name | Connections | Description |
|---|---|---|---|
scripts/getDrive.ts |
getDrive |
microsoft-onedrive |
Get a drive's metadata and storage quota (own drive by default). |
scripts/listDrives.ts |
listDrives |
microsoft-onedrive |
List the drives available to the user, to resolve a driveId. |
scripts/listFolderItems.ts |
listFolderItems |
microsoft-onedrive |
List the direct children of a folder or the drive root. |
scripts/findFiles.ts |
findFiles |
microsoft-onedrive |
Search files and folders by name/content within one drive. |
scripts/findItemsByKql.ts |
findItemsByKql |
microsoft-onedrive |
Search own + shared items via Microsoft Search (keyword/KQL). |
scripts/getItemByShareUrl.ts |
getItemByShareUrl |
microsoft-onedrive |
Resolve a sharing URL (or share id) to a file or folder. |
scripts/getItem.ts |
getItem |
microsoft-onedrive |
Get a file or folder's metadata (with a download URL) by id. |
scripts/createFolder.ts |
createFolder |
microsoft-onedrive |
Create a folder at the root or inside another folder. |
scripts/uploadTextFile.ts |
uploadTextFile |
microsoft-onedrive |
Create a small text file from string content. |
scripts/uploadFile.ts |
uploadFile |
microsoft-onedrive |
Upload a binary file from a source URL (handles large files). |
scripts/replaceFile.ts |
replaceFile |
microsoft-onedrive |
Replace an existing file's contents from a source URL. |
scripts/moveItem.ts |
moveItem |
microsoft-onedrive |
Move / rename an item within the same drive. |
scripts/copyItem.ts |
copyItem |
microsoft-onedrive |
Copy a file/folder to another folder or drive (async). |
scripts/getCopyStatus.ts |
getCopyStatus |
(none) | Poll the status of an async copy started by copyItem. |
scripts/deleteItem.ts |
deleteItem |
microsoft-onedrive |
Delete a file or folder (moves it to the recycle bin). |
scripts/exportFile.ts |
exportFile |
microsoft-onedrive |
Download a file converted to PDF / HTML / JPG. |
scripts/createSharingLink.ts |
createSharingLink |
microsoft-onedrive |
Create a shareable link (view/edit/embed) to an item. |
scripts/inviteToItem.ts |
inviteToItem |
microsoft-onedrive |
Grant named people read/write access to an item. |
scripts/listItemPermissions.ts |
listItemPermissions |
microsoft-onedrive |
List the permissions on a file or folder. |
scripts/removeItemPermission.ts |
removeItemPermission |
microsoft-onedrive |
Revoke a permission from a file or folder. |
Disambiguation & refusals
Disambiguation before a write. Before writing to a file or folder you looked up by name — from findFiles, findItemsByKql, or listFolderItems — count the exact case-insensitive name matches:
- Exactly one match — act on it. Don't over-ask; a single unambiguous match is the answer.
- Two or more that tie — stop. List the tied candidates with a distinguishing field (
parentReference.path,webUrl,lastModifiedDateTime, orid) and ask which one the user means. Don't pick arbitrarily, and don't write to all of them. File names collide constantly across folders (e.g. tworeport.docx).
Unsupported operations — say so and stop; don't fake it with another tool. This catalog deliberately does not:
- Trigger on new or changed files (new-file / new-or-updated-file polling). Triggers aren't exposed. Don't simulate one by repeatedly listing or searching and reporting a "trigger."
- Move a file across drives (no native cross-drive move).
moveItemis same-drive only. Relocating across drives meanscopyItem→ (getCopyStatus) →deleteItem, which is lossy: the copy gets a new id and URL, and its sharing links and permissions don't carry over. You may perform this when asked to move a file to another drive, but never present it as a plain "move": warn the user it's a copy-then-delete, confirm the copy succeeded viagetCopyStatusbefore deleting the original, and report the new location. Never silently copy-delete and report a completed move. - Enumerate everything shared with the user. This catalog doesn't expose a "list shared with me" tool. Reach shared content via
findItemsByKql(search) orgetItemByShareUrl(resolve a pasted link). - Restore from the recycle bin, read/write Excel workbook ranges, sync a change feed (delta), or manage file versions/thumbnails. These aren't exposed.
deleteItemis recoverable only by a user in the OneDrive UI, not via a follow-up call here.
If asked for any of these, tell the user it's unsupported and stop — don't reach for an unrelated tool to approximate it.
Auth
Every shape passes auth as one connection selector, not the secret — a [<resolver>:]<value> string. Every connector accepts zapier:<connection-id> (Zapier-managed auth — routes through Zapier's auth, retries, and governance layer); some also accept one or more direct-token resolvers (naming and count vary per connector) — check this connector's own resolvers rather than assuming. The <resolver>: prefix is optional; a bare value goes to the first resolver that claims it — a UUID-shaped bare value always claims zapier:. Each script declares the connections it needs and the resolvers each accepts. The exact syntax for passing a connection (and how to see this connector's resolver list) differs by shape — see the reference you loaded above.
Checking what's already configured first? Don't dump environment values to do it — env or env | grep <name> prints the value along with the name, leaking a live credential into the transcript if one is set. Check names only (env | cut -d= -f1 | grep -i <name>) or test a known name directly ([ -n "$VAR_NAME" ]).
No connection yet? Pick one — and follow the reference's own flow to obtain it; never just ask the user for a connection id or token as if they already have one memorized:
| Load | |
|---|---|
| Pass the credential directly | references/use-without-zapier.md |
| Route it through a Zapier connection | references/use-with-zapier.md |
Output format
Every script returns a { data, meta } envelope:
data— the script's result (the shape itsoutputSchemadeclares; see the reference you loaded above for how to inspect a script's exact schema in your shape).meta.outputDataValidation— what validatingdatadid:{ skipped: false, droppedPaths: null }— validated, nothing removed.{ skipped: false, droppedPaths: [...], instruction }— validated, but those paths were stripped fromdata: fields the script returned from the API that theoutputSchemadoesn't declare. If you need them, re-run with output validation skipped.{ skipped: true }— validation was bypassed;datais the raw, unchecked script output.
Reading dropped fields / skipOutputDataValidation. To receive the raw, unvalidated result, opt out of output validation (the exact syntax differs by shape — see the reference you loaded above). Input validation is never skipped.
Trimming the result / filterOutputData. To shrink a large result down to the fields you need, pass a jq expression that post-processes data (again, exact syntax per shape). The jq runs against data only, NOT the { data, meta } envelope, so write it rooted at data (run the script's --help — or your shape's equivalent — to see its output schema). The transformed value replaces data, meta is preserved, and the result is NOT re-validated against the output schema.
References
Load the matching reference file before working in that area:
| Reference | Covers | Load it when |
|---|---|---|
| microsoft-onedrive-api-gotchas.md | Graph OAuth scopes, the error envelope (403/404/409/429), cursor pagination, /me/drive vs /drives/{driveId} addressing, short-lived pre-authenticated download URLs, resumable uploads, async copy, export/convert, per-drive vs KQL search, sharing links/invites/permissions, and shared-content addressing (remoteItem, /shares/{token}). |
A call errors unexpectedly (403/404/429, name conflict), you're resolving a drive or item id, uploading or exporting a file, or working with shared content or permissions. |