Cli Microsoft365 Mcp Server

io.github.pnp由 GitHub 账号 pnp 发布v0.1.22更新于 Oct 27, 2026

MCP server for CLI for Microsoft 365 to manage your tenant using natural language

已验证STDIO仅桌面效率与工作流开发者工具

概览

AI 生成的概览

本地 MCP 服务器,让助手用自然语言搜索、查阅文档并执行 CLI for Microsoft 365 命令来管理 Microsoft 365 租户。

可以做什么
  • 用模糊搜索查找合适的 CLI for Microsoft 365 命令
  • 获取命令文档、示例和选项说明
  • 执行 CLI for Microsoft 365 命令并解读返回结果
  • 获取脚本编写、身份验证检查与错误处理的最佳实践
  • 串联多条命令完成跨 SharePoint、Teams、Entra ID、Planner、Power Platform 等的复杂请求
适用场景
当你希望助手通过 CLI for Microsoft 365 而不是管理门户来管理 Microsoft 365 租户时使用,例如创建 SharePoint 列表、Teams 团队、Planner 计划或停用 Power Automate 流程。
运行要求
通过 npx 以 stdio 在本地运行。需要 Node.js 20 或更高版本,并全局安装 CLI for Microsoft 365,还需按 README 完成 m365 setup 和配置调整。必须自行用 m365 login 登录;服务器本身不做身份验证,只复用该登录上下文。
安装前请注意
命令以你已登录的 Microsoft 365 身份执行,可创建、修改或删除站点、列表、团队、计划和流程等租户资源。服务器自身不做身份验证,因此继承 CLI 会话的全部权限;执行写操作前请先审阅提示内容。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Cli Microsoft365 Mcp Server,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[CLI for Microsoft 365 MCP Server]
CLI for Microsoft 365 MCP Server

[Install in VS Code] [Install in VS Code Insiders]

💡 Description

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.

📦 Prerequisites

  • Node.js 20.x or higher
  • CLI for Microsoft 365 installed globally (npm i -g @pnp/cli-microsoft365)

🚀 Installation & Usage

👉 Check out the CLI for Microsoft 365 MCP Server Guide

👉 Check out the Getting Started recording 🎬

This MCP server uses the globally installed CLI for Microsoft 365 that you need to install globally using npm i -g @pnp/cli-microsoft365.

After you install the CLI for Microsoft 365 perform the initial setup by running the:

m365 setup

For more information, please follow the Log in to Microsoft 365

After you set up the CLI for Microsoft 365, please update its configuration using the following commands:

m365 cli config set --key prompt --value falsem365 cli config set --key output --value textm365 cli config set --key helpMode --value full

This will ensure that the MCP server will get as much information as possible from the CLI for Microsoft 365 when an error occurs or when a command is not executed properly.

The MCP server will not do any authentication for you. You will need to first authenticate using CLI for Microsoft 365 using m365 login command. Once you are authenticated, the MCP server will use the same authentication context when running any tool.

Lastly, install the MCP server on your preferred MCP client, referring to the instructions of the picked MCP host. Below, you may find guidance for VS Code.

Add to VS Code

There are multiple ways to add the MCP server to VS Code. The most common way is to:

  1. Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P on macOS) and type MCP: Add Server.

  2. Select Command (stdio) as the server type.

  3. Enter the command to run the MCP server, which is:

    npx -y @pnp/cli-microsoft365-mcp-server@latest
  4. Name the server (e.g., CLI for Microsoft 365 MCP Server).

As a result, you should have the following configuration in your .vscode/mcp.json file:

json
{    "servers": {        "CLI for Microsoft 365 MCP Server": {            "type": "stdio",            "command": "npx",            "args": [                "-y",                "@pnp/cli-microsoft365-mcp-server@latest"          ]        }    }}

Now when you open the GitHub Copilot chat in VS Code, you should be able to select the CLI for Microsoft 365 MCP Server from the list of available MCP servers and start using it to manage Microsoft 365 using natural language. In the prompt specify that "Using CLI for Microsoft 365, I want you to..." and GitHub Copilot Agent will use the MCP server to execute your request.

Add to GitHub Copilot CLI

If you are using GitHub Copilot CLI, you may add the CLI for Microsoft 365 MCP server to Copilot by doing the following:

  1. First of all start the Copilot CLI by running:
  copilot
  1. Use the copilot mcp command to add the MCP server:
  /mcp add
  1. This will open up the MCP form where you need to fill in the following details:
  • Server name: basically whatever you like, but do not use space bar characters, e.g cli-microsoft365-mcp-server
  • Server type: select Local
  • Command: npx
  • Arguments: "-y", "@pnp/cli-microsoft365-mcp-server@latest" Rest of the fields you may leave with default values.

After that click on Ctrl+S to save the MCP server and q to exit the MCP form. Now you should be able to use the CLI for Microsoft 365 MCP server in GitHub Copilot CLI by specifying it in your prompt, e.g. "Using CLI for Microsoft 365, I want you to...".

Add to Claude

When using Claude Desktop you may add the MCP server by adding it manually to the Claude Desktop configuration.

Manually add to Claude Desktop configuration
  1. In Claude Desktop, open Settings by clicking on the hamburger icon in the top left corner.
  2. Select File > Settings (or press Ctrl + ,)
  3. In the Developer tab, click Edit Config Note: If you don't see the Developer tab, you need to enable it first from Help > Enable Developer Mode.
  4. This opens explorer, edit claude_desktop_config.json in your favorite text editor. Add the following configuration to the file.
