← Back to directory
C

CLI for Microsoft 365 MCP Server

Community
Manage Microsoft 365 using natural language
GitHub source repository ↗
★ 128 Stars Category · Collaboration Popular Source revision 80131dd80d5a
58FMRS · C
Reliability
8/20
Security and permissions
12/20
Maintenance
12/20
Documentation
14/20
Setup experience
12/20

This MCP server, built by the PnP community, allows natural language management of Microsoft 365. It provides four tools for searching commands, getting docs, executing commands, and getting best practices. It relies on a globally installed CLI for Microsoft 365 and requires prior authentication. The server integrates with several popular MCP clients and provides clear installation instructions.

Read the FMRS scoring method →

This MCP server allows the use of natural language to execute any CLI for Microsoft 365 commands. It may handle complex prompts that will be executed as a chain of CLI for Microsoft 365 commands that will try to fulfill the user's request. Thanks to this, you may manage many different areas of Microsoft 365, for example: Entra ID, OneDrive, OneNote, Outlook, Planner, Power Apps, Power Automate, Power Platform, SharePoint Embedded, SharePoint Online, Teams, Viva Engage, and many more... For best results, use it with Claude Sonnet 4 or Claude Sonnet 3.7.

Tools

m365SearchCommands
Searches CLI for Microsoft 365 commands using fuzzy search based on a query string. This is more efficient than getting all commands as it returns only relevant matches. Use this tool first to find relevant commands.
m365GetCommandDocs
Gets documentation for a specified CLI for Microsoft 365 command to be used by the Model Context Protocol to provide detailed information about the command along with examples, use cases, and option descriptions
m365RunCommand
Runs a specified CLI for Microsoft 365 command to be used by the Model Context Protocol to execute the command and return the result and reason over the response
m365GetBestPractices
Gets best practices for using CLI for Microsoft 365 in scripts, including guidance on authentication checking, error handling, output handling, and configuration

Setup

Prerequisites: Node.js 20.x or higher, and global installation of CLI for Microsoft 365 (npm i -g @pnp/cli-microsoft365). Run 'm365 setup' to initialize, then authenticate using 'm365 login'. Configure CLI: 'm365 cli config set --key prompt --value false', 'm365 cli config set --key output --value text', 'm365 cli config set --key helpMode --value full'. Then add the server to your MCP client with command: npx -y @pnp/cli-microsoft365-mcp-server@latest.

claude_desktop_config.json
{
  "mcpServers": {
    "CLI-Microsoft365": {
      "command": "npx",
      "args": ["-y", "@pnp/cli-microsoft365-mcp-server@latest"]
    }
  }
}

Fit and risk

Best for

  • Developers or admins who want to interact with Microsoft 365 using natural language
  • Scenarios managing SharePoint, Teams, Planner, Power Platform, etc.
  • Users of MCP clients like VS Code, Claude Desktop, Cursor

Not for

  • Users who don't need Microsoft 365 management
  • Environments that cannot install Node.js or CLI for Microsoft 365
  • Users who expect the MCP server to handle authentication itself (it does not)

Required permissions

  • Requires global installation of CLI for Microsoft 365
  • Requires logging in to Microsoft 365 with appropriate permissions
  • Requires local network access to communicate with Microsoft 365 APIs

Risks and side effects

  • Commands executed may make changes; test with caution
  • Erroneous or unexpected prompts could cause unintended changes
  • Dependency on CLI for Microsoft 365 configuration; misconfiguration may lead to incomplete error messages

Troubleshooting

  1. Ensure CLI for Microsoft 365 is correctly installed and configured
  2. Ensure you are logged in (m365 login)
  3. Ensure config settings are correct (prompt, output, helpMode)
  4. If commands fail, check CLI error output and confirm you have sufficient permissions

Use cases

Manage SharePoint Online naturally, e.g., create lists, add columns and items (see example 'awesome ducks').
Create Microsoft Teams teams and add welcome posts to channels.
Manage Power Platform solutions, e.g., disable a Power Automate flow.
Create Planner plans with sample buckets and tasks.

Supported clients

VS CodeFull support
GitHub Copilot CLIFull support
Claude DesktopFull support
CursorFull support