entraid-mcp-server

eait1200/entraid-mcp-server

3.2

If you are the rightful owner of entraid-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The EntraID MCP Server is an enhanced FastMCP server designed for comprehensive interaction with the Microsoft Graph API, focusing on user lifecycle management and identity operations.

Tools
5
Resources
0
Prompts
0

EntraID MCP Server (Enhanced with User Lifecycle Management)

This project provides a comprehensive, modular FastMCP server for interacting with Microsoft Graph API. It is designed for extensibility, maintainability, and security, supporting advanced queries for users, sign-in logs, MFA status, privileged users, and complete user lifecycle management.

✨ Enhanced Features

šŸ†• Complete User Lifecycle Management

  • Create, update, and delete users
  • Enable/disable user accounts
  • Manage user properties (department, job title, office location, manager, etc.)
  • Set manager relationships
  • Bulk user operations

šŸ“Š Comprehensive Identity Operations

  • Modular Resource Structure: Each resource (users, groups, applications, etc.) is implemented in its own module under src/msgraph_mcp_server/resources/
  • Centralized Graph Client: Handles authentication and client initialization, shared by all resource modules
  • Full Group Lifecycle & Membership Management: Create, read, update, delete groups; manage members and owners
  • Application & Service Principal Management: Complete CRUD operations for app registrations and service principals
  • Sign-in Log Operations: Query and analyze user sign-in patterns
  • MFA Operations: Monitor and assess multi-factor authentication status
  • Password Management: Reset passwords with secure generation options
  • Permissions Helper: Get Microsoft Graph permission recommendations
  • Error Handling & Logging: Consistent error handling and progress reporting via FastMCP context

Project Structure

src/msgraph_mcp_server/
ā”œā”€ā”€ auth/                     # Authentication logic (GraphAuthManager)
ā”œā”€ā”€ resources/                # Resource modules
│   ā”œā”€ā”€ users.py             # ✨ Enhanced: Complete user lifecycle management
│   ā”œā”€ā”€ groups.py            # Group operations and membership management
│   ā”œā”€ā”€ applications.py      # Application (app registration) operations
│   ā”œā”€ā”€ service_principals.py # Service principal operations
│   ā”œā”€ā”€ signin_logs.py       # Sign-in log operations
│   ā”œā”€ā”€ mfa.py              # MFA status operations
│   ā”œā”€ā”€ managed_devices.py   # Device management operations
│   ā”œā”€ā”€ conditional_access.py # Conditional access policy operations
│   ā”œā”€ā”€ audit_logs.py        # Directory audit log operations
│   ā”œā”€ā”€ password_auth.py     # Password authentication methods
│   └── permissions_helper.py # Graph permissions utilities
ā”œā”€ā”€ utils/                   # Core GraphClient and utilities
│   ā”œā”€ā”€ graph_client.py      # Microsoft Graph client wrapper
│   └── password_generator.py # Secure password generation
ā”œā”€ā”€ server.py               # ✨ Enhanced: FastMCP server with new user management tools
└── __init__.py             # Package marker

šŸš€ Getting Started

1. Setup

  1. Clone this enhanced repository
  2. Create a config/.env file with your Azure AD credentials:
    TENANT_ID=your-tenant-id
    CLIENT_ID=your-client-id
    CLIENT_SECRET=your-client-secret
    
  3. Install dependencies: uv sync or pip install -e .

2. Azure AD App Permissions

Required Microsoft Graph API Permissions:

PermissionTypeDescription
AuditLog.Read.AllApplicationRead all audit log data
AuthenticationContext.Read.AllApplicationRead authentication context
DeviceManagementManagedDevices.Read.AllApplicationRead Intune devices
Directory.Read.AllApplicationRead directory data
Group.ReadWrite.AllApplicationFull group management
Policy.Read.AllApplicationRead policies
RoleManagement.Read.DirectoryApplicationRead directory RBAC
UserAuthenticationMethod.Read.AllApplicationRead user auth methods
Application.ReadWrite.AllApplicationManage applications and service principals
šŸ†• User.ReadWrite.AllApplicationComplete user lifecycle management

3. Testing & Development

Test your enhanced MCP server directly using the FastMCP CLI:

fastmcp dev '/path/to/src/msgraph_mcp_server/server.py'

šŸ› ļø Available Tools

šŸ†• Enhanced User Management Tools

  • search_users(query, ctx, limit=10) — Search users by name/email
  • get_user_by_id(user_id, ctx) — Get user details by ID
  • get_privileged_users(ctx) — List all users in privileged directory roles
  • get_user_roles(user_id, ctx) — Get all directory roles assigned to a user
  • get_user_groups(user_id, ctx) — Get all groups for a user
  • šŸ†• update_user(user_id, ctx, user_data) — Update user properties (department, job title, etc.)
  • šŸ†• enable_user(user_id, ctx) — Enable a user account
  • šŸ†• disable_user(user_id, ctx) — Disable a user account
  • šŸ†• create_user(ctx, user_data) — Create a new user
  • šŸ†• delete_user(user_id, ctx) — Delete a user
  • šŸ†• set_user_manager(user_id, manager_id, ctx) — Set a user's manager
  • šŸ†• remove_user_manager(user_id, ctx) — Remove a user's manager

