Enterprise Microsoft 365 MCP Server
Enterprise M365 MCP server for administering Exchange Online, Entra ID, and Microsoft Graph via 66 tools (schema shows core 34).
Automate vacation/OOF auto-replies and forwarding rules.
Audit and convert ex-employee mailboxes to shared.
Inspect mailboxes, permissions, inbox rules, and transport rules.
Send emails and Teams notifications via Graph API.
Search GAL/directory users and audit external contacts.
Audit compliance: signatures, retention, litigation hold, recoverable items.
Trace messages, verify DKIM, and list connectors.
Manage EOP quarantine and tenant allow/block lists.
Manage distribution groups and external delivery settings.
List license SKUs and update user profiles.
Generate daily activity summaries.
README adds SMTP/DNS diagnostics, calendar/OneDrive, adaptive execution, and Meta-MCP tool synthesis.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Enterprise Microsoft 365 MCP Server Set an out-of-office auto-reply for jane@contoso.com starting Monday"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
⚡ Enterprise Microsoft 365 MCP Server
The definitive, production-grade Model Context Protocol (MCP) server for enterprise Microsoft 365, Exchange Online, Microsoft Entra ID, and Microsoft Graph administration.
🌟 Overview
The Enterprise Microsoft 365 MCP Server connects Large Language Models (LLMs) and autonomous AI coding agents (such as Claude Desktop, Cursor, Antigravity IDE, Cline, and GitHub Copilot) directly to enterprise Microsoft 365 tenants with institutional-grade security.
Equipped with 66 specialized tools across 21 operational pillars, it fuses:
Microsoft Graph REST API (v1.0 & Beta) for ultra-fast, modern directory, messaging, calendar, files, and org awareness.
Exchange Online Management v3 REST Engine for deep administrative operations, transport rules, litigation holds, quarantine management, and mail flow forensics.
Adaptive Execution & Reverse Engineering Engine for zero-script execution, dynamic object reflection, and mail loop elimination.
Meta-MCP Dynamic Synthesis Engine for creating and hot-reloading new tools and scaffolding standalone MCP servers on the fly.
SMTP & Messaging Infrastructure Engine for low-level socket diagnostics, real-time SMTP AUTH credential validation, Direct Send testing, and DNS security posture auditing (MX, SPF, DMARC, anti-spoofing).
Related MCP server: OWA Exchange MCP Server
🚀 Key Capabilities
┌─────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ENTERPRISE M365 CAPABILITIES │
├──────────────────────────────┬──────────────────────────────┬───────────────────────────────────┤
│ 📅 Vacation & OOF Automation │ 🛡️ EOP Quarantine & Security │ 👥 Entra ID & User Lifecycle │
│ • Scheduled HTML auto-replies│ • Threat message release │ • Ex-employee shared conversion │
│ • Date-bounded forward rules │ • Tenant Allow/Block Lists │ • Org hierarchy & reporting lines │
│ • Multi-language signatures │ • Phish/Spam remediation │ • Never-expiring service creds │
├──────────────────────────────┼──────────────────────────────┼───────────────────────────────────┤
│ ⚡ SMTP & Relay Engineering │ ⚖️ Compliance & Forensics │ 📁 OneDrive & SharePoint (ODSP) │
│ • Real-time SMTP AUTH test │ • Litigation hold audits │ • File inventory & search │
│ • Direct Send MX verification│ • Recoverable items purge │ • Drive item metadata extraction │
│ • SPF, MX & DMARC DNS health │ • Message trace (24-72h) │ • Corporate document auditing │
├──────────────────────────────┼──────────────────────────────┼───────────────────────────────────┤
│ 📬 Mailbox Deep Governance │ 📆 Calendar & Meetings │ 💬 Teams & Notification Webhooks │
│ • Delegate & SendAs rights │ • Meeting scheduling │ • Adaptive Card alerts │
│ • Shared mailbox automapping │ • Real-time calendar events │ • Daily operations digest bot │
│ • Folder retention & counts │ • Availability inspection │ • Incident dispatch channels │
└──────────────────────────────┴──────────────────────────────┴───────────────────────────────────┘🏛️ Architecture
┌─────────────────────────────────────────┐
│ AI Agents & Coding Assistants │
│ (Claude, Cursor, Antigravity, Cline) │
└────────────────────┬────────────────────┘
│ MCP Protocol (JSON-RPC stdio)
▼
┌─────────────────────────────────────────┐
│ Enterprise M365 MCP Server Core │
│ FastMCP • Pydantic • RBAC │
└───────┬────────────┬────────────┬───────┘
│ │ │
┌────────────────┘ │ └────────────────┐
▼ ▼ ▼
┌────────────────────────┐ ┌───────────────────────────┐ ┌────────────────────────┐
│ Microsoft Graph Engine│ │ Exchange Online Bridge │ │ SMTP & DNS Diagnostics │
│ OAuth2 App Client │ │ EXO v3 REST PowerShell │ │ Sockets • RFC 5321 │
│ • Directory & Org │ │ • Transport Rules │ │ • Port 25 / 587 Check │
│ • Mail, Calendar, ODSP│ │ • Quarantine & Holds │ │ • Real-time SMTP AUTH │
│ • Credential Policies │ │ • Mailbox Protocols │ │ • MX, SPF & DMARC Audit│
└────────────────────────┘ └───────────────────────────┘ └────────────────────────┘⚡ Quickstart
1. Prerequisites
Python 3.10+
An App Registration in Microsoft Entra ID with Graph permissions (e.g.,
Directory.Read.All,Mail.ReadWrite,User.ReadWrite.All)Exchange Online Administrator rights (if utilizing PowerShell Exchange features)
2. Installation
Clone and install dependencies:
git clone https://github.com/ManoAlee/MCP-M365-MICROSOFT.git
cd MCP-M365-MICROSOFT
pip install -r requirements.txt3. Configuration (Zero-Trust Security)
Create a .env file or export environment variables:
export M365_TENANT_ID="00000000-0000-0000-0000-000000000000"
export M365_CLIENT_ID="00000000-0000-0000-0000-000000000000"
export M365_CLIENT_SECRET="your-azure-app-client-secret"
export M365_PRIMARY_ADMIN="admin@yourdomain.com"
export MCP_LOG_LEVEL="INFO"Alternatively, copy config.example.json to config.json (strictly ignored by .gitignore).
🛠️ Tool Catalog (58 Tools)
1. Out of Office / Vacation Automation
Tool | Engine | Description |
| Exchange | Queries scheduled auto-reply status and forward rules. |
| Exchange | Schedules HTML auto-reply and optional date-bounded redirect rules. |
| Exchange | Immediately deactivates out-of-office autoreply and cleans temporary rules. |
2. Lifecycle & Ex-Employee Governance
Tool | Engine | Description |
| Exchange | Audits offboarded user mailboxes, shared status, and forwarding rules. |
| Exchange | Converts user mailbox to Shared Mailbox and sets forwarding target. |
3. Mailbox Operations & Permissions
Tool | Engine | Description |
| Exchange | Deep inspection of mailbox type, protocols (OWA, MAPI, SMTP AUTH), and aliases. |
| Exchange | Lists tenant mailboxes filtered by type ( |
| Exchange | Grants |
4. Transport Rules & Mail Routing
Tool | Engine | Description |
| Exchange | Lists all client-side Inbox Rules configured on a user's mailbox. |
| Exchange | Lists tenant-wide Exchange Transport / Mail Flow rules with priority. |
| Exchange | Removes a specific inbox rule by name or GUID. |
5. Microsoft Graph Email & Teams Notifications
Tool | Engine | Description |
| Graph API | Dispatches emails via Microsoft Graph REST API ( |
| Graph API | Fetches recent messages from Inbox or custom folders with OData query filters. |
| Webhook | Sends high-impact Teams Adaptive Cards to operational webhooks. |
6. Directory, GAL & External Contacts
Tool | Engine | Description |
| Graph API | Searches Global Address List (GAL) users by displayName, email, or department. |
| Exchange | Audits Mail Contacts in the directory against authoritative local registry. |
7. Compliance, Retention & Legal Hold
Tool | Engine | Description |
| Graph API | Audits user profile attributes mapped to corporate signature policies. |
| Exchange | Audits retention policies, hold statuses, and litigation hold flags. |
| Exchange | Identifies all mailboxes currently placed under active Litigation Hold. |
| Exchange | Audits Recoverable Items folder quotas and purge activity. |
8. Mail Flow, Message Trace & DKIM
Tool | Engine | Description |
| Exchange | Runs Exchange Message Trace (24-72h) diagnosing delivery failures and NDRs. |
| Exchange | Validates DKIM signing status, selector records, and key rotation. |
| Exchange | Inspects Inbound and Outbound connectors, TLS validation, and sender IPs. |
9. Exchange Online Protection (EOP) & Quarantine
Tool | Engine | Description |
| Exchange | Queries quarantined messages filtered by reason ( |
| Exchange | Lists tenant allow/block entries for senders, domains, and URLs. |
| Exchange | Adds safe sender or domain to the Tenant Allow List with expiration. |
10. Groups & Distribution Lists
Tool | Engine | Description |
| Exchange | Lists Distribution Groups, Mail-Enabled Security Groups, and M365 Groups. |
| Exchange | Retrieves full member rosters and ownership for any group. |
| Exchange | Adds or removes member UPNs from a Distribution Group. |
| Exchange | Toggles |
11. Licensing & SKU Management
Tool | Engine | Description |
| Graph API | Audits subscribed SKUs, total enabled seats, consumed units, and pool availability. |
12. Profile Sync & Organization Management
Tool | Engine | Description |
| Graph API | Queries full Entra ID profile (department, title, office, phone, manager). |
| Exchange/Entra | Updates corporate directory fields and syncs Exchange Address Book. |
13. Operational Intelligence & Bot
Tool | Engine | Description |
| Graph API | Analyzes recent mailbox traffic and compiles structured operational digests. |
14. Advanced Mailbox Diagnostics & Routing Forensics
Tool | Engine | Description |
| Graph API | Recursively inspects mailbox folder hierarchy with item counts and size. |
| Graph API | Automated forensic diagnosis of message delivery destinations and rules. |
| Graph API | Searches mailbox messages using KQL, subject keywords, or sender criteria. |
15. Calendar & Meeting Management
Tool | Engine | Description |
| Graph API | Retrieves calendar events in a date window with attendee RSVP statuses. |
| Graph API | Creates enterprise meetings with Teams link, attendees, and HTML body. |
16. OneDrive & SharePoint Files (ODSP)
Tool | Engine | Description |
| Graph API | Lists files and folders in a user's OneDrive root or specific subfolder. |
| Graph API | Searches documents across OneDrive and SharePoint drives by keyword. |
17. Organizational Hierarchy & Management Tree
Tool | Engine | Description |
| Graph API | Retrieves a user's direct line manager from the organizational chart. |
| Graph API | Retrieves all direct reports assigned to a supervisor or executive. |
| Graph API | Lists all corporate directory users belonging to a specific department. |
18. SMTP Diagnostics, Authentication, Test Delivery & DNS Health ⚡
Tool | Engine | Description |
| Network/Socket | Tests TCP socket reachability, DNS resolution, and ESMTP EHLO handshake (ports 25, 587, 465) with latency and STARTTLS verification. |
| SMTP Engine | Validates SMTP AUTH credentials in real time with root-cause diagnostic guidance for code 535 (licensing, MFA, basic auth policies). |
| SMTP Engine | Sends end-to-end test emails supporting Direct Send (port 25, unauthenticated) or SMTP AUTH (port 587, authenticated). |
| DNS Engine | Audits domain email DNS health (MX, SPF, DMARC), assesses spoofing risks, and cross-references public WAN IP against authorized SPF entries. |
| Graph API | Queries Microsoft Entra ID via Graph API to determine if a service account has |
| Graph/PowerShell | Sets or revokes |
| Hybrid Engine | Pre-flight audit for SMTP Relay & Direct Send (WAN IP, MX, ports 25/587, Inbound Connectors, and SPF). |
19. Advanced Rules & Email Loop Elimination 🔄
Tool | Engine | Description |
| Exchange Online | Retrieves complete properties, conditions, dates, and exceptions for any mailbox inbox rule. |
| Exchange Online | Updates conditions, actions, and exceptions ( |
20. Adaptive Execution Engine & Object Reverse-Engineering 🔍
Tool | Engine | Description |
| Exchange Online | Dynamically executes any Exchange Online cmdlet or pipeline on-demand with automatic JSON parsing and error recovery (zero scratch scripts). |
| Hybrid Reflection | Reverse-engineers and inspects any M365/Exchange entity (Mailbox, Group, Rule, Contact), resolving members, aliases, protocols, and rules. |
| Graph API | Inspects transport headers ( |
| Graph API | Executes any custom REST request against Microsoft Graph API v1.0 using the MCP authentication token. |
21. Meta-MCP: Tool Synthesis & Server Scaffolding 🧬
Tool | Engine | Description |
| Meta-MCP Synthesizer | Synthesizes, validates, and registers a new tool dynamically in runtime with AST syntax validation, persistence, and JSON schema output. |
| Meta-MCP Generator | Scaffolds the complete architecture for a new standardized MCP Server for other enterprise subsystems (FastMCP, core, tools, tests). |
🧬 Meta-MCP: Self-Evolution & Tool Synthesis
The Enterprise M365 MCP Server includes a Meta-MCP Runtime Layer that empowers AI coding agents with self-evolution and dynamic capability expansion:
┌────────────────────────────────────────────────────────────────────────┐
│ META-MCP SELF-EVOLUTION ENGINE │
├────────────────────────────────────────────────────────────────────────┤
│ │
│ 1. Introspect & Reverse-Engineer │
│ m365_reverse_inspect_object ──► Discovers unknown entity types │
│ │
│ 2. Execute Without Friction (Zero Scripts) │
│ m365_adaptive_exchange_executor ──► Runs cmdlets on-the-fly │
│ m365_adaptive_graph_query ────────► Queries REST endpoints │
│ │
│ 3. Synthesize & Persist Capabilities │
│ m365_create_tool ──► Writes, validates AST, hot-reloads tool │
│ m365_create_server ─► Scaffolds complete new MCP ecosystems │
│ │
└────────────────────────────────────────────────────────────────────────┘Zero-Script Operation: Eliminates the fragile anti-pattern of creating temporary
.ps1or.pyscratch files on the host filesystem.Hot-Reload Tool Creation: Synthesizes and tests new tools in
src/mcp_m365/tools/dynamic/directly via AI conversation.Instant Loop Remediation: Automatically detects routing loops via
m365_inspect_message_routingand patches them surgically withm365_set_inbox_rule.
💻 Client Configuration
Add this server to your preferred MCP environment:
Claude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"m365-governance": {
"command": "python",
"args": ["-m", "mcp_m365.server"],
"cwd": "/path/to/MCP-M365-MICROSOFT",
"env": {
"M365_TENANT_ID": "your-tenant-id",
"M365_CLIENT_ID": "your-client-id",
"M365_CLIENT_SECRET": "your-client-secret",
"M365_PRIMARY_ADMIN": "admin@yourdomain.com"
}
}
}
}Cursor (.cursor/mcp.json)
{
"mcpServers": {
"m365-governance": {
"command": "python",
"args": ["-m", "mcp_m365.server"],
"cwd": "${workspaceFolder}"
}
}
}Antigravity IDE (mcp_config.json)
{
"mcpServers": {
"m365-governance": {
"command": "python.exe",
"args": ["-m", "mcp_m365.server"],
"cwd": "C:\\path\\to\\MCP-M365-MICROSOFT"
}
}
}🔒 Security & Enterprise Governance
This repository adheres to strict Zero-Trust & Zero-Leak security standards:
Zero Hardcoded Secrets: Absolutely no client IDs, secrets, tenant GUIDs, employee PII, or company domain names exist in the codebase. All runtime identity is injected strictly via environment variables.
Robust
.gitignoreGuardrails: Production configuration files (config.json,.env,*.token_cache.bin, logs) are enforced in.gitignore.Least Privilege Principle: Supports granular Azure App Registration permission scopes. Read operations require only
Directory.Read.AllandMail.ReadWrite.Defensive SMTP Testing: Diagnostic test email utilities do not store credentials or bypass transport policies.
🧪 Testing & Validation
The server includes a comprehensive automated test suite verifying tool registration, Pydantic schemas, and Graph/Exchange integrations:
# Run unit tests
python -m unittest discover tests
# Output:
# ..............
# ----------------------------------------------------------------------
# Ran 14 tests in 0.004s
# OK (66 Tools Operational)📄 License
Distributed under the MIT License. See LICENSE for details.
Available Tools
34 toolscompliance_audit_domain_signaturesB
Audits tenant-wide email signatures and legal disclaimers configured via Exchange Transport Rules.
Inputs: no named parameters. Returns: result
compliance_audit_litigation_holdC
Audits mailboxes with Litigation Hold or Retention Hold enabled for legal preservation.
Inputs: identity. Returns: result
compliance_audit_recoverable_itemsC
Audits mailbox Recoverable Items and Deleted Items folder sizes and quotas for compliance and storage hygiene.
Inputs: identity (required). Returns: result
compliance_audit_retention_policiesA
Audits retention policies and MRM tags configured in Exchange Online for compliance/GDPR/LGPD.
Inputs: no named parameters. Returns: result
gal_audit_external_mail_contactsB
Audits external MailContacts in Exchange Online directory, optionally filtered by target domain.
Inputs: domain_filter. Returns: result
gal_search_directory_usersC
Searches directory accounts in Microsoft Entra ID by displayName, UPN, or email address.
Inputs: search_term (required), top. Returns: result
graph_generate_daily_activity_summaryC
Analyzes mailbox messages and generates a categorized summary for daily operational reviews.
Inputs: user_upn (required), top_messages. Returns: result
graph_list_recent_messagesC
Fetches recent emails from a mailbox via Microsoft Graph API.
Inputs: user_upn (required), top. Returns: result
graph_send_emailC
Sends corporate email with HTML formatting via Microsoft Graph API with application permissions.
Inputs: subject (required), from_user (required), html_body (required), to_recipients (required), +1 more. Returns: result
graph_send_teams_notificationC
Sends rich formatted card notifications to Microsoft Teams channels via Incoming Webhooks.
Inputs: title (required), message (required), theme_color, webhook_url. Returns: result
m365_add_sender_to_allow_listC
Adds a sender email or domain to the Tenant Allow List with an expiration period.
Inputs: sender_or_domain (required), note. Returns: result
m365_audit_ex_employeesA
Audits disabled or terminated accounts for NDR 550 5.1.10 risks and license optimization opportunities.
Inputs: no named parameters. Returns: result
m365_check_quarantineC
Checks quarantined messages in Microsoft Defender / EOP by recipient, sender, or hours back.
Inputs: page_size, hours_back, sender_address, recipient_address. Returns: result
m365_configure_vacationC
Configures scheduled out-of-office auto-reply with HTML formatting and optional forwarding/redirection.
Inputs: end_date (required), user_upn (required), start_date (required), return_date (required), +3 more. Returns: result
m365_disable_vacationC
Immediately disables automatic out-of-office replies and clears temporary vacation redirect rules.
Inputs: user_upn (required). Returns: result
m365_get_group_membersC
Retrieves the member list of a distribution group.
Inputs: group_identity (required). Returns: result
m365_get_mailbox_infoC
Retrieves comprehensive mailbox properties (type, protocols, UPN, aliases, forwarding, quotas).
Inputs: identity (required). Returns: result
m365_get_user_profileB
Retrieves a user's corporate profile (department, jobTitle, phone numbers, office, account status).
Inputs: user_upn (required). Returns: result
m365_get_vacation_statusB
Checks the scheduled automatic reply (OOF / Out-of-Office) and vacation forwarding rules for a mailbox.
Inputs: user_upn (required). Returns: result
m365_list_connectorsA
Lists inbound and outbound email connectors configured in Exchange Online.
Inputs: no named parameters. Returns: result
m365_list_distribution_groupsC
Lists distribution groups in Exchange Online with authentication and external delivery settings.
Inputs: result_size. Returns: result
m365_list_inbox_rulesB
Lists all client-side and server-side inbox rules configured on a specific mailbox.
Inputs: user_upn (required). Returns: result
m365_list_license_skusA
Lists all M365 license subscription SKUs showing enabled, consumed, and available seats.
Inputs: no named parameters. Returns: result
m365_list_mailboxesC
Lists mailboxes filtered by type (SharedMailbox, UserMailbox, RoomMailbox).
Inputs: result_size, recipient_type. Returns: result
m365_list_tenant_allow_listB
Lists entries in the Microsoft Defender Tenant Allow/Block List (senders, domains, URLs).
Inputs: no named parameters. Returns: result
m365_list_transport_rulesC
Lists tenant-wide mail flow and transport rules in Exchange Online.
Inputs: filter_state. Returns: result
m365_manage_group_memberC
Adds or removes a user from a distribution group (action: 'add' or 'remove').
Inputs: member_email (required), group_identity (required), action. Returns: result
m365_message_traceC
Traces message delivery events in Exchange Online by sender, recipient, status, and time window.
Inputs: hours_back, result_size, status_filter, sender_address, +1 more. Returns: result
m365_remove_inbox_ruleC
Removes a specific inbox rule from a mailbox by its RuleIdentity or Name.
Inputs: user_upn (required), rule_name (required). Returns: result
m365_set_group_external_deliveryB
Configures whether a distribution group accepts messages from unauthenticated external senders.
Inputs: group_identity (required), allow_external. Returns: result
m365_update_user_profileC
Updates user directory attributes (department, job title, mobile phone, business phone).
Inputs: user_upn (required), job_title, department, mobile_phone, +1 more. Returns: result
m365_verify_dkim_statusB
Verifies DKIM signing status and active key configuration for tenant accepted domains.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 34 tools
Most tools target distinct resources and actions, such as vacation status vs. configure vs. disable, or message trace vs. quarantine checks. However, several audit and directory tools have adjacent purposes (e.g., compliance audits, GAL search vs. user profile lookup, transport rules vs. domain signature audit), so occasional confusion is possible.
Tools generally use snake_case verb_noun phrasing, which is readable and mostly predictable. But the server mixes multiple prefix families (m365_, graph_, gal_, compliance_) and some names are long audit-style descriptions rather than consistent action-oriented patterns.
At 34 tools, the surface is heavy for an MCP server and risks overwhelming tool selection. While Microsoft 365 administration is broad, many tools are narrow audit or configuration variants that could be consolidated or grouped.
The set covers a wide range of Exchange Online, Entra ID, Defender, compliance, and Graph operations, including many read and audit capabilities. However, it lacks several core lifecycle operations such as mailbox/user/group creation and deletion, license assignment, and broader Teams or SharePoint management.
Maintenance
Related MCP Connectors
Manage Microsoft 365 email, calendar, contacts and inbox rules via the Graph API with OAuth 2.0.
Microsoft 365, CRM, Partner Center and tenant operations for organisations and MSPs.
Gmail, Outlook, Drive, OneDrive and calendars for AI agents. Many accounts, one endpoint, audit log.
Protocol-native energy infrastructure orchestration for AI data centers. Provides 46 MCP tools across 8 grid protocols (IEC-61850, DNP3, Modbus, OCPP, OpenADR, IEEE 2030.5, IEC 60870-5-104, ICCP) with 5 core API primitives: connect, dispatch, settle, comply, and intel. Enables AI agents to programmatically interact with substations, grid interfaces, and energy assets for real-time workload-grid coordination.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceConnects AI assistants to Microsoft 365 accounts to manage emails, calendars, files, and Teams messages. It offers 71 tools and supports multi-user environments through a secure, customizable server architecture.55-
- AlicenseAqualityCmaintenanceMCP server for any Microsoft Exchange / OWA deployment. Gives LLM agents access to email, calendar, directory search, folders, availability, and meeting analytics via 30 tools.3033 PyPI13MIT
- FlicenseBqualityDmaintenanceEnables LLMs to manage your Microsoft 365 calendar, tasks, and email via Microsoft Graph API, acting as a personal secretary.14-
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants and automation tools to manage Microsoft 365, Entra ID, and Intune resources through 32 tools for user/device/file management and infrastructure monitoring.8MIT