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 app registration required — uses the Microsoft Graph PowerShell well-known client ID, no setup needed
- No secrets required — uses delegated authentication, 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
Environment Variables
| Variable | Required | Description |
|---|---|---|
AZURE_TENANT_ID |
Yes | Your Azure AD tenant ID |
Usage
Codex plugin
This repository includes a Codex plugin marketplace at .agents/plugins/marketplace.json.
The marketplace entry points at the repository root as the entra-pim plugin.
Install it directly from the repository:
codex plugin marketplace add vexxhost/entra-pim-mcp-server --ref main
codex plugin add entra-pim@vexxhost-entra-pim
The plugin forwards AZURE_TENANT_ID from the Codex process environment to the MCP server. For Codex Desktop and the VS Code extension, shell environment variables may not be inherited, so put the tenant ID in ~/.codex/.env and restart Codex:
export AZURE_TENANT_ID=00000000-0000-0000-0000-000000000000
Use your own Entra tenant ID in place of the placeholder. The plugin does not hardcode a tenant ID because tenant selection is deployment-specific.
Run directly with uvx
AZURE_TENANT_ID="your-tenant-id" uvx 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="..." 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": ["entra-pim-mcp-server"],
"env": {
"AZURE_TENANT_ID": "your-tenant-id"
}
}
}
}
VS Code / GitHub Copilot
Add to your .vscode/mcp.json:
{
"servers": {
"entra-pim": {
"command": "uvx",
"args": ["entra-pim-mcp-server"],
"env": {
"AZURE_TENANT_ID": "your-tenant-id"
}
}
}
}
Cursor
Add to your Cursor MCP settings (.cursor/mcp.json):
{
"mcpServers": {
"entra-pim": {
"command": "uvx",
"args": ["entra-pim-mcp-server"],
"env": {
"AZURE_TENANT_ID": "your-tenant-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) |
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.
Metadata
Release files for entra-pim-mcp-server 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| entra_pim_mcp_server-1.0.1.tar.gz | 124.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| entra_pim_mcp_server-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 136.6 kB
Release files / entra_pim_mcp_server-1.0.1.tar.gz
| Download URL | entra_pim_mcp_server-1.0.1.tar.gz |
|---|---|
| Size | 124.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c5fa97dab08e6123d819dee210d8841796631a55b2d95c2aaa5ef6c4257c4ee
|
|
BLAKE2b-256 checksum How to use checksums |
dd08630253a0e896d7215892bd4064f3381ae42a36fbadbf3d7120c677791a23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 7, 2026.
Transparency logRelease files / entra_pim_mcp_server-1.0.1-py3-none-any.whl
| Download URL | entra_pim_mcp_server-1.0.1-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb0fa06ed9736640425cf0d7a4d869969d6a341a0385f51f7e51f20556242f82
|
|
BLAKE2b-256 checksum How to use checksums |
f8434af644b4d19f9809fbcba90d42ac137e17180215c2e5c20b7b2829c023ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 7, 2026.
Transparency log