Skip to main content
Glama

CREG MCP Server

Leer en español

An MCP (Model Context Protocol) server for querying the regulation of Colombia's Energy and Gas Regulatory Commission (CREG, Comisión de Regulación de Energía y Gas). Claude Desktop, Claude Code or any other MCP client can search CREG resolutions and legal opinions (conceptos), read them in chunks or by searching inside, and see each rule's regulatory graph: which law it rests on, what it repeals or amends, and what later repealed or amended it.

What sets it apart from a search engine is that validity is not typed in by hand: it is computed from the texts themselves. Every read starts with the rule's computed status (its effective-date clause and the repeals found in the corpus, with the evidence), so a repealed resolution is not cited as current. For example, CREG 030 of 2018 comes out repealed by CREG 174 of 2021.

The documents are in Spanish, as published by the CREG; tool names and outputs are in Spanish too.

Tools

Tool

What it does

creg_listar_categorias

Corpus inventory by topic and document type

creg_buscar

Keyword search, filtered by topic and type (resolucion, concepto)

creg_leer_documento

Reads a rule in chunks (desde) or by searching inside (buscar), with its computed validity first

creg_relaciones

Regulatory graph of a rule (174 de 2021, 174/2021 or its path): legal basis, predecessors, replacements and the opinions that cite it

Each tool takes a single params object, for example creg_relaciones(params={"norma": "030 de 2018"}).

Suggested use: creg_buscar to find the rule, creg_relaciones to know where to look, creg_leer_documento to cite. The graph tells you where to look; the citation comes from what you read.

Related MCP server: regwatch-co

Corpus

CREG resolutions and opinions in Markdown, shipped inside the package (src/creg_mcp/corpus/), organised by topic: renewables and distributed generation (AGPE, GD), trading and wholesale market, distribution and grid connection, metering, tariffs, reliability charge, non-interconnected zones (ZNI) and energy storage. The full list is in corpus.txt.

  • CREG texts only: no technical standards (IEC, IEEE, NTC), which are copyrighted, and no laws, decrees or RETIE.

  • Only the text of the rule: handwritten working summaries are not included.

  • It is a dated selection, not the whole of CREG regulation. A rule outside the corpus shows up in the graph as "fuera del repositorio" and cannot be read through the server: do not cite it as read.

  • To use another corpus with the same layout (<topic>/resoluciones|conceptos/*.md), set CREG_MCP_CORPUS to its path.

Installation

Requires Python 3.10 or later.

git clone https://github.com/jpsalamanca-co/creg-mcp.git
cd creg-mcp
pip install -e ".[dev]"   # [dev] adds pytest, pytest-asyncio and ruff
python -m pytest tests -q

Client configuration

Claude Desktop (claude_desktop_config.json) or Claude Code (.mcp.json):

{
  "mcpServers": {
    "creg": {
      "command": "creg-mcp",
      "env": { "PYTHONIOENCODING": "utf-8" }
    }
  }
}

To run it directly over stdio: creg-mcp or python -m creg_mcp.server. Quick check without a client: creg-mcp --test.

Tests

python -m pytest tests -q checks that:

  • the corpus holds only CREG resolutions and opinions, with no handwritten summaries, and matches corpus.txt;

  • CREG 030 of 2018 comes out repealed by 174 of 2021, and 174 of 2021 comes out in force;

  • reads cannot escape the corpus folder;

  • over stdio, the server lists its four tools and answers a rule's graph.

Scope

A lookup tool, not legal advice. Computed validity comes from the rules written in vigencia.py applied to the corpus in the package: a later rule that is not in the corpus cannot be taken into account. Before applying a rule, confirm its text and status at the CREG's official source.

License

Code: MIT, see LICENSE. The CREG texts are official documents published by the Commission; see NOTICE.md.

Available Tools

4 tools
creg_buscarA
Read-onlyIdempotent

Busca documentos regulatorios del sector eléctrico colombiano por palabra clave.

Busca en títulos, temas, nombres de archivo y resúmenes de los documentos .md del repositorio. Útil para encontrar resoluciones CREG, conceptos jurídicos, leyes y decretos sobre FNCER, generación distribuida, tarifas, conexión, etc.

Args: params (BuscarInput): Parámetros de búsqueda: - query (str): Palabra clave (ej: 'AGPE', 'excedentes', 'solar') - categoria (Optional[str]): Filtrar por categoría - tipo (Optional[str]): 'resolucion', 'concepto', o 'decreto' - limite (int): Máximo resultados (default 10) - todos (bool): exigir todos los términos. Por defecto la búsqueda puntúa término a término (OR): 'zanahoria AGPE' devuelve lo mismo que 'AGPE'.

Returns: str: Resultados en Markdown con título, categoría, tipo y ruta de cada documento.

Inputs: params (required). Returns: result

creg_leer_documentoA
Read-onlyIdempotent

Lee el contenido completo de un documento regulatorio .md del repositorio.

Dado la ruta relativa de un documento (obtenida de creg_buscar), retorna su contenido en Markdown. Incluye la tabla de metadata y el texto completo de la resolución, concepto o decreto.

Antepone la vigencia CALCULADA por vigencia.py desde la propia norma (cláusula de vigencia y derogatorias del corpus). Esa es la que se cita, no la fila Estado del documento.

Varias normas pasan de 50 000 caracteres (la 174/2021 tiene más de 200 000): para citar un artículo, localizarlo con buscar y leerlo con desde.

Args: params (LeerDocumentoInput): Parámetros: - ruta (str): Ruta relativa del documento - max_caracteres (int): Límite de caracteres (default 8000) - desde (int): Posición desde la que leer (default 0) - buscar (str): Texto a localizar; devuelve fragmentos con su posición

Returns: str: Vigencia calculada y el tramo pedido del documento, o los fragmentos donde aparece buscar.

Inputs: params (required). Returns: result

creg_listar_categoriasA
Read-onlyIdempotent

Lista las categorías del repositorio regulatorio CREG con conteo de documentos.

Retorna un resumen del inventario: cuántas resoluciones, conceptos y decretos hay en cada carpeta temática. Útil para entender qué regulación está disponible antes de buscar documentos específicos.

Returns: str: Resumen en Markdown con categorías y conteos.

Inputs: no named parameters. Returns: result

creg_relacionesA
Read-onlyIdempotent

Muestra de dónde viene una norma, qué deroga o modifica y quién la derogó o modificó.

Sale de grafo.py, que lee las cláusulas de los propios textos (deroga, modifica, adiciona, sustituye, "derogado por" en las anotaciones del Gestor, y las leyes invocadas en el preámbulo). Cada relación trae la cita y la ruta del documento para abrirlo.

NO sustituye la lectura: para citar una norma, aunque sea para decir que está derogada, abrir su documento con creg_leer_documento. Esto dice dónde mirar; la cita sale de lo leído.

Args: params (RelacionesInput): norma ('174 de 2021' o ruta) y profundidad (1-3).

Returns: str: Árbol en texto con fundamento, predecesoras, reemplazos, proyectos y conceptos que la mencionan.

Inputs: params (required). Returns: result

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 4 tools

    Disambiguation5/5

    Each tool targets a clearly distinct operation: listing categories, searching, reading full content, and exploring normative relations. There is no meaningful overlap—creg_buscar locates documents, creg_leer_documento reads them, and creg_relaciones maps their lineage. An agent can easily pick the right tool.

    Naming Consistency4/5

    All names share a consistent `creg_` prefix and are in Spanish, with clear verb_noun forms (listar_categorias, buscar, leer_documento). The minor deviation is creg_relaciones, which is a noun rather than a verb, slightly breaking the otherwise uniform action-oriented pattern.

    Tool Count5/5

    Four tools is well-scoped for a read-only regulatory repository: inventory, search, retrieval, and relationship mapping. Each tool earns its place and none is redundant. Nothing feels thin or bloated.

    Completeness5/5

    For a read-only corpus, the surface covers the full lifecycle of discovery (list categories), search, full-text reading with pagination, and cross-reference/derogation mapping. No obvious gaps remain for the stated purpose of finding and citing Colombian electric-sector regulation.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      MCP server for searching and extracting official announcements, decrees, and resolutions from the Argentine Official Gazette (Boletín Oficial de la República Argentina). It enables LLMs to perform real-time searches and retrieve verbatim legal text with complete juridical fidelity.
      14
      19 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      An MCP server for querying Colombian legislative norms and their current legal effect, with read-only tools for normativity search and validity consultation. It provides provenance-backed data with explicit citations to official sources.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables searching and reading Peru's Official Gazette for norms, resolutions, booklets, and PDFs through a local MCP harness. It provides full-text search with date and booklet filters, plus retrieval of document summaries, integral text, and public PDF URLs.
      9
      2
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Enables local MCP clients to search and read Peru's official legal information system, including legal norms and jurisprudence, with tools for full-text search, structure mapping, targeted reading, and filters. It provides clean content without storing files, using stdio transport and public session authentication.
      7
      4
      Apache 2.0