Skip to main content
Glama

MCP Microsoft Graph Server

by tcpatter

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

  1. Go to Azure PortalMicrosoft Entra IDApp registrationsNew registration
  2. Configure:
    • Name: MCP-MSGraph-Server
    • Account types: Single tenant
    • No redirect URI needed
  3. Note the Application (client) ID and Directory (tenant) ID

2. API Permissions

Add these Application permissions in API permissions:

  • User.Read.All
  • Group.Read.All
  • Directory.Read.All
  • Device.Read.All
  • Application.Read.All

Important: Click "Grant admin consent" after adding permissions.

3. Client Secret

  1. Go to Certificates & secretsNew client secret
  2. Set expiration to 24 months (recommended)
  3. Copy the secret value immediately

4. Azure Storage Setup

Create a storage account for logging:

  1. Create storage account in Azure Portal
  2. Get the connection string from Access keys
  3. Container mcp-logs will be created automatically

Installation

pip install -r requirements.txt

Configuration

  1. Copy .env.example to .env:
cp .env.example .env
  1. Update .env with 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 match
  • operatingSystem eq 'Windows' - Windows devices only
  • createdDateTime 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

  1. "Insufficient privileges"
    • Verify admin consent was granted for API permissions
    • Check that application permissions (not delegated) were added
  2. "Authentication failed"
    • Verify tenant ID, client ID, and client secret
    • Check that client secret hasn't expired
  3. "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.

-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

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.

  1. Features
    1. Prerequisites
      1. Setup
        1. 1. Azure App Registration
        2. 2. API Permissions
        3. 3. Client Secret
        4. 4. Azure Storage Setup
      2. Installation
        1. Configuration
          1. Usage
            1. Running the Server
            2. Available Tools
          2. OData Filtering
            1. Logging
              1. Security Best Practices
                1. Troubleshooting
                  1. Common Issues
                  2. Debugging
                2. License

                  Related MCP Servers

                  • A
                    security
                    A
                    license
                    A
                    quality
                    This server provides a convenient API for interacting with Azure DevOps services, enabling AI assistants and other tools to manage work items, code repositories, boards, sprints, and more. Built with the Model Context Protocol, it provides a standardized interface for communicating with Azure DevOps
                    Last updated -
                    96
                    33
                    43
                    TypeScript
                    MIT License
                  • -
                    security
                    A
                    license
                    -
                    quality
                    Enables management of Azure Cloud PCs using the Microsoft Graph API, allowing users to list available Cloud PCs in their tenant through Claude Desktop.
                    Last updated -
                    Python
                    MIT License
                  • -
                    security
                    -
                    license
                    -
                    quality
                    A Model Context Protocol server that connects to Microsoft Graph API, allowing AI assistants to query and access data from Microsoft Entra ID (formerly Azure Active Directory).
                    Last updated -
                    1
                    Python
                  • A
                    security
                    F
                    license
                    A
                    quality
                    Enables AI systems to analyze documents and extract form data through Azure Form Recognizer/Document Intelligence, supporting various document types including receipts, invoices, and ID documents.
                    Last updated -
                    2
                    668
                    2
                    TypeScript
                    • Apple

                  View all related MCP servers

                  MCP directory API

                  We provide all the information about MCP servers via our MCP API.

                  curl -X GET 'https://glama.ai/api/mcp/v1/servers/tcpatter/mcp-graph-service'

                  If you have feedback or need assistance with the MCP directory API, please join our Discord server