Skip to main content

Lex API MX — servidor MCP

Servidor Model Context Protocol que conecta Claude Desktop, Claude Code, Cursor o cualquier agente MCP con la legislación federal mexicana vigente de Lex API MX.

El servidor es un adaptador ligero y de código abierto (MIT): no contiene el corpus. Cada llamada consulta la API de Lex API MX con tu clave y devuelve el paquete normativo tal cual, con cita canónica, vigencia, fuente oficial y checksum SHA-256 del texto. La estructura de una norma llega como un índice compacto (el árbol completo de la Ley Federal del Trabajo pesa más de 1 MB; su índice, unos 15 KB).

Herramientas

Herramienta Endpoint Para qué
resolve_legal_citation POST /api/v1/resolve Resolver una cita o situación a un paquete normativo verificable.
search_mexican_law GET /api/v1/articulos/search Buscar artículos vigentes por texto, norma o materia.
get_norm_structure GET /api/v1/normas/{slug}/estructura Índice de una norma: primer y último artículo, divisiones en orden y números de artículo. El texto (include_text, por páginas de nodos con page) se rige por los permisos y la cuota de la cuenta.

Todas exigen fecha ("vigente" o YYYY-MM-DD). Las de búsqueda y resolución exigen además jurisdiccion; hoy la única cobertura es "federal".

Instalación

Requiere uv y una clave de Lex API MX. El plan gratuito publica sus límites vigentes en Cuenta: crea tu cuenta con tu correo y genera la clave en lexapi.mx/cuenta.

{
  "mcpServers": {
    "lex-api-mx": {
      "command": "uvx",
      "args": ["lex-api-mx-mcp"],
      "env": { "LEX_API_MX_KEY": "tu_clave" }
    }
  }
}
  • Claude Desktop: Settings → Developer → Edit Config y pega el bloque anterior en claude_desktop_config.json; reinicia la aplicación.
  • Claude Code: claude mcp add lex-api-mx --env LEX_API_MX_KEY=tu_clave -- uvx lex-api-mx-mcp
  • Cursor: el mismo bloque en ~/.cursor/mcp.json (global) o .cursor/mcp.json (proyecto).

Pruébalo preguntando: ¿Cuáles son las causas de rescisión de la relación de trabajo sin responsabilidad para el patrón? Cita el artículo exacto.

Variables de entorno

Variable Obligatoria Valor por defecto
LEX_API_MX_KEY Sí —
LEX_API_MX_BASE_URL No https://api.lexapi.mx

Errores

Los errores de la API llegan al modelo como errores de herramienta legibles y con la acción para la siguiente llamada: clave inválida (401), permiso faltante o plan requerido (403), saldo agotado (402: no reintentar y avisar al responsable de la cuenta con el enlace de recarga), norma inexistente o fecha anterior a la cobertura (404: qué slug o qué fecha usar) y límite de peticiones (429). Ante un 429 con espera de 30 segundos o menos, el servidor reintenta solo hasta dos veces.

Código fuente

github.com/Julio-Patron/lexapi-mx (licencia MIT). También está en el MCP Registry como io.github.Julio-Patron/lex-api-mx.

Lectura incluida y versión 0.4.0

API y MCP requieren la misma clave de una cuenta con correo confirmado. La política activa de Cuenta determina cuota y permisos; la lectura incluida no exige créditos. La cuota mensual se comparte entre claves por cuenta y mes UTC. monthly_quota_exceeded indica cuándo se renueva; no se resuelve comprando créditos. Se mantienen límites de texto, resultados, tamaño y concurrencia.

El MCP 0.4.0 incluye búsqueda, estructura, resolve, map_legal_topic, get_legal_article, list_legal_norms, get_legal_norm, get_legal_article_history y get_corpus_status. El mapa conserva un catálogo limitado de temas. Las ocho lecturas normativas aceptan idempotency_key: conserva identificador y parámetros para el mismo reintento; una petición distinta es otro evento. No se eliminan límites de ráfagas por reintentar. get_corpus_status consulta el estado público y no consume cuota.

La API y el MCP son gratuitos; no se venden planes ni recargas. Confirma tu correo y entra en Cuenta para recibir tu primera clave. Las cuentas anteriores pueden aceptar allí los límites gratuitos, conservando saldos e historial.

Metadata

Release files for lex-api-mx-mcp 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lex-api-mx-mcp 0.4.1
File Size Uploaded Provenance Actions
lex_api_mx_mcp-0.4.1.tar.gz 12.4 kB With provenance Details for lex_api_mx_mcp-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lex-api-mx-mcp 0.4.1
File Interpreter ABI Platform Actions
lex_api_mx_mcp-0.4.1-py3-none-any.whl Python 3 none any Details for lex_api_mx_mcp-0.4.1-py3-none-any.whl

Total release size: 24.7 kB

Release files / lex_api_mx_mcp-0.4.1.tar.gz

Download URL lex_api_mx_mcp-0.4.1.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5d671a081c8dd826ecda076115ad011963b9afd8e251e0e416c00641e9d8e512
BLAKE2b-256 checksum
How to use checksums
42cd6e39e534c5b8566a41fafb1a38ffd931f922c111d9a87b90fa8caf431d4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 3, 2026.

Transparency log

Release files / lex_api_mx_mcp-0.4.1-py3-none-any.whl

Download URL lex_api_mx_mcp-0.4.1-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8dc3bf801c9252909b276b545eefc0618c00461d951d42a6a5286848fbc27a54
BLAKE2b-256 checksum
How to use checksums
1b9e169f2cf33e030020cf2c7ff7f6fab23bfc47a539fb1f804bcd6f64b6bc1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 3, 2026.

Transparency log

Security for lex-api-mx-mcp 0.4.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lex_api_mx_mcp-0.4.1.tar.gz

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 Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page