MCP Microsoft Graph Server
Provides secure access to Microsoft Entra ID (Azure AD) resources including users, devices, and applications through Microsoft Graph API. Enables querying organizational data with comprehensive audit logging to Azure Blob Storage.
README
MCP Microsoft Graph Server
An MCP (Model Context Protocol) server that provides secure access to Microsoft Entra ID (Azure AD) resources via Microsoft Graph API.
Features
- Users: Read user profiles, groups, licenses, and department information
- Devices: Access device inventory with OS and sign-in information
- Applications: Query application registrations and their properties
- Azure Integration: Logs all activities to Azure Blob Storage for audit purposes
- Security: Uses application permissions with client credentials flow
Prerequisites
- Azure tenant with admin access
- Python 3.8+
- Azure Storage account for logging
Setup
1. Azure App Registration
- Go to Azure Portal → Microsoft Entra ID → App registrations → New registration
- Configure:
- Name:
MCP-MSGraph-Server - Account types:
Single tenant - No redirect URI needed
- Name:
- Note the Application (client) ID and Directory (tenant) ID
2. API Permissions
Add these Application permissions in API permissions:
User.Read.AllGroup.Read.AllDirectory.Read.AllDevice.Read.AllApplication.Read.All
Important: Click "Grant admin consent" after adding permissions.
3. Client Secret
- Go to Certificates & secrets → New client secret
- Set expiration to 24 months (recommended)
- Copy the secret value immediately
4. Azure Storage Setup
Create a storage account for logging:
- Create storage account in Azure Portal
- Get the connection string from Access keys
- Container
mcp-logswill be created automatically
Installation
pip install -r requirements.txt
Configuration
- Copy
.env.exampleto.env:
cp .env.example .env
- Update
.envwith your values:
AZURE_TENANT_ID=your-tenant-id-here
AZURE_CLIENT_ID=your-client-id-here
AZURE_CLIENT_SECRET=your-client-secret-here
AZURE_STORAGE_CONNECTION_STRING=your-storage-connection-string-here
AZURE_LOG_CONTAINER_NAME=mcp-logs
Usage
Running the Server
python mcp_msgraph_server.py
Available Tools
1. get_entra_users
Get Microsoft Entra ID users with profile information.
{
"tool": "get_entra_users",
"arguments": {
"filter": "startswith(displayName,'John')",
"fields": ["displayName", "mail", "department"]
}
}
Response includes:
- Display name and email
- Department information
- Group memberships
- Assigned licenses
2. get_entra_devices
Get registered devices in your tenant.
{
"tool": "get_entra_devices",
"arguments": {
"filter": "operatingSystem eq 'Windows'"
}
}
Response includes:
- Device name and OS
- Last sign-in timestamp
- Device ID
3. get_entra_applications
Get application registrations.
{
"tool": "get_entra_applications",
"arguments": {
"filter": "startswith(displayName,'MyApp')"
}
}
Response includes:
- Application name and ID
- Creation date
- Sign-in audience
OData Filtering
All tools support OData filter queries:
startswith(displayName,'John')- Name starts with "John"mail eq 'user@domain.com'- Exact email matchoperatingSystem eq 'Windows'- Windows devices onlycreatedDateTime ge 2024-01-01T00:00:00Z- Created after date
Logging
All API calls and operations are logged to Azure Blob Storage:
- Location:
logs/YYYY/MM/DD/timestamp.json - Format: Structured JSON with timestamp, level, message, and metadata
- Levels: INFO, ERROR
- Includes: Request details, response counts, error information
Security Best Practices
✅ Implemented:
- Application permissions (no user context required)
- Client credentials flow
- Token caching with expiration
- Secure environment variable configuration
- Comprehensive audit logging
- Request timeout protection
🔄 Recommended:
- Rotate client secrets every 24 months
- Monitor blob storage logs regularly
- Use Azure Key Vault for secrets in production
- Implement IP restrictions if needed
- Set up alerting on failed authentication attempts
Troubleshooting
Common Issues
-
"Insufficient privileges"
- Verify admin consent was granted for API permissions
- Check that application permissions (not delegated) were added
-
"Authentication failed"
- Verify tenant ID, client ID, and client secret
- Check that client secret hasn't expired
-
"Blob storage errors"
- Verify storage connection string
- Ensure storage account is accessible
Debugging
Enable verbose logging by checking blob storage logs:
- Authentication attempts
- API request details
- Error messages with context
License
This project follows security best practices for enterprise deployments.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.