Skip to content
Jason's Blog
Go back

Bridging the Gap: Introducing M365 CLI for AI Agents and Power Users

If you’ve ever tried to script or automate Microsoft 365 workflows, you know the drill: register an app in Entra ID, wrestle with MSAL libraries, handle token caching, and eventually write a bunch of boilerplate just to read your own inbox or fetch a file.

It gets even more complicated when you’re building AI Agents (like those powered by OpenClaw). To give an LLM access to your email and calendar, you typically have to write custom tools and API wrappers from scratch.

That’s why I built M365 CLI — a modern, fast, and dependency-light command-line interface for Microsoft 365 personal and corporate accounts.

What is it?

Simply put, M365 CLI is a terminal tool that lets you manage your Mail, Calendar, OneDrive, and SharePoint directly from the command line.

Instead of writing custom API calls, you can now run commands like:

# Read your top 5 unread emails
m365 mail list --top 5

# See what's next on your schedule
m365 cal list --days 3

# Grab a file from OneDrive
m365 od download "Documents/Q1_Report.pdf" ./

Why build another CLI?

There are existing tools out there, but M365 CLI was built with a very specific dual-purpose philosophy: It must be perfect for AI Agents, while remaining a joy for human power users.

🤖 Built for AI Agents

The primary motivation behind this project was to give AI agents a seamless, out-of-the-box way to interact with the M365 ecosystem.

👨‍💻 Built for Power Users

If you spend most of your day in the terminal, switching to a heavy web app just to check your calendar or send a quick email breaks your flow.

How to get started

Getting started is designed to be frictionless. The tool comes with a pre-configured Azure AD application, so you don’t even need to touch the Azure Portal to try it out (though you can configure your own app for production).

# Install globally
npm install -g m365-cli

# Login via Device Code
m365 login

# Start exploring!
m365 mail list
m365 onedrive ls

What’s Next

Right now, M365 CLI successfully covers Mail, Calendar, OneDrive, and SharePoint. The upcoming phases will introduce Contacts management and further optimization.

If you are building AI workflows, running a personal assistant agent, or just hate leaving the terminal, give it a try.

Check out the code, contribute, or drop a star on the repository!


Share this post on:

Next Post
OpenClaw 语音转文字配置指南(Azure OpenAI)