PIM Me
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@PIM Me Activate my quick roles for debugging production issue"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PIM Me
Azure PIM role activation library and MCP server. Activate roles programmatically or through natural language with your AI assistant. Save your frequently-used roles as favorites and activate them all with a single command.
Quick Start
Prerequisites
Node.js 18+
Azure CLI installed and logged in (
az login)Azure account with PIM-eligible roles
As an MCP Server
Add to your MCP client:
VS Code (.vscode/mcp.json):
{
"servers": {
"pim-me": {
"command": "npx",
"args": ["-y", "pim-me-mcp"]
}
}
}Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"pim-me": {
"command": "npx",
"args": ["-y", "pim-me-mcp"]
}
}
}As a Library
npm install pim-me-mcpimport {
listEligibleRoles,
listActiveRoles,
activateRoles,
activateQuickRoles
} from 'pim-me-mcp';
// List all roles you can activate
const eligible = await listEligibleRoles();
console.log(eligible.roles);
// Check what's currently elevated
const active = await listActiveRoles();
active.roles.forEach(role => {
console.log(`${role.roleName} expires at ${role.endDateTime}`);
});
// Activate specific roles
const result = await activateRoles(
[{ name: 'Contributor', scope: 'my-subscription' }],
'Development work',
8 // hours
);
// Or activate your saved favorites
const quickResult = await activateQuickRoles('Development work');Related MCP server: cloudscope-mcp
MCP Server Usage
Setting Up Quick Roles
The easiest way to use this tool is to set up your frequently-used roles once:
Ask: "Show me my PIM roles" or "Help me set up my quick roles"
Pick roles from the numbered list: "Save roles 20, 21, 22 as my quick roles"
Set a default justification (optional): Include
defaultJustification: "Development work"when saving
Your configuration is saved to ~/.pim-me-mcp.json:
{
"quickRoles": {
"roles": [
{ "name": "Owner", "scope": "my-resource-group" },
{ "name": "Contributor", "scope": "my-subscription" }
],
"description": "My daily development roles",
"defaultJustification": "Development work"
}
}Daily Usage
Once configured, just say:
"Activate my quick roles" — uses your default justification
"Activate my quick roles for debugging production issue" — custom justification
"List my eligible roles" — see all roles you can activate
"List my active roles" — see currently elevated roles with expiration times
"Activate the Contributor role for my-subscription" — activate specific roles
Available Tools (MCP)
Tool | Description |
| Lists all PIM roles you can activate |
| Lists currently elevated roles with expiration times |
| Shows eligible roles with indices + your saved quick roles |
| Saves selected roles (by index) as quick roles |
| Activates your saved quick roles |
| Activates specific roles by name |
Library API
Core Functions
Function | Description |
| Returns all PIM roles you can activate |
| Returns currently elevated roles with expiration times |
| Activates specific roles |
| Activates your saved favorites |
Configuration Functions
Function | Description |
| Loads quick roles from config file or env |
| Saves quick roles to config |
| Returns path to |
Types
interface RoleConfig {
name: string; // e.g., "Contributor"
scope: string; // e.g., "my-subscription"
}
interface QuickRolesConfig {
roles: RoleConfig[];
description?: string;
defaultJustification?: string;
}How It Works
This MCP server uses the Azure CLI to interact with the Azure PIM REST API:
Lists eligible roles via
roleEligibilityScheduleInstancesAPILists active roles via
roleAssignmentScheduleInstancesAPI (filtered toassignmentType=Activated)Activates roles via
roleAssignmentScheduleRequestsAPI withSelfActivaterequest type
API Version: 2020-10-01
Tricky Implementation Details
🔑 Group-Based Role Assignments
The trickiest part of Azure PIM automation is handling group-based role assignments. When a role is assigned to a group (rather than directly to a user), activation requires special handling.
Problem 1: Wrong Principal ID
Symptom: "InsufficientPermissions" or "The assignee cannot be found"
Cause: The roleEligibilityScheduleInstances API returns the group's principal ID, but the activation API needs the user's principal ID.
Solution: Extract the user's OID from the Azure access token JWT:
async function getCurrentUserPrincipalId(): Promise<string> {
const tokenResult = await azCommand(
"account get-access-token --resource https://management.azure.com"
);
const tokenData = JSON.parse(tokenResult);
// Decode JWT payload (base64)
const payload = JSON.parse(
Buffer.from(tokenData.accessToken.split('.')[1], 'base64').toString()
);
return payload.oid; // The user's Azure AD Object ID
}Problem 2: Missing Linked Schedule ID
Symptom: Activation fails for group-based roles even with correct principal ID
Solution: For group-based assignments, include linkedRoleEligibilityScheduleId in the request body. This links the activation back to the group's eligibility schedule.
📦 Activation Request Body
{
"properties": {
"principalId": "<user-oid>",
"roleDefinitionId": "<role-definition-id>",
"requestType": "SelfActivate",
"justification": "<business-justification>",
"scheduleInfo": {
"expiration": {
"type": "AfterDuration",
"duration": "PT8H"
}
},
"linkedRoleEligibilityScheduleId": "<eligibility-schedule-id>"
}
}Note:
linkedRoleEligibilityScheduleIdis required for group-based assignments, optional for direct assignments.
⚠️ Error Handling
Error Code | Meaning | Solution |
| Role already activated | Treat as success ✅ |
| Wrong principal ID | Use user's OID, not group's |
| Principal ID mismatch | Extract OID from access token |
📋 API Reference
Endpoint | Method | Purpose |
| GET | List eligible roles |
| GET | List active roles |
| PUT | Activate a role |
Troubleshooting
Issue | Solution |
"Command 'az' not found" | |
"Please run 'az login'" | Run |
Role not found | Use |
License
MIT
Available Tools
6 toolsactivate_pim_rolesB
Activates specified PIM (Privileged Identity Management) roles in Azure. Provide role names and scopes to match against your eligible roles.
Inputs: roles (required), justification (required), duration.
activate_quick_rolesA
Activates your saved quick roles (favorites) for fast elevation. Configure your quick roles first using list_quick_roles and save_quick_roles. Reads the latest config each time, so no server reload needed after changes.
Inputs: duration, justification.
list_active_rolesA
Lists all currently active (elevated) PIM role assignments. Shows which roles you have activated, along with their start and end times.
Inputs: no named parameters.
list_eligible_rolesA
Lists all eligible PIM (Privileged Identity Management) roles that can be activated in Azure. Returns role names, scopes, and whether they are assigned directly or through a group.
Inputs: no named parameters.
list_quick_rolesA
Lists all eligible PIM roles with indices and shows your currently saved quick roles. Use this to see available roles, then call save_quick_roles with your selected indices to update your favorites.
Inputs: no named parameters.
save_quick_rolesA
Saves your selected roles as quick roles for fast activation. Use the indices from list_quick_roles to specify which roles to save.
Inputs: indices (required), description, defaultJustification.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
list_eligible_roles and list_quick_roles overlap significantly by both listing eligible roles, though list_quick_roles adds indices and saved quick-role info. activate_quick_roles and activate_pim_roles are distinct in purpose but could still be confused at a glance.
All tool names follow a consistent snake_case verb_noun pattern, starting with list, activate, or save. The naming clearly communicates the action and target object without mixing conventions.
With 6 tools, the server is well-scoped for a focused PIM role activation workflow. Each tool serves a recognizable function within the quick-role and direct-activation flows.
The set covers listing eligible roles, activating roles, quick-role management, and listing active roles, but lacks a deactivate or end-role operation. This creates a dead end for users who want to manually end an elevation early.
Maintenance
Related MCP Connectors
Official Microsoft MCP Server to query Microsoft Entra data using natural language
The MCP server for Azure DevOps, bringing the power of Azure DevOps directly to your agents.
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
MCP server for Pentest-Tools.com: run scans, manage findings and reports via your preffered LLM.
Related MCP Servers
- AlicenseBqualityBmaintenanceAn MCP server that enables running CLI for Microsoft 365 commands through GitHub Copilot Agent, allowing users to interact with Microsoft 365 services using natural language.42,279 npm135MIT
- AlicenseAqualityCmaintenanceCloud cost management MCP server for Azure. Ask your AI about your cloud bill.15149 npm1MIT
- AlicenseAqualityDmaintenanceAn MCP server for Azure development and operations, enabling Cosmos DB queries, Service Bus messaging, and PIM role activation.3144 PyPIMIT
- AlicenseBqualityCmaintenanceAn MCP server for managing Azure infrastructure from AI assistants, supporting subscriptions, VMs, storage, networking, identity, and more through natural language commands.992MIT