MCP server for Azure Entra PIM — list eligible assignments and activate group/role assignments
Project description
entra-pim-mcp-server
An MCP (Model Context Protocol) server for Azure Entra PIM (Privileged Identity Management). List eligible assignments and activate group or Entra role assignments — all through your MCP-compatible AI client.
Features
- List eligible PIM assignments — view all Group and Entra Role assignments you're eligible for, with their activation status
- Activate PIM assignments — activate group or role assignments by name or ID, with a justification and optional duration
- Automatic browser authentication — opens your browser automatically when login is needed, with persistent token caching
- No secrets required — uses a public client app registration, no client secret necessary
Prerequisites
- Python 3.10 or later (or uv to run without installing Python manually)
- An Azure Entra ID tenant with PIM enabled
- An Entra ID app registration (public client) with the required permissions
Entra ID App Registration
-
Click New registration
-
Set:
- Name: e.g.,
Entra PIM MCP Server - Supported account types: Accounts in this organizational directory only
- Redirect URI: Select Web and add
http://localhost
- Name: e.g.,
-
After creation, go to Authentication:
- Enable Allow public client flows → Yes
-
Go to API permissions and add the following Microsoft Graph delegated permissions:
Permission Description User.ReadSign in and read user profile Group.Read.AllRead all groups PrivilegedAssignmentSchedule.ReadWrite.AzureADGroupRead/write privileged access group assignment schedules PrivilegedEligibilitySchedule.Read.AzureADGroupRead privileged access group eligibility schedules RoleManagementPolicy.Read.AzureADGroupRead group role management policies RoleEligibilitySchedule.Read.DirectoryRead role eligibility schedules RoleAssignmentSchedule.ReadWrite.DirectoryRead/write role assignment schedules RoleManagementPolicy.Read.DirectoryRead role management policies -
Click Grant admin consent (requires admin privileges)
-
Note down the Application (client) ID and your Directory (tenant) ID
Environment Variables
| Variable | Required | Description |
|---|---|---|
AZURE_TENANT_ID |
Yes | Your Azure AD tenant ID |
AZURE_CLIENT_ID |
Yes | The app registration client ID |
Usage
Run directly with uvx
AZURE_TENANT_ID="your-tenant-id" AZURE_CLIENT_ID="your-client-id" uvx --from git+https://github.com/vexxhost/entra-pim-mcp-server entra-pim-mcp-server
Run from source
git clone https://github.com/vexxhost/entra-pim-mcp-server.git
cd entra-pim-mcp-server
uv sync
AZURE_TENANT_ID="..." AZURE_CLIENT_ID="..." uv run entra-pim-mcp-server
MCP Client Configuration
Claude Desktop
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS, %APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"entra-pim": {
"command": "uvx",
"args": ["--from", "git+https://github.com/vexxhost/entra-pim-mcp-server", "entra-pim-mcp-server"],
"env": {
"AZURE_TENANT_ID": "your-tenant-id",
"AZURE_CLIENT_ID": "your-client-id"
}
}
}
}
VS Code / GitHub Copilot
Add to your .vscode/mcp.json:
{
"servers": {
"entra-pim": {
"command": "uvx",
"args": ["--from", "git+https://github.com/vexxhost/entra-pim-mcp-server", "entra-pim-mcp-server"],
"env": {
"AZURE_TENANT_ID": "your-tenant-id",
"AZURE_CLIENT_ID": "your-client-id"
}
}
}
}
Cursor
Add to your Cursor MCP settings (.cursor/mcp.json):
{
"mcpServers": {
"entra-pim": {
"command": "uvx",
"args": ["--from", "git+https://github.com/vexxhost/entra-pim-mcp-server", "entra-pim-mcp-server"],
"env": {
"AZURE_TENANT_ID": "your-tenant-id",
"AZURE_CLIENT_ID": "your-client-id"
}
}
}
}
Authentication
This server uses interactive browser authentication. When you first call any PIM tool:
- Your default browser opens automatically to the Microsoft Entra ID login page
- You sign in and grant consent
- The browser shows "Authentication complete" — you can close the tab
- The token and authentication record are cached locally
On subsequent calls (and server restarts), the cached token is used silently — no re-authentication needed until the token expires.
Available Tools
list_eligible
Lists all eligible PIM assignments (both Group and Entra Role) for the authenticated user.
Returns structured JSON with an assignments array, where each assignment has:
- type —
GrouporEntraRole - name — Group or role display name
- id — Group or role definition ID
- role — Access level (e.g.,
member,owner) or role name - memberType — Membership type (e.g.,
Direct) - status —
Active(currently activated) orEligible(available to activate) - endTime — When the eligibility expires
activate
Activates a PIM assignment for a group or Entra role.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Name of the group or Entra role to activate (case-insensitive) |
justification |
string | Yes | Reason for activation |
duration |
number | No | Duration in hours (defaults to policy maximum) |
access_id |
string | No | Access relationship for groups: member (default) or owner |
directory_scope_id |
string | No | Directory scope for Entra roles (default: /) |
Architecture
┌─────────────┐ stdio ┌──────────────────┐ Graph API ┌──────────────┐
│ MCP Client │ ◄────────────► │ MCP Server │ ──────────────► │ Microsoft │
│ (Claude, │ │ (this project) │ │ Graph API │
│ Cursor, │ │ │ │ │
│ VS Code) │ └──────────────────┘ └──────────────┘
└─────────────┘ │
│ Auto Browser Login
▼
┌──────────────┐
│ Microsoft │
│ Entra ID │
└──────────────┘
- MCP client starts the server as a subprocess (stdio transport)
- When a PIM tool is called and no cached token exists, the browser opens for Entra ID login
- After authentication, the token and auth record are cached locally
- All MCP tool calls use this token for Microsoft Graph PIM operations
- On restart, the cached token is used silently
License
Apache License 2.0 — see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file entra_pim_mcp_server-0.1.0.tar.gz.
File metadata
- Download URL: entra_pim_mcp_server-0.1.0.tar.gz
- Upload date:
- Size: 116.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3201af754d4852ca474ffda1711fdc3cc1393567b012987de5d0cb41bae1e60
|
|
| MD5 |
3a46f62c6a14e7e6ec6f01dc5a9871c2
|
|
| BLAKE2b-256 |
23ada80f4171f3856f227bba4bb6eb59438887d3aa4e6c478b3a9a1bf1ab90c2
|
Provenance
The following attestation bundles were made for entra_pim_mcp_server-0.1.0.tar.gz:
Publisher:
release.yml on vexxhost/entra-pim-mcp-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
entra_pim_mcp_server-0.1.0.tar.gz -
Subject digest:
c3201af754d4852ca474ffda1711fdc3cc1393567b012987de5d0cb41bae1e60 - Sigstore transparency entry: 1085274714
- Sigstore integration time:
-
Permalink:
vexxhost/entra-pim-mcp-server@951a583c94e1ad17cda6da9e5daae3c20a6db130 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vexxhost
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@951a583c94e1ad17cda6da9e5daae3c20a6db130 -
Trigger Event:
push
-
Statement type:
File details
Details for the file entra_pim_mcp_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: entra_pim_mcp_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf9c4fe14daaa1531d54f32e442aba89400ae202f01e0ac0bdb9556a244e382d
|
|
| MD5 |
3acf106f057beb8ff4dded3d32c9c6e3
|
|
| BLAKE2b-256 |
376027601569d9fbe1254d9ba17d771cc9cfb3848882d2afc86431ff5cbbfb38
|
Provenance
The following attestation bundles were made for entra_pim_mcp_server-0.1.0-py3-none-any.whl:
Publisher:
release.yml on vexxhost/entra-pim-mcp-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
entra_pim_mcp_server-0.1.0-py3-none-any.whl -
Subject digest:
bf9c4fe14daaa1531d54f32e442aba89400ae202f01e0ac0bdb9556a244e382d - Sigstore transparency entry: 1085274793
- Sigstore integration time:
-
Permalink:
vexxhost/entra-pim-mcp-server@951a583c94e1ad17cda6da9e5daae3c20a6db130 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vexxhost
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@951a583c94e1ad17cda6da9e5daae3c20a6db130 -
Trigger Event:
push
-
Statement type: