cli-microsoft365-mcp-server

MCP.Pizza Chef: pnp

Administering Microsoft 365 usually means either clicking through admin centres or memorising a long command-line tool. This lets an assistant drive that tool for you, so you describe the change and it works out the command. It can look up users, sites, and settings across a tenant. Note this is an early-stage project, and you must log in with the underlying tool yourself first, since it does no authentication of its own.

Communication
Data
Other

Use This MCP server To

Look up a user's details in the tenant Check settings across sites Find which sites exist in the tenant Make an admin change by describing it Avoid memorising exact command syntax

README

CLI for Microsoft 365 MCP Server

💡 Description

Currently this is a work in progress and more POC than a solution.

📦 Prerequisites

  • Node.js 20.x or higher

🚀 How to build and run

Before anything first run npm install to install all dependencies.

Then in order to build the project run:

npm run build

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

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

Running MCP using the inspector

One of the ways to test the CLI for Microsoft 365 MCP server is using the MCP Inspector. 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.

inspector

Running MCP in VS Code

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 how ever 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.

{
    "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
            ]
        }
    }
}

Click on start and you should see 358 new tools added to your GitHub Copilot Agent. Test them out. It is recommended to use Claude 3.5 Sonnet as the AI model for the best results.

vs code

🔗 Resources

cli-microsoft365-mcp-server FAQ

Do I need to log in separately?
Yes — you authenticate with the underlying Microsoft 365 command-line tool first, since this does no login of its own.
Which apps does it work with?
It is documented for VS Code.
Is this production ready?
The authors describe it as a work in progress and closer to a proof of concept, so treat it accordingly.
Can I use this to look up users?
Yes — user and site lookups across a tenant are among the things it handles.
How hard is it to set up?
You install the underlying tool globally, log in, then paste a config entry.