Democratizing FONASA MLE Access: Open Data and an MCP Server
How we transformed the FONASA medical exam catalog into an AI-ready tool with an MCP server and 7-digit normalized data.
Mario Inostroza
In Chile, the FONASA Modalidad Libre Elección (MLE) catalog is the “source of truth” for thousands of medical procedures. However, accessing it programmatically has historically been a nightmare of inconsistent Excel spreadsheets and truncated codes.
Today we are releasing fonasa-mle-open, an open-source project that cleans this data and exposes it via an MCP server so any AI agent can understand the Chilean healthcare system.
The Problem with “Living” Spreadsheets
Every March, FONASA publishes its annexes. But here’s the gotcha: the 2025 file looks nothing like the 2026 one. One uses sharedStrings.xml in its internal structure, the other uses in-line strings. One has 3 sheets, the other only 1.
If you try to parse them naively, you lose data or, worse, destroy the prices.
What We Built: Surgical Normalization
We implemented a Python extractor that normalizes every procedure to its canonical 7-digit code (Group + Subgroup + Item). Without this, interoperability is impossible.
// Example of robust search in the MCP server
const codeQuery = query.replace(/\D/g, "").padStart(7, "0");
// Now "301045" will always find "0301045" (CBC/Hemograma)
The Gotcha: The Excel Decimal Trap
A real bug we faced: Excel sometimes exports 1680 as 1680.0. In the Chilean pricing format, where a dot is usually a thousands separator (1.680), a simple heuristic could end up turning a $1,680 exam into a $16,800 one.
We solved it with regex cleaning and strict rounding before integer conversion.
Security and Robustness
We didn’t just stop at data. We applied a Judgment Day (adversarial review) to the code, and critical items surfaced:
- XXE Protection: The XML parser is now locked against external entities to prevent data exfiltration.
- Hybrid Search: The MCP server now handles partial code searches by ignoring leading zeros, perfect for when a user types quickly.
System Architecture
To ensure data integrity, we designed a pipeline that goes from the official Excel to the AI agent:
Why an MCP Server?
AI agents (like Claude) can now “learn” about Chilean healthcare in real time. By connecting this server to Claude Desktop, the model no longer hallucinates prices: it queries the source of truth.
Now Available for the Community
The project is live and you can use it in three ways:
- NPM: Run it directly with
npx @mariohealthbits/fonasa-mle-open. - Smithery.ai: Find it in the official Smithery catalog.
- GitHub: Check the code and data at marioSoftmedic/fonasa-mle-open.
What’s Next
The next technical step is automating extraction with a GitHub Action for March 2027, ensuring the data is always up to date.
📱 WhatsApp: +56962170366 🐦 X.com: @mariohealthbits 🌐 mariohealthbits.dev
Related reading
Similar topics
My B2B tech stack: How I use NotebookLM and Obsidian to close healthcare deals
Selling clinical software requires processing hours of meetings and dense PDFs. Here is the AI workflow I use to turn raw documents into lethal proposals.
Similar topics
Clinical AI Fails Because of Data, Not the Model
A clinical model can sound correct and still fail if it receives PDFs, free text and lab results without traceability. The problem starts before the prompt.
Similar topics
Human-in-the-loop is not enough: designing real oversight for medical AI
Medical AI oversight is not a doctor watching a screen. It requires authority, traceability, escalation, drift monitoring, and auditable evidence.