legalize-mx-mcp
Summary: Query Mexican legislation (federal, state, municipal) with its reform history — search the catalog, read the text in force at any date, compare versions, and always get the official link to cite.
buscar_norma— full-text search across titles and content, filtered by state, municipality, type, validity, availability of text, or source.leer_norma— read the current text or the version in force on a given date; long texts come in pages, and uncatalogued texts can be fetched and extracted live (extraer_en_vivo).articulo— retrieve a single article ("27","3 bis","primero"), current or as of a date.historial— list reforms with date, change type, decree, and affected articles.diff— see which articles were reformed, added, or repealed between two dates, plus the diff.fuentes— official links to the original documents for citing or verifying.cobertura— check what exists and what is missing: norms per source and type, and the source for each municipality.dof_del_dia/leer_nota_dof— see what the DOF published on a given day (live) and read a note's full text.actualizar_indice— download the latest published index immediately, without restarting.Works both as a local MCP server/CLI and as an optional HTTP server, with the index kept up to date automatically.
Reads legal text and reform history from a public GitHub repository, with one Markdown file per law and one commit per reform. Uses GITHUB_TOKEN to raise API rate limits for history queries.
Downloads and periodically refreshes the search index (~90 MB) from a Hugging Face dataset, and can be deployed on Hugging Face Spaces via the optional HTTP server mode.
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., "@legalize-mx-mcp Busca el artículo 27 de la Constitución y su historial de reformas"
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.
legalize-mx-mcp
· v0.1.0, beta pública · cambios
MCP server y CLI para que agentes de IA consulten la legislación mexicana federal, estatal y municipal, con su historial de reformas.
Busca en el catálogo, lee el texto vigente o el que regía en una fecha, compara versiones y devuelve siempre el enlace oficial para citar.
Corre en tu máquina, sin servidor propio:
Índice de búsqueda: se baja una vez del dataset
elimoralsmendox/legalize-mxen Hugging Face (~90 MB) y se actualiza solo.Texto e historial: se piden por norma al repo público
elimorals/legalize-mx, con un archivo Markdown por ley y un commit por reforma.Documentos oficiales: cuando una norma solo está catalogada, se bajan y se extraen en vivo del portal oficial (SCJN, congresos, periódicos oficiales, municipios). El DOF del día también se consulta en vivo.
Qué contiene
Normas en el índice | ~215,000, de 53 fuentes oficiales (lista) |
Con texto e historial versionado | ~34,000 consolidadas, y ~40,000 más "como se publicaron" (de PDF y OCR) en publicación |
Fuentes | Catálogo de la SCJN (federal, 32 entidades, tratados), 31 congresos y la Consejería de CDMX, Cámara de Diputados, DOF (NOM, lineamientos, acuerdos), periódicos oficiales estatales y ~600 portales municipales |
Cobertura municipal | Censo de los 2,478 municipios: cuál es la fuente de cada uno, o por qué no la hay |
Cuándo no hay texto. No todas las normas tienen texto procesado todavía. En esos casos leer_norma lo dice y devuelve los documentos oficiales. Con extraer_en_vivo=true baja el documento y extrae su texto en ese momento. Un PDF escaneado sale vacío, porque necesita OCR.
Related MCP server: KriteriusMX
Instalación
Necesitas uv. Para extraer PDF en vivo hace falta además pdftotext (brew install poppler o apt install poppler-utils), o instalar el extra [pdf].
Claude Code: plugin con el MCP y la skill (recomendado)
/plugin install legalize-mx --marketplace elimorals/legalize-mx-mcpInstala el MCP y la skill legalize-mx. La skill le enseña al agente cuándo consultarlo y en qué orden usar las herramientas, cómo citar la fuente y versión, y qué no cubre. Con Claude Code anterior a 2.1.275: /plugin marketplace add elimorals/legalize-mx-mcp y luego /plugin install legalize-mx.
Claude Code: solo el MCP
claude mcp add legalize-mx -- uvx --from git+https://github.com/elimorals/legalize-mx-mcp@v0.1.0 legalize-mx-mcpOtros clientes MCP (.mcp.json, Claude Desktop, Cursor…)
{
"mcpServers": {
"legalize-mx": {
"command": "uvx",
"args": ["--from", "git+https://github.com/elimorals/legalize-mx-mcp@v0.1.0", "legalize-mx-mcp"],
"env": { "GITHUB_TOKEN": "" }
}
}
}Sin token, GitHub permite 60 consultas de historial por hora. El historial se guarda en caché 24 h. Con un GITHUB_TOKEN el límite sube a 5,000.
CLI
uvx --from git+https://github.com/elimorals/legalize-mx-mcp@v0.1.0 legalize-mx buscar "jornada laboral" --estado federalHerramientas
Herramienta | Qué hace |
| Búsqueda de texto completo en títulos y contenido, con filtros |
| Texto vigente, o el que regía en una fecha. Va por partes si es largo |
| Un artículo: |
| Reformas: fecha, decreto, artículos afectados |
| Artículos reformados, adicionados y derogados entre dos fechas, más el diff |
| Enlaces oficiales para citar o verificar |
| Qué hay y qué falta: normas por fuente y tipo, y la fuente de cada municipio |
| Lo que publicó el DOF ese día (en vivo) |
| Texto completo de una nota del DOF (en vivo) |
| Baja ya el índice más reciente, sin reiniciar |
En el CLI son los subcomandos buscar, leer, articulo, historial, diff, fuentes, cobertura, dof, nota-dof, actualizar e info.
Mantenerlo al día
El índice se publica de nuevo conforme entran normas y reformas. Tu copia local se mantiene así:
Al arrancar: si pasaron más de 24 h desde la última revisión, el MCP consulta
index/latest.json, que pesa unos bytes, y baja el índice solo si hay versión nueva.Mientras corre: si se publica un índice nuevo,
buscar_norma,coberturaeinfoagregan a su respuesta un campoaviso_indicecon el mensaje para el usuario. Conactualizar_indice()olegalize-mx actualizarse cambia a la versión nueva sin reiniciar.Si tu copia tiene más de 7 días, también aparece
aviso_indice, porque lo publicado esos días puede faltar. Lo más reciente se confirma condof_del_dia(), que consulta el DOF en vivo.El texto y el historial de cada ley siempre se leen del repo de GitHub, así que reflejan la última publicación aunque el índice sea de unos días antes.
Ejemplos
legalize-mx articulo CPEUM 27 --fecha 1920-01-01 # el artículo 27 original de 1917
legalize-mx diff LFT 2025-01-01 # qué cambió en la LFT desde enero de 2025
legalize-mx buscar "protección civil" --municipio Zapopan
legalize-mx leer "muni-html:jal-zapopan:f30bbb480326df84" --en-vivo
legalize-mx cobertura --estado OAX
legalize-mx dofIdentificadores
Leyes federales: usan su abreviatura de Diputados (
CPEUM,LFT,LAMP…).Resto del catálogo de la SCJN:
{ESTADO}-{titulo}-{id}.Otras fuentes:
{fuente}:{id}, por ejemplocongreso-jal:…odof:5801377.
buscar_norma siempre devuelve el id.
Documentación
EJEMPLOS.md: llamadas reales con su respuesta y flujos completos de un agente.
docs/HERRAMIENTAS.md: referencia de cada herramienta (parámetros, respuesta, errores, avisos).
docs/DATOS.md: identificadores, campos, formato del repo y de los commits, esquema del índice.
docs/FUENTES.md: las 53 fuentes oficiales con sus conteos.
docs/ARQUITECTURA.md: cómo llega una norma del portal a la respuesta.
docs/MANTENIMIENTO.md: publicar, reglas de integridad, evaluaciones y tests.
docs/FAQ.md: confiabilidad, OCR, actualización, límites, licencia.
ROADMAP.md: qué falta y en qué orden.
Servidor HTTP (opcional)
Para agentes que no pueden lanzar procesos locales:
legalize-mx-mcp --http --host 0.0.0.0 --port 8000 # streamable HTTP en /mcpCorre igual en Hugging Face Spaces, Fly.io o cualquier VPS. No necesita base de datos: baja el mismo índice.
Variables de entorno
Variable | Para qué |
| Sube el límite de consultas de historial |
| Ruta a un clon local de |
| Ruta a un índice local (no lo descarga) |
| Carpeta de caché (por defecto |
Actualizar el índice (mantenedores)
python3 scripts/build_index.py --data …/data-mx --repo …/legalize-mx --censo …/research-censo \
--municipios …/municipios.json --out dist
scripts/publish_index.sh dist # sube index/ al dataset de Hugging FaceAdvertencia
Es una herramienta de consulta, no asesoría legal. El texto se obtiene automáticamente de fuentes oficiales y puede contener errores de origen o de conversión. Verifica siempre con la fuente oficial que devuelve fuentes() antes de usarlo en un asunto real.
Licencia
MIT para el código. Los textos legales son de dominio público: el art. 14, fr. VIII, de la Ley Federal del Derecho de Autor excluye de protección los textos legislativos y administrativos.
Available Tools
10 toolsactualizar_indiceA
Baja ahora el índice más reciente publicado y lo usa. Úsalo cuando una respuesta traiga
aviso_indice, o si buscas algo publicado en los últimos días.
Inputs: no named parameters.
articuloC
Un artículo específico ("27", "3 bis", "primero"), vigente o a una fecha.
Inputs: id (required), numero (required), fecha.
buscar_normaA
Busca normas por texto (título y contenido) con filtros.
estado: clave de 3 letras (JAL, NLE, CMX…) o "federal". municipio: nombre o clave INEGI. tipo: ley, ley_federal, ley_general, codigo, reglamento, bando, ley_de_ingresos, presupuesto, acuerdo, decreto, lineamientos, tratado, nom… vigente: true/false. con_texto: solo las que tienen texto procesado. fuente: "scjn" o el slug de una fuente (congreso-jal, dof, muni-html…).
Inputs: tipo, desde, texto, estado, +5 more.
coberturaC
Qué hay y qué falta: normas por fuente y tipo, y la fuente municipal de cada municipio.
Inputs: estado, municipio.
diffB
Qué cambió entre la versión vigente en fecha_a y la de fecha_b (por omisión, la actual).
Inputs: id (required), fecha_a (required), fecha_b, max_caracteres.
dof_del_diaC
Lo que publicó hoy (o en fecha) el Diario Oficial de la Federación, en vivo.
Inputs: fecha, solo_normativas.
fuentesC
Enlaces oficiales a los documentos originales (para citar o verificar).
Inputs: id (required).
historialC
Reformas de una norma: fecha, tipo de cambio, decreto y artículos afectados.
Inputs: id (required).
leer_normaB
Texto de una norma: el vigente, o el que regía en fecha (AAAA-MM-DD).
Textos largos vienen por partes: usa desde con el valor siguiente_desde. Si la norma solo
está catalogada, devuelve sus documentos oficiales; con extraer_en_vivo=true los baja y extrae.
Inputs: id (required), desde, fecha, max_caracteres, +1 more.
leer_nota_dofC
Texto completo de una nota del DOF por su código (de dof_del_dia), en vivo.
Inputs: codigo (required), desde, max_caracteres.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool targets a fairly distinct operation: search (buscar_norma), full read (leer_norma), single article (articulo), reform history (historial), version comparison (diff), official sources (fuentes), coverage metadata (cobertura), and DOF live tools. Minor overlap exists between leer_norma/articulo (both return text) and between fuentes and leer_norma's catalog fallback, but descriptions clarify the boundaries.
All names are snake_case and readable, but the convention is mixed: some use verb_noun (buscar_norma, leer_norma, leer_nota_dof, actualizar_indice) while others are bare nouns (articulo, historial, diff, fuentes, cobertura, dof_del_dia). Readable but not a predictable single pattern.
10 tools is well-scoped for a legal-norm research server, with each tool earning a distinct role across search, retrieval, provenance, and freshness workflows. No redundant or filler tools.
The surface covers the research lifecycle well: discovery, reading (full/partial/by article), historical versions, diffs, citation sources, coverage reporting, and live DOF retrieval plus index refresh. Minor gaps like a bulk/export or citation-formatting tool are absent but workable around.
Maintenance
Related MCP Connectors
Resolve, search and verify legal citations against the official sources, with provenance.
Official Mexican data for AI agents: CURP, RFC, CFDI, postal codes, phone, SPEI/CEP, DOF, geocoding.
Polish statutes (Dziennik Ustaw, ELI) and court rulings (SAOS) for AI agents. Runs on Apify.
Current law as data for AI: search, read and verify statutes and citations. CIS countries first.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables querying Mexican federal legislation (316 laws indexed) through natural language, with tools for legal consultation, pricing, and law catalog browsing.-
- AlicenseNot gradedqualityBmaintenanceEnables Claude to search and retrieve legal sources from Mexican and inter-American courts (SCJN, TFJA, DOF, Corte IDH) with complete citations and official links.MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to search Mexican federal and state statutes, Supreme Court theses, and precedents, returning verifiable citations with dated validity, public URLs, and explicit indication of whether case law is binding jurisprudence or merely persuasive.-

Legalizeofficial
AlicenseNot gradedqualityBmaintenanceEnables AI assistants to search and read consolidated legislation from multiple countries, retrieve exact law texts as of any historical date with citations and git commit SHAs, and create webhook or email subscriptions to track legal changes.2MIT