M365 MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add --transport http m365-mcp-server http://localhost:3000/mcp
Required:AZURE_CLIENT_IDAZURE_CLIENT_SECRETAZURE_TENANT_IDSESSION_SECRET+ 2 optional
README.md

Secure, delegated access to Microsoft 365 services for AI models

m365-mcp-server

A production-ready MCP (Model Context Protocol) server for Microsoft 365, providing secure access to Email, SharePoint, and OneDrive through Azure AD/Entra ID authentication with OAuth 2.1 + PKCE.

Features

  • Email Access: List folders, search messages, read email content (including shared mailboxes)
  • Calendar Access: List calendars, browse events, expand recurring events with date ranges
  • SharePoint/OneDrive: Browse sites, drives, folders, and read file content
  • Document Parsing: Extracts readable text from PDF, Word, Excel, PowerPoint, CSV, and HTML files
  • OAuth 2.1 + PKCE: Secure authentication via Azure AD/Entra ID
  • Delegated Permissions: Users access only their authorized content
  • Open WebUI Compatible: Works with native MCP or MCPO proxy
  • Production Ready: Docker support, security hardening, structured audit logging
  • Token Revocation: RFC 7009 compliant token revocation endpoint

Quick Start

1. Azure AD Setup

Follow docs/entra-app-registration.md to create an Azure AD app registration with these permissions:

  • openid, offline_access (OIDC)
  • User.Read, Mail.Read, Mail.Read.Shared, Files.Read, Sites.Read.All, Calendars.Read (Microsoft Graph)

2. Configuration

Create a .env file:

# Azure AD / Entra ID (required)
AZURE_CLIENT_ID=your-client-id
AZURE_CLIENT_SECRET=your-client-secret
AZURE_TENANT_ID=your-tenant-id

# Server
MCP_SERVER_PORT=3000
MCP_SERVER_BASE_URL=http://localhost:3000
SESSION_SECRET=$(openssl rand -hex 32)

# Optional
LOG_LEVEL=info
REDIS_URL=redis://localhost:6379

# OAuth signing keys (required in production)
# OAUTH_SIGNING_KEY_PRIVATE=<base64-encoded PEM>
# OAUTH_SIGNING_KEY_PUBLIC=<base64-encoded PEM>

3. Run Locally

# Install dependencies
npm install

# Development mode
npm run dev

# Production build
npm run build
npm start

4. Authenticate

  1. Open http://localhost:3000/auth/login in a browser
  2. Sign in with your Microsoft 365 account
  3. Note the session ID returned after login

Docker Deployment

Basic

cd docker
docker-compose up -d m365-mcp-server redis

With Open WebUI

cd docker
docker-compose --profile with-webui up -d

With MCPO Proxy

cd docker
docker-compose --profile with-mcpo up -d

Open WebUI Integration

Option A: Native MCP (Recommended)

  1. In Open WebUI, go to Admin Settings > Tools
  2. Add MCP Server:
    {
      "url": "http://localhost:3000/mcp",
      "transport": "streamable-http"
    }
    
  3. Complete OAuth login when prompted

Option B: Via MCPO Proxy

  1. Start MCPO with the provided config:
    mcpo --config docker/mcpo-config.json --port 8000
    
  2. In Open WebUI, add as OpenAPI Tool:
    http://localhost:8000/openapi.json
    

MCP Tools

Email Tools

Tool Description
mail_list_messages List messages with optional filters (supports shared mailboxes)
mail_get_message Get full message details with body (HTML→text), CC/BCC, and attachment metadata
mail_list_folders List mail folders or subfolders (supports shared mailboxes)
mail_get_attachment Read and parse email attachments (PDF, Word, Excel, PowerPoint, CSV, HTML→text). Max 20MB

All email tools accept an optional mailbox parameter (email address or user ID) to access shared mailboxes. Omit to use your personal mailbox. Requires Mail.Read.Shared permission with admin consent.

SharePoint/OneDrive Tools

Tool Description
sp_list_sites Search and list SharePoint sites
sp_list_drives List drives (OneDrive/document libraries)
sp_list_children List folder contents
sp_get_file Get file content with automatic document parsing (PDF, Word, Excel, PowerPoint → text). Max 20MB

OneDrive Tools

Tool Description
od_my_drive Get personal OneDrive info including drive ID and storage quota
od_list_files List files and folders in personal OneDrive (root or subfolder)
od_get_file Get file content by item_id with automatic document parsing (PDF, Word, Excel, PowerPoint). Max 20MB
od_search Search for files in personal OneDrive only
od_recent List recently accessed files
od_shared_with_me List files shared with you by others

Calendar Tools

Tool Description
cal_list_calendars List all calendars with metadata
cal_list_events List events with optional date range (expands recurring events)
cal_get_event Get full event details including body/description

Requires Calendars.Read permission (no admin consent needed). Provide start_date and end_date to expand recurring events into individual occurrences.

API Endpoints

Endpoint Method Description

Tools (17)

mail_list_messagesList messages with optional filters including shared mailboxes
mail_get_messageGet full message details with body and attachment metadata
mail_list_foldersList mail folders or subfolders
mail_get_attachmentRead and parse email attachments
sp_list_sitesSearch and list SharePoint sites
sp_list_drivesList drives for SharePoint sites
sp_list_childrenList folder contents in SharePoint
sp_get_fileGet file content with automatic document parsing
od_my_driveGet personal OneDrive info
od_list_filesList files and folders in personal OneDrive
od_get_fileGet file content by item_id
od_searchSearch for files in personal OneDrive
od_recentList recently accessed files
od_shared_with_meList files shared with you
cal_list_calendarsList all calendars with metadata
cal_list_eventsList events with optional date range
cal_get_eventGet full event details

Environment Variables

AZURE_CLIENT_IDrequiredAzure AD Client ID
AZURE_CLIENT_SECRETrequiredAzure AD Client Secret
AZURE_TENANT_IDrequiredAzure AD Tenant ID
MCP_SERVER_PORTPort for the server
SESSION_SECRETrequiredSecret for session management
REDIS_URLRedis connection string

Configuration

claude_desktop_config.json
{"url": "http://localhost:3000/mcp", "transport": "streamable-http"}

Try it

Find the latest email from my manager regarding the project deadline.
List the files in my 'Project Alpha' OneDrive folder and summarize the content of the latest PDF.
What is on my calendar for tomorrow afternoon?
Search my OneDrive for any documents related to the Q3 budget.

Frequently Asked Questions

What are the key features of M365 MCP Server?

Secure OAuth 2.1 + PKCE authentication via Azure AD. Document parsing for PDF, Word, Excel, PowerPoint, CSV, and HTML. Support for shared mailboxes and SharePoint sites. Structured audit logging and production-ready Docker support.

What can I use M365 MCP Server for?

Automating the summarization of email threads and attachments. Querying SharePoint document libraries for specific project information. Managing calendar events and checking availability via natural language. Extracting data from various Office 365 file formats for analysis.

How do I install M365 MCP Server?

Install M365 MCP Server by running: cd docker && docker-compose up -d m365-mcp-server redis

What MCP clients work with M365 MCP Server?

M365 MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep M365 MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare