MCP Legal Chile
Connects AI assistants to Chilean legal sources, enabling citation of official legal texts, search of doctrine, jurisprudence, and rulings.
README
MCP Legal Chile
Conector MCP de derecho chileno para Claude, Cursor y apps compatibles.
Producción: https://mcp-legal-chile.onrender.com/mcp
Versión: 1.7.3
Matriz de honestidad (qué trae cada tool)
| Tool | Evidencia | Fuente |
|---|---|---|
citar_texto_legal |
Texto íntegro + cita | XML LeyChile en blockquote |
buscar_doctrina / obtener_doctrina |
Metadata + abstract + citas Chile/APA | SciELO Chile (22 revistas) + OpenAlex + Crossref |
buscar_doctrina_latam |
Metadata + citas + enlaces por país | Catálogo PE / BR / AR / MX / CO (OpenAlex + SciELO/OJS) |
buscar_jurisprudencia |
Solo enlace (PJUD) | Búsqueda web → pjud.cl |
buscar_tc |
Metadata + PDF | API buscador-backend.tcchile.cl |
resolver_rol |
Enlaces + candidatos | TC API + portales PJUD/TC/TDLC… |
obtener_fallo_tc |
Extracto + blockquote | API oficial Tribunal Constitucional |
buscar_dictamenes / resolver_dictamen |
Solo enlace | Contraloría |
investigar_tema |
Pack mixto (parcial OK) | Orquesta lo anterior con tope global ~12s |
Regla: si evidence=link_only, el asistente no debe afirmar el contenido del fallo/dictamen.
Cómo usarlo sin quedarse corto
- Empieza con
investigar_tema(mapa rápido, no texto íntegro de todo). - Extrae texto solo con tools de extracción:
citar_texto_legal,obtener_articulo,obtener_fallo_tc. - No esperes contenido de PJUD/CGR vía
buscar_*— solo enlaces oficiales a verificar.
SLOs (objetivos P95)
| Operación | Objetivo | Notas |
|---|---|---|
| Artículo con cache hit | < 500 ms | |
| Artículo cold (sin 429) | < 5 s | LeyChile puede rate-limitar |
buscar_legislacion |
< 4 s | SPARQL BCN |
buscar_derecho_chileno (parcial OK) |
< 8 s | |
investigar_tema (parcial OK) |
< 12 s | Tope duro PACK_TOTAL_MS; no es 4–8s end-to-end |
| Éxito XML LeyChile (24h, con caché) | > 95% |
Latencia variable (0.2–8s): típica en Render starter (arranque en frío / red). El keep-alive mitiga, no elimina.
Métricas en vivo: GET /metrics
Capacidades principales
- Texto oficial LeyChile (artículos, índice/cuerpo, inciso/literal heurístico)
- Errores tipados: artículo no encontrado, XML inválido y formato no soportado (sin respuestas vacías)
- Catálogo de normas frecuentes (CPR, Códigos, 19.628, 19.496…)
investigar_tema— pack anti-alucinación con presupuesto global y salida acotada (~10k chars)formatear_cita— citas chilenas solo con IDs ya obtenidos- Jurisprudencia/TC con parsers ROL/RIT + catálogo de 18 tribunales/portales
- Caché durable (Redis si
REDIS_URL) + singleflight + stale-if-error - Rate limit / circuit breaker por proveedor (LeyChile, TC, OpenAlex, Crossref, SciELO…)
- Concurrencia acotada por proveedor, sin serializar toda la operación (evita cascadas)
- Búsquedas standalone con deadline duro de 15s (antes podían esperar 45–90s)
- API keys + cuotas diarias persistentes en Redis (
MCP_API_KEYS+REDIS_URL) - Warmup
/warmup+ cron keep-alive
Inicio rápido
npm install
npm run dev
npm test
# smoke local (server corriendo):
SMOKE_BASE=http://127.0.0.1:3000 npm run smoke
MCP: http://localhost:3000/mcp
Variables de entorno
| Variable | Descripción |
|---|---|
REDIS_URL |
Redis/Key Value: caché + cuotas diarias (si falta, solo memoria) |
MCP_API_KEYS |
name:key:limit,... — cuotas por key; persistentes con Redis |
SEARCH_PROVIDER |
auto | serper | brave |
SEARCH_API_KEY / SERPER_API_KEY / BRAVE_API_KEY |
Búsqueda web |
WARMUP_ON_BOOT |
1 (default) / 0 |
LEYCHILE_MIN_INTERVAL_MS |
Intervalo mínimo entre requests LeyChile |
CIRCUIT_OPEN_MS / CIRCUIT_THRESHOLD |
Circuit breaker |
SEARCH_TOOL_TIMEOUT_MS |
Tope total de búsquedas standalone (default 15s) |
FETCH_TIMEOUT_MS / TC_TIMEOUT_MS / SPARQL_TIMEOUT_MS |
Topes upstream (12s / 10s / 10s) |
*_MAX_CONCURRENT |
Concurrencia por proveedor (web 3; TC/OpenAlex/etc. 2; LeyChile 1) |
UNIFIED_BUDGET_MS |
Tope fan-out buscar_derecho_chileno (default 8s) |
PACK_TOTAL_MS |
Tope global investigar_tema (default 12s) |
PACK_TIMEOUT_MS |
Tope por fuente dentro del pack (default ~6s) |
PACK_MAX_CHARS |
Cap de salida del pack (default 10_000) |
PACK_ARTICLE_CHARS |
Cap de quote de artículo en pack (default 1_200) |
Deploy
Blueprint: render.yaml — plan starter, Key Value, cron keep-alive cada 10 min.
Aviso
No sustituye asesoría jurídica. PJUD/CGR no ofrecen API abierta de texto completo. El MCP es un puente: si BCN/PJUD/TC fallan, las tools degradan a warning/link o timeout parcial. En LeyChile, un artículo inexistente o XML no parseable se reporta como error explícito con enlaces oficiales de verificación.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.