entraid-mcp-server is an MCP server that interacts with EntraID through the Microsoft Graph API, using a modular, resource-oriented FastMCP architecture, designed for extensibility, maintainability, and security.
Purpose Used to operate EntraID through the Microsoft Graph API, supporting advanced queries such as users, groups, sign-in logs, MFA status, and privileged users. It can be integrated as an MCP tool into MCP-capable clients such as Claude and Cursor.
Main capabilities
- Modular resource structure: each resource (users, sign-in logs, MFA, etc.) is implemented in an independent module under src/msgraph_mcp_server/resources/, making it easy to extend with new resources (such as groups and devices).
- Centralized Graph client: handles authentication and client initialization, shared by all resource modules.
- User operations: search users by name/email, get a user by ID, list all privileged users (directory role members), get user roles, get user groups (including transitive membership).
- Group lifecycle and membership management: create, read, update, and delete groups; add/remove group members and owners; search and list groups and group members.
- Application and service principal management: list, create, update, and delete applications (app registrations) and service principals; view app role assignments and delegated permissions for applications and service principals.
- Sign-in logs: query a user's sign-in logs for the last X days, and get a user's audit logs.
- MFA: get a user's MFA status, and get the MFA status of all members in a group.
- Password management: directly reset a user's password (custom or automatically generate a secure password), with the option to require a password change at the next sign-in.
- Permissions helper: suggest appropriate Microsoft Graph permissions for common tasks; search and explore available Graph permissions; help implement the principle of least privilege.
- Conditional access and devices (provided in the tool list): get all conditional access policies, get a single policy by ID, get all managed devices (filterable by OS), and get a specific user's managed devices.
- Error handling and logging: provide consistent error handling and progress reporting through the FastMCP context, and provide detailed logs for troubleshooting.
- Security: .env and secret files are excluded from version control; use Microsoft best practices for authentication.
Usage
- Clone the repository.
- Create a config/.env file and fill in the Azure AD credentials: TENANT_ID=your-tenant-id CLIENT_ID=your-client-id CLIENT_SECRET=your-client-secret
- (Optional) If needed, set up certificate-based authentication.
- Testing and development: You can directly use the FastMCP CLI to test and develop the MCP server; this command starts an interactive development environment with MCP Inspector. For more information and advanced usage, see the FastMCP documentation.
- Integration with Claude (Anthropic): Install the server and run it as a Claude MCP tool, replacing /path/to/ with the actual project path; the -f flag points to the .env file.
- Integration with Cursor: Add the configuration in .cursor/mcp.json (do not commit real keys to version control), replacing /path/to/ and the environment variables with actual values.
Main tools (partial)
- search_users(query, ctx, limit=10)
- get_user_by_id(user_id, ctx)
- get_privileged_users(ctx)
- get_user_roles(user_id, ctx)
- get_user_groups(user_id, ctx)
- get_all_groups(ctx, limit=100)
- get_group_by_id(group_id, ctx)
- search_groups_by_name(name, ctx, limit=50)
- get_group_members(group_id, ctx, limit=100)
- create_group(ctx, group_data)
- update_group(group_id, ctx, group_data)
- delete_group(group_id, ctx)
- add_group_member(group_id, member_id, ctx)
- remove_group_member(group_id, member_id, ctx)
- add_group_owner(group_id, owner_id, ctx)
- remove_group_owner(group_id, owner_id, ctx)
- get_user_sign_ins(user_id, ctx, days=7)
- get_user_mfa_status(user_id, ctx)
- get_group_mfa_status(group_id, ctx)
- get_all_managed_devices(filter_os=None)
- get_managed_devices_by_user(user_id)
- get_conditional_access_policies(ctx)
- get_conditional_access_policy_by_id(policy_id, ctx)
- get_user_audit_logs(user_id, days=30)
- reset_user_password_direct(user_id, password=None, require_change_on_next_sign_in=True, generate_password=False, password_length=12)
- suggest_permissions_for_task(task_category, task_name)
- list_permission_categories_and_tasks()
- get_all_graph_permissions()
- search_permissions(search_term, permission_type=None)
- list_applications(ctx, limit=100)
- get_application_by_id(app_id, ctx)
- create_application(ctx, app_data)
- update_application(app_id, ctx, app_data)
- delete_application(app_id, ctx)
- list_service_principals(ctx, limit=100)
- get_service_principal_by_id(sp_id, ctx)
- create_service_principal(ctx, sp_data)
- update_service_principal(sp_id, ctx, sp_data)
- delete_service_principal(sp_id, ctx)
- greeting://{name} — returns a personalized greeting
Group creation/update parameter example group_data is a dictionary and can include: displayName (required on creation), mailNickname (required on creation), description (optional), groupTypes (optional, such as ["Unified"]), mailEnabled (optional), securityEnabled (optional), visibility (optional, "Private" or "Public"), owners (optional, list of user IDs), members (optional, list of IDs), membershipRule (required for dynamic groups), membershipRuleProcessingState (optional, "On" or "Paused"). For more fields and behavior, see the docstring in groups.py.
Application creation/update parameter example app_data is a dictionary and can include: displayName (required on creation), signInAudience (optional), tags (optional), identifierUris (optional), web (optional), api (optional), requiredResourceAccess (optional).
Service principal creation/update parameter example sp_data is a dictionary and can include: appId (required on creation), accountEnabled (optional), tags (optional), appRoleAssignmentRequired (optional), displayName (optional).
Extending the server
- Add new resource modules under resources/ (such as groups.py, devices.py).
- Register new tools in server.py using FastMCP's @mcp.tool() decorator.
- All API calls use the shared GraphClient.
Security and best practices
- Never commit secrets: .env and other sensitive files are already gitignored.
- Least privilege: grant only the necessary Microsoft Graph permissions to the Azure AD application.
- Auditing and monitoring: use log output for troubleshooting and monitoring.
Required Graph API permissions Note: Creating, updating, and deleting groups, and adding/removing group members or owners, requires Group.ReadWrite.All. Read-only queries of groups and memberships can use Group.Read.All and GroupMember.Read.All.
Applicable scenarios Suitable for scenarios where you need to manage EntraID users, groups, applications, service principals, sign-in logs, MFA status, conditional access policies, and other objects via the Microsoft Graph API, and want to invoke them as MCP tools in MCP-capable clients.
Limitations Information such as specific charges, prices, and platform compatibility is not yet available. You need to prepare Azure AD credentials yourself before use.