Skip to main content
Glama
Entra ID SecOps MCP Server

Entra ID SecOps MCP Server

by Sultan-zd

Entra ID SecOps MCP Server

CI Python MCP License

An MCP server that exposes Microsoft Entra ID security logs as tools executable by an AI agent (Claude Desktop, Cursor, or any other MCP client).

Goal: allow an analyst to ask a question in natural language — "why can't this account sign in anymore?" — and get an answer in seconds based on the tenant's actual data.

📖 Installation and testing guide — the three ways to launch the server, step by step. 🔍 Technical brief — market scan and secure exposure.

Design Principle

A raw Microsoft Graph response contains about sixty fields per event. The server applies aggressive truncation: only about a dozen security indicators reach the model. This is both a cost optimization (factor ~35 on tokens) and a security control, since unlisted fields — some of which are attacker-controlled — never enter the context.

Aggregates (number of failures, distinct IPs, suspicious patterns) are computed in Python, not inferred by the model.

Related MCP server: Microsoft MCP Server for Enterprise

Tools

Tool

Purpose

Graph Permission

License

get_user_context

Account record: position, groups, held roles. Determines the severity of an incident.

Directory.Read.All

—

get_user_signins

Recent sign-ins for a UPN, with summary and suspicious patterns

AuditLog.Read.All

P1

get_risky_users

Accounts flagged as risky by Identity Protection

IdentityRiskyUser.Read.All

P2

get_risk_detections

Individual detections: why an account is at risk

IdentityRiskEvent.Read.All

P2

get_directory_audits

Administrative changes; flags persistence actions

AuditLog.Read.All

—

get_conditional_access_policies

Active policies and coverage gaps

Policy.Read.All

—

All tools are read-only: the server never modifies the tenant.

get_user_context     le compte est-il privilégié ? l'incident est-il grave ?
      ↓
get_user_signins     que s'est-il passé sur l'authentification ?
      ↓
get_risk_detections  qu'a détecté Identity Protection, et pourquoi ?
      ↓
get_directory_audits l'attaquant a-t-il modifié quelque chose une fois entré ?

This sequence is also described in the server's instructions, which the MCP client sends to the model.

Quick start (without an Azure tenant)

The fixture mode replays a demo incident and requires no tenant, license, or secret.

python -m venv venv
venv/Scripts/activate          # Windows ; sur Linux/macOS : source venv/bin/activate
pip install -e ".[dev]"

cp .env.example .env           # ENTRA_DATA_SOURCE=fixture est déjà la valeur par défaut
python -m entra_secops_mcp

Connecting to a real tenant

  1. Create an App Registration in the Entra portal.

  2. Add the application permissions from the table above, then grant admin consent.

  3. Generate a client secret.

  4. Fill in .env:

AZURE_TENANT_ID=...
AZURE_CLIENT_ID=...
AZURE_CLIENT_SECRET=...
ENTRA_DATA_SOURCE=graph

License required. Accessing sign-in logs via the API requires an Entra ID P1 license, and Identity Protection tools require P2. Without them, Graph returns 403. The other tools work without a paid license. Check the tenant's license before you start: this is the classic blocker that wastes several days.

Security

  • No secret is present in the code or in the Docker image. They are injected at startup via --env-file.

  • .env is excluded from git by .gitignore. A secret pushed to a repository must be revoked in Azure, not just deleted from the file.

  • Logging goes to stderr: in stdio transport, stdout carries the JSON-RPC protocol and tolerates no stray bytes.

Configuration

All variables are documented in .env.example.

Docker

docker build -t entra-secops-mcp .
docker run -i --rm --env-file .env entra-secops-mcp

Final image: 277 MB, multi-stage build, runs as a non-root user (uid=1000), no secrets in the layers.

-i keeps standard input open — that's where the MCP protocol passes through. No -t: a pseudo-terminal injects color codes that corrupt JSON frames.

Development

pytest              # 81 tests
ruff check src tests
mypy src            # mode strict
pre-commit install  # contrôles avant chaque commit
python demo.py      # investigation de démonstration

Status

Tools

6, all read-only

Tests

81, no Azure tenant required

Types

mypy --strict without warnings

MCP Protocol

2026-07-28 (SDK mcp 2.0)

Container

verified via a real MCP client: startup 2.4 s, tool call ~110 ms

License

MIT.

Available Tools

6 tools
get_conditional_access_policiesA
Read-onlyIdempotent

Liste les politiques d'accès conditionnel du tenant, avec leur état réel d'application.

À utiliser pour expliquer pourquoi une connexion a été bloquée (code 53003), ou pour repérer une faille de couverture : politique désactivée, politique en mode audit seul, ou exclusion qui permet à un compte de contourner un contrôle.

Inputs: limit. Returns: Résultat de `get_conditional_access_policies`.

get_directory_auditsA
Read-onlyIdempotent

Récupère les modifications administratives récentes de l'annuaire, afin d'identifier une dérive de configuration ou un changement non autorisé.

Signale automatiquement les opérations à valeur de persistance ou d'élévation de privilèges : attribution de rôle, ajout d'un secret applicatif, enrôlement d'une méthode MFA, modification d'une politique d'accès conditionnel.

À utiliser après avoir constaté une connexion suspecte, pour déterminer ce que l'attaquant a fait une fois entré.

Inputs: hours, limit, initiated_by. Returns: Résultat de `get_directory_audits`.

get_risk_detectionsA
Read-onlyIdempotent

Récupère les détections de risque unitaires : identifiants divulgués, IP anonymisée, voyage impossible, pulvérisation de mots de passe.

C'est l'outil qui explique POURQUOI un compte est signalé à risque, là où get_risky_users se contente de dire QUE le compte l'est.

Nécessite une licence Entra ID P2.

Inputs: upn, hours, limit. Returns: Résultat de `get_risk_detections`.

get_risky_usersA
Read-onlyIdempotent

Liste les comptes signalés à risque par Entra Identity Protection, du plus risqué au moins risqué.

À utiliser pour obtenir une vue d'ensemble de l'exposition du tenant, ou pour confirmer qu'un compte précis est bien considéré comme compromis.

Nécessite une licence Entra ID P2.

Inputs: limit, only_active. Returns: Résultat de `get_risky_users`.

get_user_contextA
Read-onlyIdempotent

Récupère la fiche d'identité d'un compte : poste, département, état, groupes d'appartenance et rôles d'annuaire détenus.

C'est l'outil qui détermine la GRAVITÉ d'un incident. Une connexion suspecte sur un compte sans privilège et sur un compte administrateur global appellent des réponses très différentes.

À appeler systématiquement avant de conclure sur un incident.

Inputs: upn (required). Returns: Fiche d'identité d'un compte : ce qui détermine la gravité d'un incident.

get_user_signinsA
Read-onlyIdempotent

Récupère les connexions récentes d'un utilisateur pour investiguer un blocage d'authentification, une anomalie géographique ou une compromission.

Retourne les événements réduits à leurs indicateurs de sécurité, plus une synthèse chiffrée (nombre d'échecs, IP distinctes, observations calculées).

Args: upn: User Principal Name complet, par exemple « alice@contoso.com ». hours: Fenêtre de recherche en heures. Défaut 24, maximum 168 (7 jours). limit: Nombre maximum d'événements retournés. Défaut 25, maximum 100.

Inputs: upn (required), hours, limit. Returns: Résultat de `get_user_signins` : les événements plus une synthèse chiffrée. La…

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool targets a distinct data source: user identity context, sign-in events, risky user aggregates, individual risk detections, directory audit logs, and conditional access policies. The closely related risky-user and risk-detection tools are explicitly differentiated by scope, so an agent can reliably pick the right one.

    Naming Consistency5/5

    All tool names follow a consistent get_<resource> pattern using snake_case: get_user_context, get_user_signins, get_risky_users, get_risk_detections, get_directory_audits, get_conditional_access_policies. The naming convention is uniform and predictable.

    Tool Count5/5

    Six tools is a tightly scoped set for an Entra ID SecOps investigation server. Each tool covers a necessary aspect of incident investigation without redundancy or bloat.

    Completeness5/5

    The tool surface covers the main investigative workflow: identify the user's privilege level, inspect sign-ins, review identity risk, understand specific risk detections, check for malicious directory changes, and evaluate conditional access impacts. No significant operational gap is apparent for the stated SecOps purpose.

    Maintenance

    ActivityStale
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      Provides secure access to Microsoft Entra ID (Azure AD) resources including users, devices, and applications through Microsoft Graph API. Enables querying organizational data with comprehensive audit logging to Azure Blob Storage.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables security investigation and threat hunting through Microsoft Defender and Entra ID, with 31 tools for KQL queries, alerts, threat intelligence, identity investigation, and advanced threat hunting.
      MIT