Today, a language model can connect to a database, write a valid SQL query and explain the result. But that isn't enough to trust its answers to analytical questions: to answer reliably, it needs a system that supplies the context the data alone doesn't show.

This post is the first of five in the series “From Text-to-SQL to an Instrumented Analytics MCP.” It presents the problem through an example and explains what it means to instrument. The rest of the series will follow: the seven ways a basic MCP can lead to wrong answers, what information the model receives and what the system does with it, how we check whether a change really improves the answers, and why answering analytical questions takes more than retrieving documents or generating SQL.

The system and the measurements we'll use for the example are real. It's a wholesaler, Alacena, but the data we've used is fictional. All five posts are based on the same real case, and we'll explain what an MCP server needs to do, beyond running SQL, to help a language model answer analytical questions reliably.

You don't need to know how language models work internally; a basic grasp of SQL is enough. If you're part of a data, engineering or product team that has already connected (or is thinking about connecting) a language model to your data, this series will give you:

  • Concrete examples of wrong answers that can show up even when the model runs a valid query, so you can recognize them in your own system.
  • The techniques we tried to solve each problem and, where we measured it, what results we got.
  • A method for knowing whether a change really helps.
  • An explanation of why the four most obvious remedies aren't enough to solve the problem: a different model, a larger context window, better text-to-SQL or a better prompt.

It isn't an exhaustive catalog, a product, a benchmark or a set of code snippets to copy. We chose the cases and techniques because they illustrate specific problems and because we were able to measure them. In a real system, many other challenges come up, and we've left some techniques out here.

Key takeaway: a practical series to understand how to get more reliable answers when a model works with your data.

How a model answers a question about your data

Two things make this possible today. Language models write SQL well. And the Model Context Protocol (MCP), an open standard, lets a model call an external server: here, one that runs a query on your database and sends back the result. People call the simplest form of this “text-to-SQL”: text in, a query out. In this series, an MCP server that does only that is a naive MCP.

The path has five steps (figure 1). The model acts in two of them.

Figure 1. The five steps from question to answer. The model acts in two of them: it writes the query and it writes the answer. The person and the system do the rest.
Figure 1. The five steps from question to answer. The model acts in two of them: it writes the query and it writes the answer. The person and the system do the rest.

Here is that path on a table small enough to read in full. It belongs to an invented food wholesaler and holds one row per product line of an order, so an order with two products is two rows. The question: how many orders went to Málaga? Figure 2 shows how the model answers through a naive MCP.

Figure 2. With a naive MCP. The query is valid and the server returns 3, the rows highlighted in the table. The analyst reads “We shipped 3 orders to Málaga” with nothing to warn them; the red “wrong” mark is ours. The right answer is 4, as the note below explains.
Figure 2. With a naive MCP. The query is valid and the server returns 3, the rows highlighted in the table. The analyst reads “We shipped 3 orders to Málaga” with nothing to warn them; the red “wrong” mark is ours. The right answer is 4, as the note below explains.

The second exchange (figure 3) reaches 4 because two things changed, and neither is the model. The data was cleaned, so the city has one spelling. And before writing the query the model read what one row is.

A model can generate a technically correct query that produces a conceptually wrong result. This series picks up where that warning left off.

Key takeaway: the query was valid and the number was real. The answer was still wrong.

What a result does not show

Some questions are answered by one row. The answer is written in the table, and anyone can check it by looking at that row.

An analytical question asks for an aggregate: one figure, or a short list, that sums up every row that meets a condition. Figure 4 compares the two on the seven-row table of the example.

Figure 4. Left, a lookup question: the answer, Gijón, is in one row. Right, an analytical question: the answer, 4, comes out of six rows, and no row holds that value.
Figure 4. Left, a lookup question: the answer, Gijón, is in one row. Right, an analytical question: the answer, 4, comes out of six rows, and no row holds that value.

That difference makes an aggregated answer more delicate, for three reasons.

  1. The answer is compact. Thousands of rows end up as one figure or a five-line list. Nothing around it shows whether something is missing.
  2. One wrong assumption changes all of it. What is counted, which rows are included, up to which date. If one of them is wrong, the whole figure is wrong, not a detail of it. In the example, the same question gave 3 and 4.
  3. And it still looks reliable. An exact number, from a valid query, stated without hesitation, reads as a fact. The more compact the answer, the more it is trusted and the less it is checked.

So a wrong conclusion here costs more than a wrong detail: it is the figure a decision is taken on, and once one such figure turns out to be wrong, the analyst stops trusting the rest.

