Vibe Coding #1 - AI Agent Connected to PDFs in Python | Legislative Documents from Spain's Energy Sector

Building from scratch an AI agent that answers questions about PDF documents. The example: energy regulations from Spain's BOE. The technique: works for any documentation.

January 15, 2026 16:00 CET 1:14:00 ES
pythonchromadbai-agentsapimcp

Featured clips

Note: This is an AI-dubbed version of the original Spanish stream.

What we built

An AI agent connected to Spain’s BOE legislative documents that answers questions citing the relevant articles.

You ask: “How is the secondary band price calculated?” and it responds with the exact reference to the corresponding article.

The real problem

How much time does your team waste searching through hundreds of pages of regulations? In the energy sector, operators constantly consult grid programs, generation commitments, and curtailment regulations.

What we did step by step

  1. PDF Extraction — Converted the Electrical Energy Code to Markdown using PyMuPDF4LLM
  2. Vector Database — Indexed documents in ChromaDB for semantic search
  3. Python API — Created REST endpoints to query the documentation
  4. MCP Integration — Connected the API as an MCP server so Claude Code can use it directly

Key discovery

During the stream we discovered the initial parser was failing because not all “articles” are called that. Some are written as “rules”, “provisions”, or “annexes”. We had to adapt the system to handle these variations.

“Coding with AI is like driving: if you don’t stop it when you should, you’ll crash.”

Tech stack

  • Python — Main language
  • ChromaDB — Vector database
  • PyMuPDF4LLM — PDF extraction optimized for LLMs
  • FastMCP — Protocol for connecting with AI agents
  • Claude Code — Development agent

Who is this for

  • Developers who want to connect AI agents to their data
  • Technical teams evaluating solutions for internal documentation
  • Energy sector — the example is energy legislation, but the technique is universal

Resources

Subscribe to our newsletter

Get weekly insights on data, automation, and AI.

© 2026 Datons. All rights reserved.