Microsoft 365 & Azure MCP Server
A unified MCP server that enables AI assistants to interact with Microsoft 365 and Azure resources through Azure CLI and Microsoft Graph API, running in a single Docker container.
README
Microsoft 365 & Azure MCP Server
A unified MCP (Model Context Protocol) server that provides access to Microsoft Graph API and Azure CLI through a single Docker container. This server enables AI assistants like Claude, Cursor, and Warp AI to interact with your Microsoft 365 and Azure resources seamlessly.
✨ Features
- Azure CLI Integration: Execute any Azure CLI command to manage Azure resources
- Microsoft Graph API: Full access to Microsoft 365 resources (users, groups, mail, calendars, etc.)
- Multiple Transport Modes: Supports stdio (default), HTTP/SSE, and OpenAPI/REST transport modes
- Flexible Authentication: Interactive device code flow or automated service principal authentication
- Shared App Registration: Use a single app registration for both Azure CLI and Graph API
- Docker Ready: Pre-built container images available on GitHub Container Registry
- Production Ready: Includes health checks, logging, and error handling
🚀 Quick Start
Prerequisites
- Docker installed and running
- Access to Microsoft 365/Azure (for authentication)
⚠️ Important: Docker Image Name
The correct Docker image name is:
ghcr.io/jackinsightsv2/azure-m365-mcp:latest
Common Mistake: The image name matches the repository name format (Azure-M365-MCP), not a reversed version.
- ✅ Correct:
ghcr.io/jackinsightsv2/azure-m365-mcp - ❌ Wrong:
ghcr.io/jackinsightsv2/m365-azure-mcp
The image name is derived from the GitHub repository name (JackInSightsV2/Azure-M365-MCP), which becomes azure-m365-mcp when converted to lowercase for Docker image naming.
Available Tags:
latest- Latest build from the main branchv1.0.1,v1.0.0, etc. - Specific version tags (requires GitHub Release to be published)
Claude Desktop
Add this to your claude_desktop_config.json:
{
"mcpServers": {
"unified-microsoft-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--name",
"unified-microsoft-mcp",
"-e",
"LOG_LEVEL=INFO",
"ghcr.io/jackinsightsv2/azure-m365-mcp:latest"
]
}
}
}
Cursor
Add this to your ~/.cursor/mcp.json:
{
"mcpServers": {
"unified-microsoft-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--name",
"unified-microsoft-mcp",
"-e",
"LOG_LEVEL=INFO",
"ghcr.io/jackinsightsv2/azure-m365-mcp:latest"
],
"env": {}
}
}
}
Warp AI
Add this to your Warp MCP configuration:
{
"unified-microsoft-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--name",
"unified-microsoft-mcp",
"-e",
"LOG_LEVEL=INFO",
"ghcr.io/jackinsightsv2/m365-azure-mcp:latest"
],
"env": {},
"working_directory": null,
"start_on_launch": true
}
}
The Docker container will be automatically downloaded from GitHub Container Registry.
🛠️ Available Tools
execute_azure_cli_command
Execute Azure CLI commands for managing Azure resources. Communicate naturally - ask Claude/Cursor to "list my Azure subscriptions" or "create a resource group called MyRG in East US".
graph_command
Execute Microsoft Graph API commands for managing Microsoft 365 resources. Ask naturally - "show me my profile" or "list all users in my organization".
🔐 Authentication & Security
Both tools support multiple authentication modes:
1. Interactive Authentication (Default - Most Secure)
When you don't provide credentials in the configuration, the server will prompt you to authenticate through your browser when first using each tool. This keeps your credentials out of configuration files.
Note: Interactive authentication works with stdio transport mode. For HTTP/SSE mode, you must provide credentials via environment variables.
2. Automated Authentication (Optional)
For automated scenarios or HTTP/SSE transport mode, you can provide credentials via environment variables.
3. Shared App Registration (Recommended)
You can use a single Azure AD app registration for both Azure CLI and Microsoft Graph API by setting SHARE_APP_REGISTRATION=true. This simplifies configuration and reduces the number of credentials you need to manage.
🔧 Configuration with Credentials
Transport Modes
The server supports three transport modes:
- stdio (default): Standard input/output communication, supports interactive authentication
- sse: HTTP Server-Sent Events mode, requires credentials in environment variables
- openapi: HTTP REST API mode, provides Swagger UI and standard endpoints
To use SSE or OpenAPI mode, set MCP_TRANSPORT=sse or MCP_TRANSPORT=openapi and MCP_PORT=8001 (or your preferred port).
OpenAPI Mode (REST API)
When running in OpenAPI mode (MCP_TRANSPORT=openapi), the server exposes a standard REST API with Swagger documentation.
- Access Documentation: Open
http://localhost:<port>/docs(e.g.,http://localhost:8001/docs) in your browser - Interactive UI: Use the Swagger UI to test tools and commands directly
- REST Endpoints: Interact with tools via standard HTTP POST requests
Basic Configuration (Interactive Auth)
No credentials needed - authentication happens interactively when tools are first used.
Advanced Configuration (Automated Auth)
If you want to avoid interactive authentication prompts or use HTTP/SSE mode, add environment variables to your MCP configuration:
Claude Desktop
{
"mcpServers": {
"unified-microsoft-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--name",
"unified-microsoft-mcp",
"-e",
"AZURE_APP_TENANT_ID=your-tenant-id",
"-e",
"AZURE_APP_CLIENT_ID=your-client-id",
"-e",
"AZURE_APP_CLIENT_SECRET=your-client-secret",
"-e",
"GRAPH_APP_CLIENT_ID=your-graph-client-id",
"-e",
"GRAPH_APP_TENANT_ID=your-graph-tenant-id",
"-e",
"GRAPH_APP_CLIENT_SECRET=your-graph-client-secret",
"-e",
"LOG_LEVEL=INFO",
"ghcr.io/jackinsightsv2/azure-m365-mcp:latest"
]
}
}
}
Cursor
{
"mcpServers": {
"unified-microsoft-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--name",
"unified-microsoft-mcp",
"-e",
"AZURE_APP_TENANT_ID=your-tenant-id",
"-e",
"AZURE_APP_CLIENT_ID=your-client-id",
"-e",
"AZURE_APP_CLIENT_SECRET=your-client-secret",
"-e",
"GRAPH_APP_CLIENT_ID=your-graph-client-id",
"-e",
"GRAPH_APP_TENANT_ID=your-graph-tenant-id",
"-e",
"GRAPH_APP_CLIENT_SECRET=your-graph-client-secret",
"-e",
"LOG_LEVEL=INFO",
"ghcr.io/jackinsightsv2/azure-m365-mcp:latest"
],
"env": {}
}
}
}
Warp AI
{
"unified-microsoft-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--name",
"unified-microsoft-mcp",
"-e",
"AZURE_APP_TENANT_ID=your-tenant-id",
"-e",
"AZURE_APP_CLIENT_ID=your-client-id",
"-e",
"AZURE_APP_CLIENT_SECRET=your-client-secret",
"-e",
"GRAPH_APP_CLIENT_ID=your-graph-client-id",
"-e",
"GRAPH_APP_TENANT_ID=your-graph-tenant-id",
"-e",
"GRAPH_APP_CLIENT_SECRET=your-graph-client-secret",
"-e",
"LOG_LEVEL=INFO",
"ghcr.io/jackinsightsv2/m365-azure-mcp:latest"
],
"env": {},
"working_directory": null,
"start_on_launch": true
}
}
Shared App Registration Configuration
To use a single app registration for both Azure CLI and Graph API:
{
"mcpServers": {
"unified-microsoft-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--name",
"unified-microsoft-mcp",
"-e",
"SHARE_APP_REGISTRATION=true",
"-e",
"AZURE_APP_TENANT_ID=your-tenant-id",
"-e",
"AZURE_APP_CLIENT_ID=your-client-id",
"-e",
"AZURE_APP_CLIENT_SECRET=your-client-secret",
"-e",
"LOG_LEVEL=INFO",
"ghcr.io/jackinsightsv2/azure-m365-mcp:latest"
]
}
}
}
When SHARE_APP_REGISTRATION=true, the Graph API will automatically use the Azure CLI credentials. Ensure your app registration has both Azure RBAC roles and Microsoft Graph API permissions configured.
Environment Variables
General Settings
LOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL). Default: INFOMCP_TRANSPORT: Transport mode ("stdio", "sse", or "openapi"). Default: stdioMCP_PORT: Port for SSE mode. Default: 8001SHARE_APP_REGISTRATION: Use same app registration for Azure CLI and Graph API (true/false). Default: false
Azure CLI
AZURE_APP_TENANT_ID: Your Azure AD tenant IDAZURE_APP_CLIENT_ID: Your service principal client IDAZURE_APP_CLIENT_SECRET: Your service principal client secretAZURE_SUBSCRIPTION_ID: Your Azure subscription ID (optional)COMMAND_TIMEOUT: Timeout for Azure CLI commands in seconds. Default: 300MAX_CONCURRENT_COMMANDS: Maximum concurrent Azure CLI commands. Default: 5
Microsoft Graph
GRAPH_APP_CLIENT_ID: Your app registration client ID (for read/write mode)GRAPH_APP_TENANT_ID: Your app registration tenant ID (for read/write mode)GRAPH_APP_CLIENT_SECRET: Your app registration client secret (for read/write mode)OPERATION_TIMEOUT: Timeout for Graph API operations in seconds. Default: 300MAX_CONCURRENT_OPERATIONS: Maximum concurrent Graph API operations. Default: 5
Alternative variable names (for backward compatibility):
USE_APP_REG_CLIENTID(alternative toGRAPH_APP_CLIENT_ID)TENANTID(alternative toGRAPH_APP_TENANT_ID)CLIENT_SECRET(alternative toGRAPH_APP_CLIENT_SECRET)
🐳 Docker Compose
For local development or production deployment, you can use Docker Compose:
-
Copy
env.exampleto.env:cp env.example .env -
Edit
.envand configure your credentials -
Start the service:
docker-compose up -d -
View logs:
docker-compose logs -f
The docker-compose.yml includes:
- Persistent Azure CLI configuration volume
- Log directory mounting
- Health checks
- Resource limits
- Automatic restart policy
💻 Local Development
Prerequisites
- Python 3.11+
- Azure CLI installed
- Poetry (for dependency management)
Setup
-
Clone the repository:
git clone <repository-url> cd Azure-M365-MCP -
Install dependencies:
poetry install -
Copy environment file:
cp env.example .env -
Configure
.envwith your settings -
Run the server:
poetry run python -m unified_mcp.mainOr use the entry point:
poetry run unified-microsoft-mcp
Building the Docker Image
docker build -t unified-microsoft-mcp:latest .
Pulling Pre-built Images
The pre-built images are available on GitHub Container Registry:
# Pull the latest version
docker pull ghcr.io/jackinsightsv2/azure-m365-mcp:latest
# Pull a specific version (requires GitHub Release to be published)
docker pull ghcr.io/jackinsightsv2/azure-m365-mcp:v1.0.1
Note: The image name format is azure-m365-mcp (matching the repository name Azure-M365-MCP), not m365-azure-mcp.
Running Tests
poetry run pytest
📖 Usage Examples
Azure CLI Examples
# List subscriptions
execute_azure_cli_command(command="az account list")
# List resource groups
execute_azure_cli_command(command="az group list")
# Create a resource group
execute_azure_cli_command(command="az group create --name MyRG --location eastus")
# List virtual machines
execute_azure_cli_command(command="az vm list")
# Get storage accounts
execute_azure_cli_command(command="az storage account list")
Microsoft Graph Examples
# Get current user info
graph_command(command="me")
# List all users
graph_command(command="users")
# Get specific user
graph_command(command="users/user@domain.com")
# List groups
graph_command(command="groups")
# Get user's mail
graph_command(command="me/mailFolders/inbox/messages")
# Create a user (requires client secret)
graph_command(
command="users",
method="POST",
data={
"accountEnabled": true,
"displayName": "John Doe",
"mailNickname": "johndoe",
"userPrincipalName": "johndoe@yourdomain.com",
"passwordProfile": {
"forceChangePasswordNextSignIn": true,
"password": "TempPassword123!"
}
}
)
🔒 Security Best Practices
-
Interactive Authentication (Recommended): Use the default configuration without credentials. The server will securely prompt for authentication when needed, keeping your secrets out of configuration files.
-
Environment Variables: Only add credentials to the configuration if you need fully automated operation or are using HTTP/SSE mode.
-
Shared App Registration: When using
SHARE_APP_REGISTRATION=true, ensure your app registration has the minimum required permissions for both Azure CLI and Graph API operations. -
Client Secrets: You don't need to add secrets to environment variables if using interactive authentication. The server will prompt for them when needed.
-
HTTP/SSE Mode: When using SSE transport mode, credentials are required as interactive authentication is not supported.
🐛 Troubleshooting
Authentication Issues
Problem: "Authentication failed" or "Client secret required"
- Solution: Check that your client ID, tenant ID, and client secret are correct
- Ensure you copied the secret value, not the secret ID
- Verify your app registration has the required permissions
Problem: "Device code timeout"
- Solution: Complete authentication within the time limit (usually 15 minutes)
- For automated scenarios, use service principal authentication instead
Problem: "Permission denied" for Graph API operations
- Solution: Configure appropriate API permissions in Azure Portal
- For read/write operations, ensure your app registration has the necessary delegated or application permissions
- If using shared app registration, ensure the app has both Azure RBAC roles and Graph API permissions
Transport Mode Issues
Problem: Server not responding in SSE mode
- Solution: Ensure
MCP_TRANSPORT=sseandMCP_PORTare set correctly - Check that the port is not already in use
- Verify firewall rules allow connections to the port
Problem: Interactive auth not working in SSE mode
- Solution: SSE mode requires credentials in environment variables. Interactive authentication only works with stdio transport mode.
Configuration Issues
Problem: Graph API using wrong credentials
- Solution: Check
SHARE_APP_REGISTRATIONsetting- If
true, Graph usesAZURE_APP_*credentials - If
false, Graph usesGRAPH_APP_*credentials or falls back to read-only mode
- If
Problem: "Missing required credentials for HTTP mode"
- Solution: HTTP/SSE mode requires credentials. Provide:
- Azure CLI:
AZURE_APP_TENANT_ID,AZURE_APP_CLIENT_ID,AZURE_APP_CLIENT_SECRET - Graph API:
GRAPH_APP_*credentials or enableSHARE_APP_REGISTRATION=true
- Azure CLI:
Docker Issues
Problem: Error response from daemon: manifest unknown when pulling image
- Solution: Verify you're using the correct image name format
- ✅ Correct:
ghcr.io/jackinsightsv2/azure-m365-mcp:latest - ❌ Wrong:
ghcr.io/jackinsightsv2/m365-azure-mcp:latest
- ✅ Correct:
- The image name matches the repository name (
Azure-M365-MCP), converted to lowercase:azure-m365-mcp - For versioned images (e.g.,
v1.0.1), ensure a GitHub Release has been published for that tag
Problem: Container exits immediately
- Solution: Check logs with
docker logs <container-name> - Ensure environment variables are set correctly
- Verify the image was pulled successfully
- Check that
MCP_TRANSPORTis set correctly (stdio,sse, oropenapi) - For
openapimode, verify the transport mode is being recognized in the logs
Problem: Azure CLI commands fail
- Solution: Ensure Azure CLI is authenticated in the container
- For persistent auth, use the mounted volume for Azure CLI config
- Check that the service principal has appropriate Azure RBAC roles
📚 Additional Resources
- Microsoft Graph API Documentation
- Azure CLI Documentation
- Model Context Protocol Specification
- Azure AD App Registration Guide
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
MIT License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。