ldap-mcp-server
Read-only MCP server for querying and auditing an LDAP directory.
Search users by uid, name, or email with partial matching and a result limit.
List the groups a given user belongs to.
Detect expired accounts or passwords unchanged for more than N days.
Reconcile a CSV of
usuario,aplicacion,rolaccess entries against the directory to find nonexistent users, expired accounts, and users with multiple roles in the same application.Safely query LDAP with read-only access, escaped filters, and restricted CSV file reads.
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., "@ldap-mcp-server which groups does ana.garcia belong to?"
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.
ldap-mcp-server
Servidor MCP (Model Context Protocol) de solo lectura que permite a un agente de IA (Claude, u otro cliente MCP) consultar y auditar un directorio LDAP: buscar usuarios, ver sus grupos, detectar cuentas inactivas y cruzar listados de accesos para encontrar hallazgos de IAM.
Proyecto demostrativo basado en mi experiencia automatizando la depuración de accesos en entornos regulados. Todos los datos son ficticios (
dc=example,dc=org).
English summary: a read-only MCP server that lets AI agents query and audit an LDAP directory (user search, group membership, inactive accounts, access-list reconciliation). Ships with a Dockerized OpenLDAP and fake data.
Herramientas MCP
Herramienta | Qué hace |
| Busca por uid, nombre o correo (coincidencia parcial). |
| Devuelve los grupos ( |
| Cuentas expiradas ( |
| Cruza un CSV |
Related MCP server: LDAP Assistant MCP
Arquitectura
flowchart LR
A[Claude / agente IA] -- MCP stdio --> B[ldap-mcp-server<br/>MCP Python SDK]
B --> C[audit.py<br/>reglas de auditoría]
B --> D[directory.py<br/>ldap3 solo lectura]
D -- LDAP --> E[(OpenLDAP<br/>Docker)]
F[accesos.csv] --> BSolo lectura: la conexión se abre con
read_only=True; el servidor no expone ninguna operación de escritura.Filtros LDAP escapados para evitar inyección LDAP.
Lectura de CSV acotada:
cruzar_accesossolo lee archivos.csvdentro deLDAP_MCP_CSV_DIR(por defecto./data); rechaza rutas absolutas,.., rutas UNC y enlaces simbólicos.Lógica separada del acceso a datos: las reglas de auditoría se prueban sin servidor LDAP.
Inicio rápido
Requisitos: Python 3.10+, uv y Docker.
# 1. Levantar OpenLDAP con datos ficticios
docker compose up -d
# 2. Instalar dependencias y correr pruebas
uv sync
uv run pytest
# 3. Pruebas de integración contra el OpenLDAP local
cp .env.example .env
LDAP_INTEGRATION=1 uv run --env-file .env pytestConectarlo a Claude Desktop
Agrega esto a claude_desktop_config.json (ajusta la ruta):
{
"mcpServers": {
"ldap": {
"command": "uv",
"args": ["--directory", "C:/ruta/a/ldap-mcp-server", "run", "ldap-mcp-server"],
"env": {
"LDAP_URL": "ldap://localhost:389",
"LDAP_BIND_DN": "cn=admin,dc=example,dc=org",
"LDAP_BIND_PASSWORD": "admin_demo_local",
"LDAP_BASE_DN": "dc=example,dc=org",
"LDAP_MCP_CSV_DIR": "C:/ruta/a/ldap-mcp-server/data"
}
}
}
}Ejemplos de preguntas para el agente:
"¿Qué cuentas llevan más de 90 días sin cambiar la clave?"
"¿A qué grupos pertenece ana.garcia?"
"Cruza
accesos_ejemplo.csvcontra el directorio y dime qué accesos hay que revocar."
Estructura
src/ldap_mcp/
server.py # herramientas MCP (MCPServer, SDK oficial de Python)
directory.py # acceso LDAP de solo lectura (ldap3)
audit.py # reglas de auditoría (puras, testeables)
models.py # modelo Usuario
data/
seed.ldif # directorio ficticio
accesos_ejemplo.csv # listado de accesos de ejemplo
tests/ # unitarias + integración opcionalSeguridad
Usa una cuenta de servicio con permisos solo de lectura sobre el directorio.
No guardes credenciales en el repositorio: usa variables de entorno o
.env(ignorado por git).Para producción usa
ldaps://o StartTLS.
Autor
Kevin Stiven Naranjo González — AI-Ops & Agentic AI Engineer · LinkedIn · CV
Licencia MIT.
Available Tools
4 toolsbuscar_usuarioA
Busca usuarios por uid, nombre o correo (coincidencia parcial).
Args: texto: Texto a buscar, por ejemplo "garcia" o "ana.". limite: Máximo de resultados (1-100).
Inputs: texto (required), limite. Returns: result
cruzar_accesosB
Cruza un listado de accesos contra el directorio y marca hallazgos.
El CSV debe tener las columnas: usuario, aplicacion, rol. Devuelve usuarios inexistentes, cuentas expiradas y usuarios con varios roles en la misma aplicación.
Args: csv_texto: Contenido del CSV. ruta_csv: Alternativa: ruta local a un archivo .csv.
Inputs: ruta_csv, csv_texto.
detectar_cuentas_inactivasB
Lista cuentas expiradas o con la clave sin cambiar en más de N días.
Args: dias_sin_cambio_clave: Umbral en días (por defecto 90).
Inputs: dias_sin_cambio_clave.
listar_grupos_de_usuarioB
Devuelve los grupos a los que pertenece un usuario.
Args: uid: Identificador exacto del usuario, por ejemplo "ana.garcia".
Inputs: uid (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
The tools are highly distinct: one searches by various criteria, one lists groups for a specific user, one detects inactivity, and one performs complex CSV cross-validation. Each serves a very clear and non-overlapping purpose.
The tools consistently follow a clear action_subject pattern using Spanish verbs and nouns (e.g., 'buscar_usuario', 'listar_grupos_de_usuario'). The naming conventions are predictable and highly readable across the entire set.
For a directory server, four tools cover essential management and auditing functions effectively. While a few more granular retrieval tools might be useful, the current count is well-scoped to the functions presented.
The current set is almost entirely focused on read-only operations and auditing. There is a critical absence of basic user lifecycle management functions, such as creating, deleting, or modifying user attributes/passwords.
Maintenance
Related MCP Connectors
Read-only discovery for AgentCheck, a visitor-side security review of AI chatbots and agents.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Read-only finance and operations controls for AI agents with evidence and safe next actions.
Read-only local AI advice, shared reports and website audits. No PC scan or local actions.
Related MCP Servers
- FlicenseAqualityCmaintenanceProvides AI assistants with unified access to on-prem Active Directory via LDAP and Azure AD / Entra ID through the Microsoft Graph API. It enables comprehensive management and search of users, groups, computers, and cloud devices using 18 specialized tools.18-
- AlicenseNot gradedqualityCmaintenanceEnables troubleshooting of LDAP directory services through natural language queries, providing health diagnostics, replication status, performance metrics, log analysis, and configuration comparisons across multiple servers.19 PyPI1GPL 3.0
- AlicenseBqualityDmaintenanceProvides read-only access to corporate LDAP directories, enabling AI assistants to search for people, navigate organizational hierarchies, and export contact information.125MIT
- FlicenseNot gradedqualityCmaintenanceProvides read-only tools for monitoring and investigating Active Directory Domain Services, including users, groups, OUs, computers, GPOs, and domain metadata via LDAPS.-