Microsoft Graph API MCP Server
A Model Context Protocol (MCP) server that integrates Microsoft Graph API with Claude, enabling management of Microsoft 365 users, licenses, and groups.
Features
User Management: Create new Microsoft 365 users
License Management: Assign licenses to users with optional service plan customization
Group Management: Add users to groups
Query Operations: List available licenses, groups, and search for users
A2A Protocol Support: Agent-to-Agent communication for automated M365 administration
Prerequisites
Microsoft Azure App Registration:
An Azure AD application with the following API permissions:
User.ReadWrite.AllDirectory.ReadWrite.AllGroup.ReadWrite.AllOrganization.Read.All
Admin consent granted for these permissions
A client secret generated
Python 3.10+ and uv package manager
Setup
1. Install uv (if not already installed)
2. Clone and Setup Project
3. Configure Environment Variables
Create a .env file in the project root:
To find these values:
Go to Azure Portal
Navigate to Azure Active Directory → App registrations
Select your app registration
Tenant ID: Found in the Overview page
Client ID: Application (client) ID in the Overview page
Client Secret: Create one in Certificates & secrets
4. Configure Claude Desktop
Add the server configuration to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Important: Replace /absolute/path/to/microsoft-graph-mcp with the actual absolute path to your project directory.
5. Restart Claude Desktop
After saving the configuration, restart Claude Desktop to load the MCP server.
Usage
Once configured, you can use natural language with Claude to manage your Microsoft 365 environment:
Creating Users
Assigning Licenses
Adding Users to Groups
Searching and Listing
Available Tools
The MCP server exposes the following tools to Claude:
create_user: Create a new Microsoft 365 user
assign_license: Assign a license to a user
add_user_to_group: Add a user to a group
list_available_licenses: List all available licenses in the tenant
list_groups: List all groups in the tenant
get_user: Get details for a specific user
search_user: Search for users by name or email
Agent-to-Agent (A2A) Protocol Support
This server supports the Agent-to-Agent (A2A) protocol, enabling automated communication and coordination between AI agents for Microsoft 365 administration tasks.
Agent Card
The agent capabilities and interface are defined in the agent-card.json file at the repository root. This card provides:
Agent Metadata: Name, description, version, and platform information
Protocol Information: MCP version and stdio endpoint configuration
Capability Declaration: Tools, tasks, and streaming support
Skill Definitions: Organized action groups for user, license, and group management
Authentication Requirements: OAuth2 client credentials flow configuration
Available Skills
The agent provides three main skill categories for A2A communication:
1. User Management
create_user: Provision new Microsoft 365 user accounts
get_user: Retrieve user profile information
search_user: Find users by name or email
2. License Management
assign_license: Allocate Microsoft 365 licenses to users
list_available_licenses: Query available license SKUs
3. Group Management
add_user_to_group: Add users to security or distribution groups
list_groups: Enumerate all groups in the tenant
Integration Examples
Agent-to-Agent User Provisioning
Automated Onboarding Workflow
An orchestrator agent can coordinate with this agent to automate employee onboarding:
Create User: Call
create_userskill to provision accountAssign License: Call
assign_licenseskill with appropriate SKUAdd to Groups: Call
add_user_to_groupfor department and project groupsVerify: Call
get_userto confirm account setup
Multi-Agent License Management
A license optimization agent can query available licenses and coordinate assignments:
Authentication for A2A
When integrating with other agents, ensure the following environment variables are configured:
The agent uses OAuth2 client credentials flow with the following required permissions:
User.ReadWrite.AllDirectory.ReadWrite.AllGroup.ReadWrite.AllOrganization.Read.All
Discovery and Registration
Other agents can discover this agent's capabilities by reading the agent-card.json file, which follows the A2A protocol specification. The card includes:
Complete skill definitions with input schemas
Authentication requirements and configuration
Endpoint information for stdio-based MCP communication
Metadata for agent discovery and cataloging
Security Considerations
Never commit the to version control
Store client secrets securely
Use the principle of least privilege when granting API permissions
Regularly rotate client secrets
Monitor API usage through Azure Portal
Consider using Azure Key Vault for production deployments
Troubleshooting
Authentication Errors
If you receive authentication errors:
Verify your credentials in the
.envfileEnsure admin consent is granted for all API permissions
Check that the client secret hasn't expired
Permission Errors
If operations fail with permission errors:
Verify the app has the required API permissions
Ensure admin consent has been granted
Check that the permissions are application permissions, not delegated
MCP Server Not Loading
If Claude Desktop doesn't recognize the server:
Check the config file path is correct
Verify the absolute path to the project directory
Look at Claude Desktop logs for errors
Ensure uv is installed and in your PATH
Development
Running Tests
Code Formatting
Common License SKU IDs
Here are some common Microsoft 365 license SKU IDs:
Microsoft 365 E3:
05e9a617-0261-4cee-bb44-138d3ef5d965Microsoft 365 E5:
06ebc4ee-1bb5-47dd-8120-11324bc54e06Microsoft 365 Business Basic:
3b555118-da6a-4418-894f-7df1e2096870Microsoft 365 Business Standard:
f245ecc8-75af-4f8e-b61f-27d8114de5f3Microsoft 365 Business Premium:
cbdc14ab-d96c-4c30-b9f4-6ada7cdc1d46
Note: SKU IDs may vary by tenant. Use the list_available_licenses tool to see your specific SKU IDs.
API Rate Limits
Microsoft Graph API has rate limits. The server handles basic error responses, but for production use, consider implementing:
Exponential backoff
Request queuing
Rate limit monitoring
License
MIT License - See LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.