The CLI for Microsoft 365 MCP Server allows you to manage Microsoft 365 through natural language commands. This server acts as a bridge between your natural language prompts and CLI for Microsoft 365 commands, enabling you to perform complex Microsoft 365 management tasks across services like SharePoint, Teams, Power Platform, and more without memorizing command syntax.
Before installing the MCP server, ensure you have:
Install the CLI for Microsoft 365 globally using npm:
npm i -g @pnp/cli-microsoft365
Perform the initial setup by running:
m365 setup
For authentication details, see the Microsoft 365 login guide at CLI for Microsoft 365 documentation.
Update the CLI configuration with these commands:
m365 cli config set --key prompt --value false
m365 cli config set --key output --value text
m365 cli config set --key helpMode --value full
These settings ensure the MCP server receives maximum information from CLI for Microsoft 365 when processing commands.
Authenticate using the CLI for Microsoft 365:
m365 login
The MCP server will use this authentication context for all operations.
MCP: Add Server
and select itCommand (stdio)
as the server typenpx -y @pnp/cli-microsoft365-mcp-server@latest
CLI for Microsoft 365 MCP Server
)This will create an .vscode/mcp.json
file with configuration similar to:
{
"servers": {
"CLI for Microsoft 365 MCP Server": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@pnp/cli-microsoft365-mcp-server@latest"
]
}
}
}
For optimal results, use this MCP server with Claude Sonnet 4 or Claude Sonnet 3.7. Here are some example scenarios showing how to use natural language prompts to manage Microsoft 365:
You can create and configure SharePoint lists with a simple prompt:
Add a new list to this site with title "awesome ducks". Then add new columns to that list including them in the default view. The first should be a text description column and the second one should be a user column. Then add 3 items to this list with some funny jokes about ducks added in the description column and adding my user in the user column. Use emojis 🙂
Create and configure Teams with natural language:
Create a new Team on Teams with name "Awesome Ducks" and in the General channel add a welcome post
Control Power Automate flows:
Can you check if I have HoursReportingReminder flow and if so disable it
Set up project management resources:
Can you create a new plan in planner to manage work for the awesome ducks. I need some sample buckets and tasks to get started
The MCP server provides three main tools:
These tools work together to interpret your natural language requests and convert them into the appropriate CLI for Microsoft 365 commands.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "cli-microsoft365-mcp-server" '{"command":"node","args":["dist/index.js"],"env":{"CertificateBase64Encoded":"","CertificatePassword":"","AppId":"","TenantId":"","TenantUrl":""}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cli-microsoft365-mcp-server": {
"command": "node",
"args": [
"dist/index.js"
],
"env": {
"CertificateBase64Encoded": "",
"CertificatePassword": "",
"AppId": "",
"TenantId": "",
"TenantUrl": ""
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"cli-microsoft365-mcp-server": {
"command": "node",
"args": [
"dist/index.js"
],
"env": {
"CertificateBase64Encoded": "",
"CertificatePassword": "",
"AppId": "",
"TenantId": "",
"TenantUrl": ""
}
}
}
}
3. Restart Claude Desktop for the changes to take effect