json
{  "mcpServers": {    "CLI-Microsoft365": {      "command": "npx",      "args": ["-y", "@pnp/cli-microsoft365-mcp-server@latest"]    }  }}
  1. Exit Claude Desktop and restart it. Every time you make changes to the code or configuration, you need to restart Claude desktop for the changes to take effect.

Note: In Windows, Claude doesn't exit when you close the window, it runs in the background. You can find it in the system tray. Right-click on the icon and select Quit to exit the application completely.

All done! You should now be able to use the CLI-Microsoft365 MCP server in Claude Desktop.

Add to Cursor

When using Cursor you can add the MCP server by doing the following:

  1. From the chat option pick the Agent settings option
  2. Go to Tools & MCP tab and click on New MCP server
  3. Modify the mcp.json configuration as follows:
json
{  "mcpServers": {    "CLI for Microsoft 365 MCP Server": {      "type": "stdio",      "command": "npx",      "args": [        "-y",        "@pnp/cli-microsoft365-mcp-server@latest"      ]    }  }}
  1. Save and enable the 'CLI for Microsoft 365 MCP Server' in the Tools & MCP tab and wait for the tools to load.

📷 Use Cases

The below uses cases are only a few example how you may use this MCP server. It is capable of handling many different tasks, so feel free to experiment with it and basically manage all of Microsoft 365 using natural language.

Also you may check the CLI for Microsoft 365 wiki to find more scenarios how ClI for Microsoft 365 can be used to manage Microsoft 365.

Manage SharePoint Online

In the following example, the MCP server created a SharePoint list with new columns and populated it with a few test items.

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 columns and the second one should be a user column. Then add 3 items to this list with some funny jokes about docs added in the description column and adding my user in the user column. use emojis 🙂"

[Screenshot of Visual Studio Code with GitHub Copilot chat with a prompt to create a new SharePoint list and a web browser presenting the newly created SharePoint list with newly created columns and items]

Manage Microsoft Teams

The following example shows how to create a new Microsoft Teams team and add a welcome post to the General channel.

prompt: "Create a new Team on Teams with name "Awesome Ducks" and in the General channel adda a welcome post"

[Screenshot of Visual Studio Code with GitHub Copilot chat with a prompt to create a new Teams team and add a welcome post to the general channel and a web browser presenting the newly created Teams team with the welcome post]

Manage Power Platform solutions

In the example, the MCP server disables a Power Automate flow.

prompt: "can you check if I have HoursReportingReminder flow and if so disable it"

[Screenshot of Visual Studio Code with GitHub Copilot chat with a prompt to disable a PowerAutomate Flow and a web browser presenting the list of flows with one being disabled from the prompt]

Manage Planner

In the following example, the MCP server creates a new Planner plan with sample buckets and tasks.

prompt: "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"

[Screenshot of Visual Studio Code with GitHub Copilot chat with a prompt to create a new Planner plan and a web browser presenting the newly created plan with sample buckets and tasks]

🛠️ Tools

ToolDescription
m365SearchCommandsSearches 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.
m365GetCommandDocsGets 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
m365RunCommandRuns 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
m365GetBestPracticesGets best practices for using CLI for Microsoft 365 in scripts, including guidance on authentication checking, error handling, output handling, and configuration

🎓 Skills

This repo includes custom GitHub Copilot skills that teach the AI how to use CLI for Microsoft 365 effectively. Skills are automatically loaded by GitHub Copilot when relevant tasks are detected.

SkillDescription
cli-microsoft365Guides Copilot on running m365 commands directly in the terminal. Covers command syntax, authentication methods, output formatting, JMESPath filtering, and common patterns for managing SharePoint Online, Entra ID, Teams, Power Platform, and more. Use when asking Copilot to run CLI for Microsoft 365 commands interactively.
cli-microsoft365-scriptGuides Copilot on writing PowerShell scripts that automate Microsoft 365 management using m365 commands. Covers script setup, structured error handling with the Invoke-CLICommand helper, CI/CD authentication, batch operations, CSV processing, and security best practices. Use when asking Copilot to create automation scripts.

🏗️ How to build and run it locally

Before anything, first run npm install to install all dependencies.

Then, in order to build the project run:

npm run build

Running MCP in VS Code from local build

It is also possible to run the MCP server in VS Code from your local build so that it may be used by GitHub Copilot Agent. First, start the CLI for Microsoft 365 MCP server using the command:

npm run start

Now go to VS Code GitHub Copilot Agent mode click on the tools icon, and select Add more tools. Then select Add MCP server and then Command (stdio) and enter the following command:

node FULL_PATH_TO_YOUR_PROJECT/dist/index.js

Click Enter and name it however you like. It is recommended to add it to workspace scope for testing. After that, open up your .vscode/mcp.json file and modify it so pass the environment variables needed for auth.

json
{    "servers": {        "m365-mcp-server": {            "type": "stdio",            "command": "node",            "args": [                "FULL_PATH_TO_YOUR_PROJECT/dist/index.js" // e.g. C:/workspace/repo/microsoft-365-mcp-server/dist/index.js            ]        }    }}

Running MCP from local build using the inspector (Debugging)

One of the ways to test the CLI for Microsoft 365 MCP server is by using the MCP Inspector. Mostly, this setup is used for debugging purposes and to test the MCP server locally. First, start the MCP server using the command:

npm run start

Now, in order to run the inspector for your MCP server, you need run the following command in the repo root folder location:

npx @modelcontextprotocol/inspector node dist/index.js

After that, wait for the inspector to start and open the inspector in your browser. You should see the MCP server running, and you should be able to query the tools and execute them locally.

🔗 Resources

来源:README.md,提交 6d89707

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.22最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分