NOTES · NOV 9, 2026 · BY TECH BENDERS

How we built the Open Data Agent

A Claude agent that queries public data in real time without the server paying for a single token. The architecture, nine tools and the trade-offs.

Most AI features have a hidden question inside them: who pays for the thinking? When a company puts an agent in front of its users, every question those users ask turns into model tokens, and those tokens land on the company's bill. For an internal tool that can be fine. For a public service built on public data, it can sink the project.

The Open Data Agent is our answer to that question. It is an architecture that lets a Claude agent query public data in real time (mobility, air quality, safety) without the server that hosts the connection ever seeing or paying for a single model token. It is not a client case: it is a proof of technical range, built on open data from Mexico City. This post explains how it works, which decisions mattered, and what we gave up to get there.

The idea in one paragraph

The reasoning always lives in the account of the person using the assistant. Our server never calls a model. It only does two things: it translates a structured request into a call to a public data source, and it returns the result as JSON. The infrastructure bill (a small server and the public sources, which cost nothing) and the intelligence bill (the model tokens) never mix, and neither side pays for the other.

Why this works: the shape of MCP

The architecture rests on the Model Context Protocol (MCP), an open protocol for connecting AI applications to tools and data. MCP separates three roles:

  • The host is the AI application the person uses, such as Claude Desktop or Claude Code. It runs the model under the person's own account and decides when to call a tool.

  • The client lives inside the host and keeps one connection to each server.

  • The server exposes tools, resources and prompts. It can be a local process or a remote service.

One of the protocol's design principles matters a lot here: servers should not be able to read the whole conversation. In the specification's words, servers "receive only necessary contextual information" and the "full conversation history stays with the host." So our server receives a tool name and its parameters, and nothing else. It never sees the conversation, and it never needs a model API key.

MCP also has a feature called sampling, which lets a server ask the client's model for a completion. We deliberately do not use it. Even if we did, the specification routes those requests through the client, with a human who can deny them, so the cost would still sit with the person's account.

The nine tools

The agent sees nine tools. The model chooses among them based on what the person asks.

  1. list_datasets searches the catalog of the city's open data portal, with free text and pagination.

  2. describe_dataset returns the real schema of a dataset: columns, types and total rows.

  3. query_records fetches rows using structured parameters (filters, selected columns, ordering, limit and offset) that the server turns into a query against the portal's SQL search endpoint.

  4. aggregate runs the grouping on the portal's side, so the agent receives counts instead of thousands of rows.

  5. crime_hotspots is a recipe on top of the public crime records: top neighborhoods or boroughs, filtered by year, borough or category.

  6. ecobici_status reads the live feed of the public bike share system (published in GBFS, the open standard for bike share data): bikes and free docks per station, with search by radius.

  7. air_quality_now returns the most recent air quality index per zone.

  8. denue_near lists economic units from the national business directory around a point. It is the only one that needs a token, and that token is free.

  9. cache_stats is a debugging tool: how many responses are cached and with what lifetime.

The server also publishes two short guides as resources, which the assistant can read by address when it needs context on how a dataset is structured.

The decisions that mattered

Keep results small

"The server pays no tokens" does not mean tokens are free. Every row the server returns becomes input tokens on the person's account. So the tools are designed to return as little as possible: aggregation happens on the portal, queries select only the columns needed, and every query has a limit. A good tool here is one that answers the question with a small, precise payload.

This is the same discipline that keeps any agent affordable. The architecture moves the bill to the right place; the tool design keeps the bill small once it gets there.

Describe before you query

Models guess column names when they do not know them, and guesses produce empty results or wrong answers. The recommended flow is to call describe_dataset first so the model sees the real schema before it queries. It costs one extra call and saves several failed ones.

Structured parameters instead of free-form SQL

The portal accepts SQL, but the tool does not ask the model to write raw SQL. It takes structured parameters and builds the query on the server. Structured inputs are easier to validate, easier to log and harder to misuse. The underlying search endpoint also accepts only a single SELECT statement and enforces its own timeout and row cap, according to the CKAN DataStore documentation, which gives a second layer of protection.

Every tool reads, none writes

All nine tools read. There is nothing to create, update or delete. That keeps the blast radius of a confused model, or a malicious prompt, very small.

Cache with a lifetime

Public sources are shared infrastructure. Hammering them helps nobody, and many of them update hourly or daily anyway. The server caches responses for a limited time, which reduces load and speeds up repeated questions. The trade-off is explicit: a cached answer can be a few minutes old. For live bike availability that window has to be short; for a catalog search it can be longer.

Freshness is data, not a footnote

Open data varies a lot in how recently it was updated. The public demo of this project ranks datasets on five dimensions (impact, data, feasibility, accessibility and freshness), and freshness is calculated against the current date every time the dashboard opens. An agent that answers with stale data and does not say so is worse than no agent at all.

What we gave up

Every architecture is a set of trade-offs. These are ours.

  • We do not control the model. The reasoning happens in the person's assistant, so we cannot pin a model, tune a prompt server-side or guarantee how the answer is phrased. What we control is the quality of the tools: their names, descriptions, parameters and outputs. That turns tool design into the main lever.

  • The person needs an MCP-capable assistant. This pattern fits people who already work in an AI assistant. It does not fit an anonymous visitor on a public website with no account.

  • Tokens still cost someone. We moved the cost to the person asking the question, which is fair for many use cases, but it is not zero. Small payloads are how we respect that.

  • Public sources have their own limits. Availability, rate limits and schemas change without notice. The server has to fail with clear messages, and the cache cannot hide outages forever.

When this pattern fits

Use it when the data is public or already belongs to the person asking, when the users already work inside an AI assistant, and when you want the cost of intelligence to scale with the people who use it instead of with your infrastructure. Avoid it when you need a fixed, branded experience for anonymous users, or when every answer must follow a script you control end to end.

In both cases, the human stays in the loop: every tool call is visible in the conversation, with its parameters, and the person decides what to do with the answer.

Build one yourself

In the workshop Build an agent that queries open data without paying for tokens we build, step by step, an MCP server like this one, covering tools, contracts, limits and keeping cost with the client. The path AI agents in production goes further, and if you want an architecture like this for your own data, let's talk.

SEC. 06 · THE STUDIO

Why this studio exists

For decades, building software belonged to technical profiles with years of training, and getting a digital product into the real world took companies months or years. No-code and AI have narrowed that gap, but the knowledge is still held by a few.

Tech Benders exists to open that knowledge up, so business teams and non-technical teams can put their ideas into production with the right technical decisions behind them. AI does what you ask of it. Without a technical base, what it builds may not scale with your company’s ecosystem, and its costs can run away over time.

The team knows the pains of large organizations and the speed at which they have to move. It brings solution architecture, data engineering, product built end to end from back end to front end, and daily work with AI. Software that solves what you need in days, not months, with the cost of AI kept in check.

Founders

The studioRead about Tech Benders →

Write to ushi@techbenders.io

Made with Wislab