Get the FREE Ultimate OpenClaw Setup Guide →

cli-microsoft365

Manage Microsoft 365 using MCP server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio pnp-cli-microsoft365-mcp-server npx -y @pnp/cli-microsoft365-mcp-server@latest

How to use

This MCP server lets you interact with the CLI for Microsoft 365 using natural language prompts. It acts as a bridge that translates your request into a sequence of CLI for Microsoft 365 commands, handling complex prompts and chaining commands as needed to fulfill your intent. The server is capable of managing a wide range of Microsoft 365 areas, including Entra ID, OneDrive, OneNote, Outlook, Planner, Power Apps, Power Automate, Power Platform, SharePoint (Embedded and Online), Teams, Viva Engage, and more. To get started, you first authenticate with the real CLI, since the MCP server will reuse your CLI authentication context when executing commands. Then you can instruct the MCP server in natural language, e.g., “Create a new SharePoint site for the HR team and invite the HR group,” and it will break that down into the necessary CLI commands.

Tools available through this MCP server are the standard CLI for Microsoft 365 commands accessible via the globally installed @pnp/cli-microsoft365 package. You can perform actions such as user management, group and license operations, mailbox and calendar tasks, SharePoint site creation, Power Platform administration, and more. The MCP server will attempt to maximize context from the CLI when there are errors, and will present you with results and next steps to continue your workflow.

How to install

Prerequisites:

  • Node.js 20.x or higher
  • npm (comes with Node.js)
  1. Install the CLI for Microsoft 365 globally

    npm i -g @pnp/cli-microsoft365
    
  2. Authenticate to Microsoft 365 (one-time per environment)

    m365 login
    

    This step creates the authentication context that the MCP server will reuse when executing commands.

  3. Install the MCP server (Node.js) via npx The README recommends running the MCP server with npx and the latest package version:

    npx -y @pnp/cli-microsoft365-mcp-server@latest
    

    This runs the MCP server as a local process or through your MCP client configuration.

  4. Optional: add the MCP server to your MCP client (VS Code, Copilot CLI, Claude, etc.)

    • VS Code: use the provided configuration example in the README
    • Copilot CLI: run the steps described in the Copilot integration section
    • Claude Desktop: follow the .mcpb file or JSON configuration guidance from the README

Additional notes

Tips and notes:

  • The MCP server relies on your existing m365 authentication context. If you sign out or the session expires, you may need to run m365 login again.
  • If commands fail to execute as expected, the MCP server will often present the underlying CLI output; use this to refine prompts or adjust prompt configuration.
  • Recommended CLI behavior tweaks from the guide include setting prompt to false, output to text, and enabling full help mode to provide rich error information when needed: m365 cli config set --key prompt --value false m365 cli config set --key output --value text m365 cli config set --key helpMode --value full
  • Ensure your environment allows CLI tool execution from the MCP host (some restricted environments may block child process execution).
  • This MCP server does not perform authentication itself; you must authenticate with the CLI first and the server will reuse that context for subsequent commands.

Related MCP Servers

Sponsor this space

Reach thousands of developers