The example hid two things from the model: what one row is, and how the city is stored. A real database hides more, and at real size nobody can check by eye. A naive MCP hands the model that compact, partial result and leaves it to draw the conclusions. These are the six things it does not show: figure 5 gives what the model receives in each case, and figure 6 what is really there. The figures in them are examples.

Figure 5. What the model receives, in six cases. Each result looks complete: 500 rows, the top three customers, 4 orders in November with a fall of 73%, a count of 3, 71 orders for Málaga, 0 orders for Castellón de la Plana. The figures are examples.
Figure 5. What the model receives, in six cases. Each result looks complete: 500 rows, the top three customers, 4 orders in November with a fall of 73%, a count of 3, 71 orders for Málaga, 0 orders for Castellón de la Plana. The figures are examples.
Figure 6. What is really there in the same six cases: the table has 1,200,000 rows; three more customers tie for third place with 11 orders; November has only 9 of 30 days; the 3 rows are two orders; another 119 orders are stored as MALAGA; and “Castellón” has 40 orders.
Figure 6. What is really there in the same six cases: the table has 1,200,000 rows; three more customers tie for third place with 11 orders; November has only 9 of 30 days; the 3 rows are two orders; another 119 orders are stored as MALAGA; and “Castellón” has 40 orders.

From that result the model does two things. It copies data: single figures, tables and charts, which can be matched against what the query returned. And it writes from them: comparisons, trends, causes and headlines that are in no row, and that nothing can match mechanically.

With a partial result, the second is what fails most. The model writes fluent conclusions that are not grounded in the data. Every number in them is real, which is why nobody notices.

Key takeaway: a model can only reason about what it is shown, and a result shows less than it seems.

What will not fix it

The natural reaction is to improve one of the components already in place. There are four obvious remedies: a more powerful model, a larger context window, better query generation, a better prompt. None of them fixes it.

A more powerful model? It does not supply what is missing

A more powerful model reasons better over what it receives. With a naive MCP, what is missing is information that is in neither the question nor the rows, and no model can make it up. Whether another model would make better use of that information once the system supplies it, we do not know: we did not test other models. That is why we changed what the model is handed instead of waiting for a better one.

A larger context window? It helps, and there is always a limit

The context window is how much text a model can read at once. A larger one holds more rows, never all of them: tables grow faster than windows. And a model with every row in view is still counting and adding by eye.

Better text-to-SQL? Not on its own

The model is not short of SQL skill. It is short of information that is in neither the question nor the schema: what one row is, which values are stored, in which unit. A better query writer without that information writes the same valid, wrong query. The error gets in at two points: a valid query that computes something else, as in the example, or a reading that takes more from the result than it says.

A better prompt? Not enough

The prompt is the set of instructions the model works under, and the first thing most teams rewrite. But a rule written in a prompt can be ignored, and in our tests a three-sentence warning attached to a result, with the field renamed to match, did not prevent a misreading. And a prompt is written before the result is known, while what is missing changes with every result. The third post in the series shows that case, with what we measured.

Key takeaway: none of the four remedies is enough. What is missing has to come from what surrounds the model.

What instrumenting means

Only the system around the model can know what a result does not show. Instrumenting means building that knowledge in, at four points between the data and the finished answer.

  1. In the data. Problems are fixed where they are stored: one spelling per value, each quantity tied to its unit. Cleaning the data is the only fix that took wrong rankings from split spellings to zero, and the one that is not always available. The other three layers are what is left when it is missing, and the series says how far they reach.
  2. In the MCP server. Each result comes back saying what it covers and what it does not. A few requests that cannot mean anything are refused.
  3. In what the model is handed. The model reads a description of the data first, and receives results in a form it cannot misread or re-add.
  4. In the application around the model. Every figure in the finished answer is matched to a result that was really returned, or visibly marked.

The rest of the series follows that order of ideas: the second post covers the problem in detail, the third the machinery, the fourth how we know it works, and the fifth what we learned.

Key takeaway: instrumenting means the system knows what the result does not show, and says so.

Next in the series: “Right numbers, wrong answers”. An analyst at Alacena asks how many orders we shipped to Málaga this year, and the same model answers through three different MCP servers. From there, seven ways a naive MCP produces a wrong answer even when the query is valid.

Tell us what you think.

Comments are moderated and will only be visible if they add to the discussion in a constructive way. If you disagree with a point, please, be polite.