Microsoft 365 MCP Server
A Model Context Protocol (MCP) server for interacting with Microsoft 365 and Microsoft Office services through the Graph API using Bearer token authentication.
- Node.js >= 20 (recommended)
- Azure AD App Registration (required)
Before using this server, you must create an Azure AD app registration:
- Go to Azure Portal
- Navigate to Azure Active Directory → App registrations → New registration
- Set application name: "MS365 MCP Server"
- Choose supported account types:
- Single tenant: Only your organization
- Multi-tenant: Any organization
- Personal + Work accounts: Any Microsoft account
- Click Register
- Copy the Application (client) ID from the Overview page
If you plan to use the token generation scripts, configure authentication:
- In your app registration, go to Authentication
- Click + Add a platform → Mobile and desktop applications
- Add redirect URI:
https://login.microsoftonline.com/common/oauth2/nativeclient - Under Advanced settings, set Allow public client flows to Yes
- Click Save
Create a .env file in the project root and set your client ID:
# REQUIRED: Your Azure AD App Registration Client ID
MS365_MCP_CLIENT_ID=your-client-id-here
# OPTIONAL: Tenant ID (defaults to "common")
MS365_MCP_TENANT_ID=commonImportant: The server will fail to start if MS365_MCP_CLIENT_ID is not provided.
- Bearer Token Authentication: Simple authentication using Microsoft Graph access tokens
- Streamable HTTP MCP: Runs as a web server supporting streamable MCP protocol
- Organization Mode: Full Microsoft 365 service integration including Teams, SharePoint, etc.
- Read-only Mode: Support for safe operations
- Tool Filtering: Granular access control for specific tools
This server uses Bearer token authentication. You need to provide a valid Microsoft Graph access token in the Authorization header:
Authorization: Bearer <your-microsoft-graph-access-token>
To obtain an access token, you can use:
- Azure CLI:
az account get-access-token --resource https://graph.microsoft.com/ - Microsoft Graph Explorer: https://developer.microsoft.com/en-us/graph/graph-explorer
- Your own OAuth 2.0 implementation using Microsoft Identity Platform
Email (Outlook)
list-mail-messages, list-mail-folders, list-mail-folder-messages, get-mail-message, send-mail,
delete-mail-message, create-draft-email, move-mail-message
Calendar
list-calendars, list-calendar-events, get-calendar-event, get-calendar-view, create-calendar-event,
update-calendar-event, delete-calendar-event
OneDrive Files
list-drives, get-drive-root-item, list-folder-files, download-onedrive-file-content, upload-file-content,
upload-new-file, delete-onedrive-file
Excel Operations
list-excel-worksheets, get-excel-range, create-excel-chart, format-excel-range, sort-excel-range
OneNote
list-onenote-notebooks, list-onenote-notebook-sections, list-onenote-section-pages, get-onenote-page-content,
create-onenote-page
To Do Tasks
list-todo-task-lists, list-todo-tasks, get-todo-task, create-todo-task, update-todo-task, delete-todo-task
Planner
list-planner-tasks, get-planner-plan, list-plan-tasks, get-planner-task, create-planner-task
Contacts
list-outlook-contacts, get-outlook-contact, create-outlook-contact, update-outlook-contact,
delete-outlook-contact
User Profile
get-current-user
Search
search-query
Teams & Chats
list-chats, get-chat, list-chat-messages, get-chat-message, send-chat-message, list-chat-message-replies,
reply-to-chat-message, list-joined-teams, get-team, list-team-channels, get-team-channel, list-channel-messages,
get-channel-message, send-channel-message, list-team-members
SharePoint Sites
search-sharepoint-sites, get-sharepoint-site, get-sharepoint-site-by-path, list-sharepoint-site-drives,
get-sharepoint-site-drive-by-id, list-sharepoint-site-items, get-sharepoint-site-item, list-sharepoint-site-lists,
get-sharepoint-site-list, list-sharepoint-site-list-items, get-sharepoint-site-list-item,
get-sharepoint-sites-delta
Shared Mailboxes
list-shared-mailbox-messages, list-shared-mailbox-folder-messages, get-shared-mailbox-message,
send-shared-mailbox-mail
User Management
list-users
Organization mode is enabled by default, providing access to all work/school features including Teams, SharePoint, shared mailboxes, and user management tools.
To disable organization mode, you can use:
MS365_MCP_ORG_MODE=false npx @softeria/ms-365-mcp-server --http 3000Organization mode provides access to:
- Teams & Chats
- SharePoint Sites
- Shared Mailboxes
- User Management
- Enhanced search capabilities
Note: Organization features require appropriate Microsoft Graph scopes in your access token.
To access shared mailboxes, you need:
- Organization mode: Shared mailbox tools require
--org-modeflag (work/school accounts only) - Delegated permissions:
Mail.Read.SharedorMail.Send.Sharedscopes - Exchange permissions: The signed-in user must have been granted access to the shared mailbox
- Usage: Use the shared mailbox's email address as the
user-idparameter in the shared mailbox tools
Finding shared mailboxes: Use the list-users tool to discover available users and shared mailboxes in your
organization.
Example: list-shared-mailbox-messages with user-id set to shared-mailbox@company.com
npm installYou can obtain a Microsoft Graph bearer token using several methods:
npm run get-tokennpm run get-token:cli
# OR manually:
az login
az account get-access-token --resource https://graph.microsoft.com/Visit Microsoft Graph Explorer and copy the access token from the request headers.
npm start
# Server will start on http://localhost:3000# Set your bearer token
export BEARER_TOKEN="your-access-token-here"
# Test the MCP server
npm run test:mcpSend JSON-RPC requests to the /mcp endpoint with your bearer token:
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your-token>" \
-d '{
"jsonrpc": "2.0",
"method": "tools/list",
"id": 1
}'tools/list- List all available toolstools/call- Execute a specific toolinitialize- Initialize the MCP session
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "list-mail-messages",
"arguments": {
"top": 10
}
},
"id": 1
}{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "list-calendars",
"arguments": {}
},
"id": 2
}{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "list-drives",
"arguments": {}
},
"id": 3
}Your Microsoft Graph access token needs the following scopes for full functionality:
Core Scopes:
User.Read- Basic profile informationMail.ReadWrite- Email operationsCalendars.ReadWrite- Calendar operationsFiles.ReadWrite- OneDrive operations
Extended Scopes (for organization features):
Sites.ReadWrite.All- SharePoint operationsTeam.ReadBasic.All- Teams operationsDirectory.Read.All- Organization directoryGroup.Read.All- Group operations
# Optional: Customize tenant (default: common)
export MS365_MCP_TENANT_ID="your-tenant-id"
# Optional: Custom client ID (has default)
export MS365_MCP_CLIENT_ID="your-client-id"
# For client credentials flow only
export MS365_MCP_CLIENT_SECRET="your-client-secret"
# Server configuration
export READ_ONLY=true # Enable read-only mode
export ENABLED_TOOLS="excel|mail" # Filter tools with regex# Basic usage
npm start
# Custom port
npm start -- --http 3001
# Read-only mode
npm start -- --read-only
# Verbose logging
npm start -- -v
# Tool filtering
npm start -- --enabled-tools "excel|calendar"Docker Compose
docker-compose down && docker-compose build --no-cache && docker-compose up --detachdocker run -it --rm \
-p 3000:3000 \
--name ms365-mcp-server \
--env-file .env \
mcp-server-m365