Return Results, Not Rows: MCP Design for Time Series

Connecting an LLM to a time-series database through MCP takes an afternoon. We measured where it breaks on 77 heat pumps, and the four tool-design rules that fixed it: results, not rows.
Connecting an LLM to a time-series database through MCP takes an afternoon. The first questions work. Then someone asks about last month, and the agent gets slow, then expensive, then stops with "this conversation is too long to continue".
We measured where that happens. One fleet of 77 heat pumps, one question, eight windows of history from 1 hour to 12 months. Setup A: Claude Opus 5.5 with a raw MCP tool that returns rows. Setup B: the same model with a tool that runs the computation next to the data and returns the result.
What we measured
Setup A answered at 1 hour (1,369 points) in 1 min 54 s, with 268k tokens sent to the model, about $0.5. At 6 hours (13,895 points): 2 min 05 s, 741k tokens, $1.6. At 12 hours (34,179 points) it went over its context limit. Everything past that is extrapolation: roughly 1.5 billion tokens for 12 months.
Setup B stayed between 44k and 59k tokens from 1 hour to 12 months (29.6 million points queried), about $0.1 per question, 5 s at 1 hour and 2 min 46 s at 12 months.
The benchmark measures time, tokens and cost. It does not measure accuracy. The full method and every number are in the benchmark article.
The quieter failure is arithmetic
The context limit is the visible failure. The quieter one is arithmetic. When the model does the maths on rows it can see, you get averages of averages, counters summed as if they were rates, gaps read as zeros, and a different number on each run. None of it is flagged in the answer. We walk through five of these traps with worked examples in why your LLM gets sensor averages wrong.
Row caps do not fix this. Most database MCP servers now cap what they return (100 rows by default, up to 10,000, or a response size limit), which protects the context window but means the model either averages a truncated result or writes the aggregate query itself. We compared five of them in MCP servers for time-series databases compared.
What we changed in the tool design
- Tools return results, not rows. A tool call is a question ("rank these units by efficiency drop over 30 days"), not a SELECT. The response is 10 to 20 computed points plus enough context to explain them.
- The model plans, the engine computes. The LLM chooses what to compute and explains the result. Aggregations, ratios, resampling and comparisons run in a time-series engine next to the data, deterministically.
- Semantics live in the tool, not the prompt. Which signal is the heat output, which one is a counter, what a valid sample is: resolved by the tool, so the model never has to guess among thousands of tag names.
- Read-only, no credentials in the model. The model never connects to the source.
What it costs
This is not free. You need an engine that can scan months of raw data quickly, and you need domain logic per kind of equipment. For a one-off question on a small table, a plain SQL MCP is fine. For fleets and long history, it is the difference between an answer and a context error.
Try the pattern on your own data
Pick a question you can answer by hand, ask it through your current MCP setup over a day, a month and a year, and ask it twice. Note when the rows get capped, when the context runs out, and when the two numbers differ. If you want to compare with an engine doing the computation, there is a free 30-day trial on your own data, read-only, no credit card. We are also happy to compare notes on how you built your own.
Disclosure: we build Spocky, the engine used in setup B.
FAQ
Why does my AI agent stop with "this conversation is too long" on sensor data?
Every row a tool returns becomes tokens in the context. In our benchmark, an LLM reading raw rows from 77 heat pumps used 268k tokens at 1 hour of history and 741k at 6 hours, and went over its context limit from 12 hours.
What does "return results, not rows" mean for an MCP tool?
The tool takes a question, runs the computation next to the data and returns a handful of computed points with enough context to explain them. The model never receives the raw history.
Does a bigger context window solve it?
No. Twelve months of the same fleet would be roughly 1.5 billion tokens by extrapolation, and the arithmetic errors on rows remain even when the rows fit.
When is a plain SQL MCP server enough?
For a one-off question on a small table, or a quick lookup while debugging. Long history, fleets and figures someone will act on need the computation done by an engine, not by the model.
Does the benchmark prove the answers are more accurate?
No. It measures time, tokens and cost. The accuracy argument rests on the mechanism: a deterministic engine computes the figure instead of a model doing arithmetic on the rows it can see.
Get the next one by email
Monthly. AI on industrial time series.