Skip to content
Back to search

onedrive-cli

Command line interface and MCP for OneDrive

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/lionello/onedrive-cli with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/lionello/onedrive-cli'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/lionello--onedrive-cli/badge.svg)](/listings/lionello--onedrive-cli)

HTML

<a href="/listings/lionello--onedrive-cli"><img src="/api/listings/lionello--onedrive-cli/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

With `npm`:

npm install -g @lionello/onedrive-cli

That installs the command as `onedrive`, with `onedrive-cli` as an alias for it.

Or with `nix-env`:

nix-env -if https://github.com/lionello/onedrive-cli/archive/master.tar.gz -A package

Or from source:

git clone https://github.com/lionello/onedrive-cli.git
cd onedrive-cli
npm install
bin/onedrive login

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 222 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # onedrive-cli
  2. Cross-platform command line interface for OneDrive (Personal)
  3. ## Installation
  4. With `npm`:
  5. ```sh
  6. npm install -g @lionello/onedrive-cli
  7. ```
  8. That installs the command as `onedrive`, with `onedrive-cli` as an alias for it.
  9. Or with `nix-env`:
  10. ```sh
  11. nix-env -if https://github.com/lionello/onedrive-cli/archive/master.tar.gz -A package
  12. ```
  13. Or from source:
  14. ```sh
  15. git clone https://github.com/lionello/onedrive-cli.git
  16. cd onedrive-cli
  17. npm install
  18. bin/onedrive login
  19. ```
  20. ## Getting started
  21. Sign in once, then use the drive like a filesystem:
  22. ```sh
  23. onedrive login # opens the Microsoft login page
  24. onedrive df # check the connection and storage usage
  25. onedrive ls # list your drive root
  26. ```
  27. `login` opens your browser, then stores the access token it gets back in
  28. `~/.onedrive-cli-token` (or `$XDG_STATE_HOME` if that is set). Tokens are valid
  29. for one hour, so run `login` again when a command reports that the token
  30. expired. Add `-r` for a read-only token.
  31. ## Usage
  32. `usage: onedrive COMMAND [arguments]`
  33. Run `onedrive help` (or `-h`/`--help`) for this list at any time, and
  34. `onedrive --version` for the installed version. The commands are:
  35. - `album` - list, create, or edit photo albums (`ls`/`create`/`add`/`rm`)
  36. - `cat` - dumps the contents of a file to stdout
  37. - `chmod` - change sharing permissions
  38. - `cp` - copies local file(s) to OneDrive or vice-versa
  39. - `df` - shows OneDrive storage usage stats
  40. - `find` - find file(s) or folder(s) by name, optionally separated by `NUL`
  41. - `grep` - full-text search across the drive, listing matching paths
  42. - `help` - shows list of supported commands
  43. - `ln` - create a link to the remote item
  44. - `login` - request/store an OAuth access token
  45. - `ls` - list the contents of a folder
  46. - `mcp` - run a read-only [MCP](https://modelcontextprotocol.io) server over stdio
  47. - `mkdir` - create a remote folder
  48. - `mv` - move a local file to OneDrive or vice-versa
  49. - `rm` - delete a file or folder from OneDrive
  50. - `sendmail` - send an invitation email for editing to recipients
  51. - `stat` - dump all information for particular file(s)
  52. - `wget` - copy a remote URL to OneDrive (server side)
  53. ## Examples
  54. ##### List the contents of the Public folder
  55. `onedrive ls Public`
  56. ##### Grep one file
  57. `onedrive cat Documents/passwords | grep boa`
  58. ##### Let OneDrive upload a file server side
  59. `onedrive wget http://mega.com/somehugepublicfile Documents/somehugepublicfile`
  60. ##### Upload files recursively
  61. `find * -type f -print0 | xargs -0 -n1 -I{} onedrive cp "./{}" "Shared Favorites/{}"`
  62. ##### Move remote files to a new folder
  63. `onedrive find 'Pictures/Camera Roll' -regex 2015 -type f -print0 | xargs -0 onedrive mv -t :/Pictures/2015/`
  64. ##### Create an album and add photos to it
  65. ```sh
  66. onedrive album create 'Summer 2026'
  67. onedrive album add 'Summer 2026' 'Pictures/Camera Roll/IMG_1234.jpg'
  68. onedrive albums # list all albums
  69. onedrive albums 'Summer 2026' # list the photos in one album
  70. ```
  71. Albums are OneDrive [bundles](https://learn.microsoft.com/onedrive/developer/rest-api/api/drive_list_bundles):
  72. they live outside the folder hierarchy and only reference the files, so
  73. `album rm` removes a photo from the album without deleting the file.
  74. Deleting an album itself is not supported by the API — use the OneDrive
  75. web UI for that.
  76. ## MCP server
  77. `onedrive mcp` starts a read-only [Model Context Protocol](https://modelcontextprotocol.io)
  78. server over stdio, so an MCP client (Claude, etc.) can browse and read your
  79. OneDrive. It reuses the stored access token, so `login` first — ideally with
  80. `login -r` for a read-only token. The server only issues `GET` requests and
  81. cannot modify the drive. It exposes these tools:
  82. - `list_onedrive_folder` - list the direct children of a folder
  83. - `search_onedrive_content` - full-text search across the whole drive
  84. - `find_onedrive_files` - recursively find items by name glob
  85. - `list_onedrive_albums` - list the photo albums, or the items in one album
  86. - `read_onedrive_file` - read a file's contents as text
  87. - `stat_onedrive_item` - return full metadata for an item
  88. - `onedrive_storage` - report storage quota for the available drives
  89. Register it with your MCP client, e.g. in `claude_desktop_config.json`:
  90. ```json
  91. {
  92. "mcpServers": {
  93. "onedrive": {
  94. "command": "onedrive",
  95. "args": ["mcp"]
  96. }
  97. }
  98. }
  99. ```
  100. ## FAQ
  101. ##### Access token was not found; 'login' first.
  102. The `onedrive` utility needs an access token in order to read/write to your OneDrive storage.
  103. Run `onedrive login`: it opens the Microsoft login page, and after you sign in the
  104. [callback page](https://github.com/lionello/onedrive-cli/blob/master/docs/oauthcallbackhandler.html)
  105. hands the token straight back to the waiting command, which saves it to
  106. `~/.onedrive-cli-token`. If the browser runs on another machine (or the handover
  107. fails), the page shows the token so you can paste it at the prompt instead.
  108. Tokens are valid for 1 hour.
  109. ##### "An item with the same name already exists under the parent"
  110. Currently, a copy will fail if a file with the same it already exists.
  111. Change the name of the target, or use other means to delete/rename the existing file in your OneDrive.
  112. ##### Invalid source name
  113. You cannot copy folders. Specify a source file instead, or use wildcards.
  114. ##### Invalid target name
  115. The target file name cannot be determined from the source path. Specify a target file name.
  116. ##### Use ./ or :/ path prefix for local or remote paths.
  117. The `cp` command supports both local->remote as well as remote->local copy.
  118. To make it clear which path is remote and which is local, either use `./` as a prefix for
  119. the local path, or use `:/` as a prefix for the remote path. Either one will suffice.
  120. ##### chmod: Invalid file mode
  121. The `chmod` command currently only supports `-w` or `-rw`. The former tried to downgrade _write_
  122. shares to _read_-only, whereas the latter removes all shares for the given item(s). Octal modes are accepted (for example `644`, `0700`) as well as `og-rw` or `g-w`.
  123. <!-- readme-only:start -->
  124. ## TODO
  125. Tracked on the [issue tracker](https://github.com/lionello/onedrive-cli/issues),
  126. so this stays a pointer rather than a second source of truth:
  127. - [#33](https://github.com/lionello/onedrive-cli/issues/33) — uploads larger than 100 MiB (`createUploadSession`)
  128. - [#36](https://github.com/lionello/onedrive-cli/issues/36) — skip the transfer when the SHA1 already matches
  129. - [#34](https://github.com/lionello/onedrive-cli/issues/34) — `chmod`: granting write access (`+w`)
  130. - [#37](https://github.com/lionello/onedrive-cli/issues/37) — confirm the API honours gzip/deflate on downloads
  131. - [#4](https://github.com/lionello/onedrive-cli/issues/4), [#8](https://github.com/lionello/onedrive-cli/issues/8) — OneDrive for Business, via Microsoft Graph
  132. ## DONE
  133. - Read-only [MCP](https://modelcontextprotocol.io) server (`onedrive mcp`)
  134. - Photo albums via bundles (`onedrive album`)
  135. - Full-text search across the drive (`onedrive grep`)
  136. - Capture the OAuth token over a loopback listener instead of copy-paste
  137. - Delete files and folders (`onedrive rm`)
  138. - Get the sharing link for a file (`onedrive ln`)
  139. - Register with NPM ([@lionello/onedrive-cli](https://www.npmjs.com/package/@lionello/onedrive-cli))
  140. - Fixed OAuth redirect on Safari (https://bugs.webkit.org/show_bug.cgi?id=24175)
  141. - Use XDG path spec for token file (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
  142. - Using `async`/`await`
  143. <!-- readme-only:end -->
  144. ## Development
  145. A [Nix](https://nixos.org) flake provides the package and a dev shell with all
  146. dependencies. Run `nix develop` (or use [Direnv](https://direnv.net)'s `use flake`)
  147. for the shell, and `nix build` / `nix run` to build or run the CLI. The legacy
  148. `shell.nix` still works with `nix-shell`.
  149. ### Update the dependency hash
  150. After changing `package-lock.json`, refresh `npmDepsHash` in `flake.nix`:
  151. ```sh
  152. nix run nixpkgs#prefetch-npm-deps -- package-lock.json
  153. ```
  154. ### Regenerate the website
  155. `docs/index.html` is generated from this README:
  156. ```sh
  157. npm run readme
  158. ```

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.