Group Management Tools

  • get_all_groups(ctx, limit=100) — Get all groups
  • get_group_by_id(group_id, ctx) — Get specific group details
  • search_groups_by_name(name, ctx, limit=50) — Search groups by name
  • get_group_members(group_id, ctx, limit=100) — Get group members
  • create_group(ctx, group_data) — Create new groups
  • update_group(group_id, ctx, group_data) — Update existing groups
  • delete_group(group_id, ctx) — Delete groups
  • add_group_member(group_id, member_id, ctx) — Add members to groups
  • remove_group_member(group_id, member_id, ctx) — Remove members from groups

Security & Compliance Tools

  • get_user_sign_ins(user_id, ctx, days=7) — Get sign-in logs
  • get_user_mfa_status(user_id, ctx) — Get MFA status for users
  • get_group_mfa_status(group_id, ctx) — Get MFA status for group members
  • get_conditional_access_policies(ctx) — Get conditional access policies
  • get_user_audit_logs(user_id, days=30) — Get audit logs for users
  • reset_user_password_direct(user_id, password, ctx) — Reset user passwords

Application Management Tools

  • list_applications(ctx, limit=100) — List app registrations
  • get_application_by_id(app_id, ctx) — Get application details
  • create_application(ctx, app_data) — Create applications
  • update_application(app_id, ctx, app_data) — Update applications
  • delete_application(app_id, ctx) — Delete applications

Device Management Tools

  • get_all_managed_devices(ctx, filter_os=None) — Get managed devices
  • get_managed_devices_by_user(user_id, ctx) — Get devices for specific users

šŸŽÆ Usage Examples with Claude

With the enhanced user management capabilities, you can now ask Claude to perform comprehensive HR and IT administration tasks:

User Onboarding:

  • "Create a new user account for Sarah Wilson joining as HR Director in the Seattle office"
  • "Set up accounts for these 5 new hires in the Engineering department"

User Management:

  • "Change John Doe's department to Finance and set Alice Johnson as his manager"
  • "Update all Marketing team members to work from Building B, Floor 3"
  • "Move the entire Sales team to the new Dallas office location"

User Offboarding:

  • "Disable Mike Davis's account and remove his manager assignment"
  • "Show me all disabled users from the last 30 days"
  • "Disable all users in the Marketing department who haven't signed in for 90 days"

Bulk Operations:

  • "Update job titles for all users in the Finance department"
  • "Set usage location to 'US' for all users without a location"
  • "Enable all previously disabled intern accounts"

Organizational Changes:

  • "Show me all users reporting to John Smith and reassign them to Jane Doe"
  • "Find all users in the IT department and update their office location"

šŸ”§ Using with Claude or Cursor

Using with Claude (Anthropic)

fastmcp install '/path/to/src/msgraph_mcp_server/server.py' \\
  --with msgraph-sdk --with azure-identity --with azure-core --with msgraph-core \\
  -f /path/to/.env

Using with Cursor

Add to your .cursor/mcp.json:

{
  "EntraID MCP Server": {
    "command": "uv",
    "args": [
      "run",
      "--with", "azure-core",
      "--with", "azure-identity", 
      "--with", "fastmcp",
      "--with", "msgraph-core",
      "--with", "msgraph-sdk",
      "fastmcp",
      "run",
      "/path/to/src/msgraph_mcp_server/server.py"
    ],
    "env": {
      "TENANT_ID": "<your-tenant-id>",
      "CLIENT_ID": "<your-client-id>",
      "CLIENT_SECRET": "<your-client-secret>"
    }
  }
}

šŸ” Security & Best Practices

  • Never commit secrets: .env files are gitignored
  • Use least privilege: Grant only necessary Microsoft Graph permissions
  • Audit & monitor: All operations are logged in Azure AD audit logs
  • Input validation: All user inputs are validated and sanitized
  • Error handling: Comprehensive error handling with proper user feedback

šŸ“ˆ What's New in This Enhanced Version

āœ… Complete User Lifecycle Management

  • Create users with full profile information
  • Update any user property (department, job title, contact info, etc.)
  • Enable/disable accounts for onboarding/offboarding
  • Manage manager relationships and organizational hierarchy
  • Delete users when necessary

āœ… Enterprise-Ready Operations

  • Bulk user operations for organizational changes
  • Comprehensive error handling and validation
  • Audit trail support for compliance
  • Integration with existing group and role management

āœ… Claude AI Integration

  • Natural language user management through conversational AI
  • Intelligent bulk operations based on criteria
  • Automated workflow suggestions
  • Context-aware user administration

šŸ¤ Contributing

This enhanced version builds on the excellent foundation of the original EntraID MCP Server. Contributions are welcome! Please ensure:

  1. All new features include proper error handling
  2. User management operations are thoroughly tested
  3. Security best practices are followed
  4. Documentation is updated for new capabilities

šŸ“„ License

MIT


⚔ Ready to transform your identity management with AI-powered automation!