How do AI agents access onchain data?
Updated August 2026
Through an indexed, queryable layer rather than the blockchain directly. An agent needs to ask questions like "what has this wallet done recently" — which is a search, not a point lookup, and therefore not something raw RPC can answer.
In practice that means putting indexed data behind an interface the agent can call: an MCP server, an API, or a database it can query.
Why can't an agent just call RPC?
Three reasons, and they compound.
The wrong shape of question. RPC answers "what is the state of X right now." Agents ask open-ended, historical, aggregate questions. Answering those over RPC means many calls and client-side filtering — expensive in tokens and latency, and unreliable.
Undecoded data. RPC returns binary. Without the ABI or IDL applied, an agent sees bytes rather than "a transfer of 500 USDC." It cannot reason about what it cannot read.
No aggregation. "How much volume did this pool do last week" cannot be expressed as an RPC call at all. Something has to compute it first.
What does a good setup look like?
| Layer | Role |
|---|---|
| Extraction | Get complete chain data, including internal transactions and state changes |
| Transformation | Decode and shape it into meaningful records |
| Storage | A database the agent's tooling can query |
| Interface | MCP server, API, or SQL access the agent calls |
The first two are ordinary indexing — Substreams into a database. The interesting design work is in the last layer: what questions can the agent actually ask, and how do you keep it from constructing queries that scan everything.
Why does data completeness matter more for agents?
Because an agent cannot tell that something is missing.
A human querying transfers and seeing nothing for a wallet might suspect the pipeline is only capturing event logs. An agent will report that no transfers occurred, confidently, and then reason from that. Value moved by internal calls, state changes, and balance adjustments never appear in logs — so a log-based pipeline gives an agent a partial picture it will treat as complete.
Extraction capturing full execution detail — call trees, state changes, balance changes — matters more here than in a human-facing dashboard, precisely because there is no one to notice the gap.
What about freshness?
Agents asking about "recent" activity need data close to the chain head, which means a streaming pipeline rather than a periodic batch job. It also means being explicit about finality: an agent should not act on data from a block that might be reorged, and it has no intuition about this unless your interface tells it.
Frequently asked questions
Can an agent query the blockchain without an indexer? For simple current-state lookups, yes. For anything historical or aggregated, it needs an indexed layer.
What's the best interface for an agent? Whatever fits your stack — an API, MCP, or a well-scoped SQL interface all work if you constrain what can be queried.
Does the agent need the raw data or a summary? Usually a shaped, filtered result. Passing raw blocks wastes context and invites errors.
Get an API key at thegraph.market — no personal information required.
Related: What is an MCP server for blockchain data? · Can an LLM query blockchain data directly? · How do I stream onchain data to a database?