In short: a legal ontology built by Dynamic Interfaces for Mexican labour law replaced 300 MCP tools with 7, and its cost per message fell from $0.60 to $0.02, a 97% drop. The saving comes from about 88,000 fewer tool-description tokens per request plus a cheaper model the smaller tool set allowed.
Method. System examined: Dynamic Interfaces' legal ontology for Mexican federal labour law, which we explored through its MCP server in March 2026. Corpus: 4 federal laws, 1,689 articles, 11 entity types, 7 judicial precedents, 12 typed cross-reference kinds, 10 enum taxonomies. Tools exposed to the model: about 300 before (one per database operation), 7 after (one per legal operation). Tool descriptions in context: about 90,000 tokens before, about 2,100 after (roughly 300 tokens per tool). Cost per message: $0.60 before, $0.02 after, as measured and reported to us by Dynamic Interfaces; the $0.02 figure also reflects a move from a frontier model to a cheaper open-weight one. HAQQ did not re-run the cost measurement independently.
Key facts
- Ontology cost result: 300 tools to 7, $0.60 to $0.02 per message (Dynamic Interfaces, reported to HAQQ, March 2026).
- Tool-count research: RAG-MCP, which passes the model only the tool descriptions it retrieves, raised tool-selection accuracy from 13.62% to 43.13% and cut prompt tokens by more than 50% (Gan and Sun, arXiv:2505.03275, May 2025).
- Legal RAG hallucinations: a preregistered Stanford RegLab and HAI study found that Lexis+ AI, Westlaw AI-Assisted Research and Ask Practical Law AI each hallucinated between 17% and 33% of the time, less often than GPT-4 (Magesh et al., Journal of Empirical Legal Studies 22:216, April 2025).
- Harvey was valued at $15.5 billion after a $550 million round announced on 9 September 2026 (Harvey blog; TechCrunch, 9 Sep 2026).
- Mexico 2026 reference values: general minimum wage MXN 315.04 a day; UMA MXN 117.31 a day, in force from 1 February 2026 (CONASAMI and INEGI figures, as reported Jan 2026).
- Target corpus for HAQQ: UAE Federal Decree-Law No. 33 of 2021 on the regulation of labour relations has 74 articles, in force since 2 February 2022 (UNEP LEAP legislation database, read 20 Oct 2026).
How did we come across this system?
In March 2026 I joined a call with the CEO of Dynamic Interfaces to see a legal ontology they had built for Mexican labour law. They told us five Mexican government customers use it daily, and that court-appointed expert witnesses (peritos) query four federal statutes through it and get answers with article-level citations. The number that made me spend the next two weeks inside it was the cost: two cents per message.
For a sense of scale, the per-seat legal AI market is priced in hundreds of dollars a month, and its leader, Harvey, was valued at $15.5 billion in September 2026. A two-cent message changes who can afford legal AI. This post is what I found when I connected to their MCP server, read the data model and tested it against the legal reasoning I would expect from a careful labour lawyer.
Disclosure. HAQQ sells legal AI, and at the time of writing we were exploring an integration with Dynamic Interfaces. Their cost figures are their own measurements; we report them with that label.
What does the Stanford study say about legal AI hallucinations?
Magesh, Surani, Dahl, Suzgun, Manning and Ho, at Stanford's RegLab and the Stanford Institute for Human-Centered AI, ran what they describe as the first preregistered evaluation of AI legal research tools. Published in the Journal of Empirical Legal Studies in April 2025, it found that the RAG-based tools from LexisNexis and Thomson Reuters each hallucinated between 17% and 33% of the time. Retrieval reduced hallucinations compared with GPT-4, and the tools differed a lot: Lexis+ AI answered 65% of queries accurately, Westlaw AI-Assisted Research 42%.
The study tested three products on US law in 2024. It does not show that every RAG system hallucinates at that rate, and it does not test ontologies. What it does show is that retrieval over text, on its own, left a measurable error rate in tools sold as reliable. That is the gap a structured model of the law tries to close. For court cases where fabricated citations reached a judge, see our hallucination audit.
Why does RAG struggle with statutes?
Most legal AI products retrieve passages: they chunk documents, embed them and fetch the chunks closest to the question. That works for many questions. On statute-heavy work it fails in three predictable ways.
Versions over time
A chunk of an article carries no date. Mexico's "Vacaciones Dignas" reform, published in the Diario Oficial de la Federación on 27 December 2022, amended Articles 76 and 78 of the Ley Federal del Trabajo and raised the first-year vacation entitlement from 6 to 12 days from 2023. A perito valuing a dismissal that spans the change needs both versions and the date each applied. Plain retrieval has no field for that.
Hierarchy
Law is layered: constitution, federal law, regulations, then titles, chapters, articles and fractions inside each law. Chunking flattens it. When one article applies "in the terms of" another, a retriever can return the first without the second.
Cross-references
Article 162 of the Ley Federal del Trabajo (seniority premium of 12 days' wages per year of service) takes its salary base from Articles 485 and 486, which cap it at twice the minimum wage. Getting the number right means following that chain. Similarity search returns fragments; a graph walks the links.
What is a legal ontology?
A legal ontology is a machine-readable model of a body of law: its entities (laws, articles, courts, precedents, computed values such as wage caps), the hierarchy between them, the dates each version applied, and typed links between provisions. A model answering a question queries that structure instead of searching loose text.
In the Dynamic Interfaces system each cross-reference has a type: remite_a (refers to), complementa (complements), modifica (amends), excepciona (creates an exception), define_termino (defines a term), establece_formula (sets a formula) and establece_procedimiento (sets a procedure). The exception type matters most to me. Article 5 of the LFT sets general rights, and special work regimes carve out exceptions. A system that does not record exceptions will apply the general rule where the special one governs.
How much does a legal ontology reduce AI costs?
Per Dynamic Interfaces' measurement, from $0.60 to $0.02 per message. Two things produce the drop, and it helps to keep them apart.
Fewer tool descriptions in every request
The usual way to build an agent is to expose each database operation as a tool. Across 11 entity types that reaches about 300 tools, and every tool description is sent to the model with every request: at roughly 300 tokens each, about 90,000 tokens before the user has asked anything. The ontology replaces them with 7 legal operations: query_legal_knowledge, calculate_settlement, find_jurisprudencia, get_cross_references, get_wage_data, get_vacation_table and generate_dictamen. That is about 2,100 tokens of descriptions, a saving of roughly 87,900 tokens per request.
This matches published research. In the RAG-MCP paper, showing the model only the relevant tools instead of all of them more than tripled tool-selection accuracy (13.62% to 43.13%) and cut prompt tokens by more than half.
A cheaper model can do the job
With 7 clear tools, the model's task is smaller: understand the question, pick one to three tools, and write up structured results. The ontology does the structural work. That let Dynamic Interfaces move from a frontier model to a cheaper open-weight one, which accounts for much of the remaining saving.
Vyzkoušejte HAQQ AI zdarma
Zažijte sepisování a rešerše s podporou AI
What the saving means for a perito
Take a perito laboral in Mexico City earning roughly MXN 15,000 to 30,000 a month (the range we were given), handling 50 cases a month at 20 messages each. At $0.60 a message, that is $600 a month, about MXN 10,800 at 18 pesos to the dollar, or 36% to 72% of income. At $0.02 it is $20, about 1.2% to 2.4%. The lower price opens a market that the higher one rules out.
Which reference unit applies: UMA or minimum wage?
Since the constitutional reform of January 2016, Mexico has two reference units: the UMA (Unidad de Medida y Actualización) and the minimum wage. In 2026 the general minimum wage is MXN 315.04 a day and the UMA MXN 117.31, a ratio of about 2.69. For the seniority-premium cap under Articles 162, 485 and 486, twice the minimum wage gives MXN 630.08 a day and twice the UMA gives MXN 234.62, 62.8% less.
Calculators and commentators in Mexico do not all apply the same unit to this cap, so this is a choice a lawyer has to make and defend. A retrieval system leaves that choice to the model on every query. An ontology records which unit the firm applies to which concept, and the authority for it, so the choice is visible and the same every time.
Can a legal ontology work in other jurisdictions?
The building blocks recur everywhere: hierarchical legislation, subject tags, cross-reference graphs, versions over time and computed values. Civil-law systems with codified statutes (France, Brazil, Saudi Arabia, the UAE) map most directly. Hudson de Martim's SAT-Graph RAG paper applies a similar structural and temporal model to the Brazilian Constitution. Common-law systems need case law treated as a first-class entity beside statutes.
What is HAQQ building with this?
We are building a UAE labour-law ontology, starting with Federal Decree-Law No. 33 of 2021 (74 articles) and its implementing regulation. Saudi Arabia's Labor Law, issued by Royal Decree No. M/51 of 1426H, is about 245 articles. Corpora of that size can be modelled and checked by lawyers in weeks. Because the ontology hands the model structured data, the model synthesises in Arabic or English instead of extracting rules from Arabic text, which is the harder task. The ontology will feed HAQQ's legal research on UAE labour questions.
Governments are moving the same way. The EU's European Legislation Identifier (ELI), agreed by the Council in 2012, gives legislation stable machine-readable identifiers, and New Zealand's Better Rules work drafts policy as plain language, rules and code together.
How do you build a legal ontology?
For one country's labour law, our working estimate is 4 to 8 weeks. These are the steps we follow:
- Identify the 3 to 5 primary statutes and their official sources, and check how machine-readable each is.
- Design the entity model. Start from a general template (Law, StructuralUnit, Article, CaseLaw, CrossReference, ComputedValue) and add what the jurisdiction needs.
- Define the taxonomies: 15 to 25 subject tags, the cross-reference types and the computed-value types.
- Parse the laws, keep the hierarchy and version dates, tag articles by subject (a model can draft tags; a lawyer approves them) and load them into a database.
- Build the cross-reference graph: explicit references first, then references between laws, with every edge typed and reviewed.
- Expose a small set of tools over MCP, for example search articles, get article, get cross-references, get case law, compute value, get timeline and compare jurisdictions.
- Measure before and after: tool tokens per request, cost per message, and accuracy on a test set of questions with lawyer-approved answers.
References
- Magesh et al., Hallucination-Free? Assessing the Reliability of Leading AI Legal Research Tools, Journal of Empirical Legal Studies 22:216 to 242 (2025)
- Gan and Sun, RAG-MCP: Mitigating Prompt Bloat in LLM Tool Selection via Retrieval-Augmented Generation, arXiv:2505.03275
- de Martim, An Ontology-Driven Graph RAG for Legal Norms, arXiv:2505.00039
- Harvey raises $550M at a $15.5B valuation (Harvey blog, 9 Sep 2026)
- Harvey hits $15.5B valuation months after reaching $11B (TechCrunch, 9 Sep 2026)
- Anthropic: donating the Model Context Protocol to the Agentic AI Foundation (9 Dec 2025)
- UAE employment laws and regulations in the private sector (u.ae), incl. Federal Decree-Law No. 33 of 2021
- Federal Decree-Law No. 33 of 2021 (UNEP LEAP legislation database)
- Ley Federal del Trabajo (Cámara de Diputados)



