npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lionello/onedrive-cli

v1.4.0

Published

OneDrive CLI

Downloads

499

Readme

onedrive-cli

Cross-platform command line interface for OneDrive (Personal)

Development

A Nix flake provides the package and a dev shell with all dependencies. Run nix develop (or use Direnv's use flake) for the shell, and nix build / nix run to build or run the CLI. The legacy shell.nix still works with nix-shell.

Update the dependency hash

After changing package-lock.json, refresh npmDepsHash in flake.nix:

nix run nixpkgs#prefetch-npm-deps -- package-lock.json

Installation

From source:

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

Or use npm:

npm install @lionello/onedrive-cli

Or use nix-env:

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

Usage

usage: onedrive COMMAND [arguments]

This little utility supports the following commands:

  • album - list, create, or edit photo albums (ls/create/add/rm)
  • cat - dumps the contents of a file to stdout
  • chmod - change sharing permissions
  • cp - copies local file(s) to OneDrive or vice-versa
  • df - shows OneDrive storage usage stats
  • find - find file(s) or folder(s) by name, optionally separated by NUL
  • grep - full-text search across the drive, listing matching paths
  • help - shows list of supported commands
  • ln - create a link to the remote item
  • login - request/store an OAuth access token
  • ls - list the contents of a folder
  • mcp - run a read-only MCP server over stdio
  • mkdir - create a remote folder
  • mv - move a local file to OneDrive or vice-versa
  • rm - delete a file from OneDrive (not implemented)
  • sendmail - send an invitation email for editing to recipients
  • stat - dump all information for particular file(s)
  • wget - copy a remote URL to OneDrive (server side)

Examples

List the contents of the Public folder

onedrive ls Public

Grep one file

onedrive cat Documents/passwords | grep boa

Let OneDrive upload a file server side

onedrive wget http://mega.com/somehugepublicfile Documents/somehugepublicfile

Upload files recursively

find * -type f -print0 | xargs -0 -n1 -I{} onedrive cp "./{}" "Shared Favorites/{}"

Move remote files to a new folder

onedrive find 'Pictures/Camera Roll' -regex 2015 -type f -print0 | xargs -0 onedrive mv -t :/Pictures/2015/

Create an album and add photos to it
onedrive album create 'Summer 2026'
onedrive album add 'Summer 2026' 'Pictures/Camera Roll/IMG_1234.jpg'
onedrive albums                # list all albums
onedrive albums 'Summer 2026'  # list the photos in one album

Albums are OneDrive bundles: they live outside the folder hierarchy and only reference the files, so album rm removes a photo from the album without deleting the file. Deleting an album itself is not supported by the API — use the OneDrive web UI for that.

MCP server

onedrive mcp starts a read-only Model Context Protocol server over stdio, so an MCP client (Claude, etc.) can browse and read your OneDrive. It reuses the stored access token, so login first — ideally with login -r for a read-only token. The server only issues GET requests and cannot modify the drive. It exposes these tools:

  • list_onedrive_folder - list the direct children of a folder
  • search_onedrive_content - full-text search across the whole drive
  • find_onedrive_files - recursively find items by name glob
  • list_onedrive_albums - list the photo albums, or the items in one album
  • read_onedrive_file - read a file's contents as text
  • stat_onedrive_item - return full metadata for an item
  • onedrive_storage - report storage quota for the available drives

Register it with your MCP client, e.g. in claude_desktop_config.json:

{
  "mcpServers": {
    "onedrive": {
      "command": "onedrive",
      "args": ["mcp"]
    }
  }
}

FAQ

Access token was not found; 'login' first.

The onedrive utility needs an access token in order to read/write to your OneDrive storage. Use theonedrive login command to get the address of the Microsoft login page. After login, this page will redirect to the file oauthcallbackhandler.html (https://github.com/lionello/onedrive-cli/blob/master/docs/oauthcallbackhandler.html) and extract the access_token from the URL parameters. Copy-paste this token into the command line. This will save the token in a file called ~/.onedrive-cli-token. These tokens have a validity of 1 hour.

"An item with the same name already exists under the parent"

Currently, a copy will fail if a file with the same it already exists. Change the name of the target, or use other means to delete/rename the existing file in your OneDrive.

Invalid source name

You cannot copy folders. Specify a source file instead, or use wildcards.

Invalid target name

The target file name cannot be determined from the source path. Specify a target file name.

Use ./ or :/ path prefix for local or remote paths.

The cp command supports both local->remote as well as remote->local copy. To make it clear which path is remote and which is local, either use ./ as a prefix for the local path, or use :/ as a prefix for the remote path. Either one will suffice.

chmod: Invalid file mode

The chmod command currently only supports -w or -rw. The former tried to downgrade write 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.

TODO

  • Implement rm
  • Support gzip/deflate encoding for downloads
  • Uploads larger than 100MiB are not yet supported (needs range API)
  • Support OneDrive for Business
  • Ability to get the link for a file
  • Skip upload/download if the SHA1 matches
  • Adding write permissions (+w) to existing share links

DONE

  • Register with NPM (@lionello/onedrive-cli)
  • Fixed OAuth redirect on Safari (https://bugs.webkit.org/show_bug.cgi?id=24175)
  • Use XDG path spec for token file (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
  • Using async/await