How a Community Builder Queried 90 DeFi Lending Protocols With a Single GraphQL Query

A case study in what becomes possible when standardized Subgraphs and open infrastructure meet AI-native tooling.

TLDR: A community builder named @PaulieB set out to solve one of DeFi's oldest data problems: every lending protocol speaks a different language. By combining Messari's standardized Subgraphs on The Graph's decentralized network with a Model Context Protocol (MCP) server, the result was a single tool that lets any AI agent query live lending data across 90 protocol deployments on 15 chains, in plain English, with no custom adapters required.


The Problem With DeFi Data

Anyone who has tried to compare lending rates across DeFi protocols knows the friction firsthand. Aave calls its markets reserves. Compound calls them markets. MakerDAO has vaults. Rari Fuse has pools of markets. Each protocol has its own schema, its own event structure, and its own terminology.

For a developer trying to build a cross-protocol view of the lending market, that fragmentation historically meant writing a custom adapter for every protocol. Forty protocols meant forty adapters. In practice, almost nobody did it.

The data existed onchain. The transparency was there. What was missing was a standardized way to access it.

The Foundation: Messari's Standardized Subgraphs

Several years ago, The Graph Foundation supported Messari in becoming the ecosystem's first core subgraph developer, with a mandate to build a unified schema across every major DeFi protocol type. For lending protocols specifically, that work produced a canonical data model that every supported protocol now shares.

Under this schema, every lending Subgraph exposes the same entity structure regardless of the underlying protocol. A `LendingProtocol` entity contains TVL, revenue, and user counts. A `Market` entity holds deposit and borrow balances, interest rates, and caps. `InterestRate` objects carry rate, side (lender or borrower), and type (variable, stable, or fixed). `Events` cover deposits, borrows, repays, liquidations, and flash loans. `DailySnapshots` provide historical rollups of all the above.

The same query works across Aave, Compound, MakerDAO, Spark Lend, Venus, and dozens more. The standardization work was already done. It was just waiting to be leveraged in innovative new ways.

What The Graph Community Built

Community builder PaulieB of Graphtronauts took that foundation and extended it in a direction that demonstrates the full potential of the infrastructure. The result is `graph-lending-mcp`, an open-source Model Context Protocol server that fans a single GraphQL query out to live Subgraph endpoints simultaneously, then returns structured, comparable data to any MCP-compatible AI assistant.

The practical effect is straightforward. A user asks Claude to compare USDC borrow rates across all protocols. The MCP fires the same query at every registered Subgraph in parallel, and returns a unified response with rates from Aave v3 on Ethereum, Compound v3, Spark Lend, Venus on BSC, and the rest, side by side, in plain English. No adapters. No custom code per protocol. No GraphQL knowledge required.

The tool currently covers 90 Subgraph deployments across 15 chains, with 65 live at any given time. The 19 tools it exposes map to the full lending lifecycle: listing protocols by TVL, retrieving interest rates across markets, comparing protocols side by side, surfacing recent liquidation events with profit data, pulling daily financial snapshots, and returning open positions for any wallet address across all covered protocols. An escape hatch tool allows raw GraphQL queries for anything the named tools don't cover.

How AI Agents Consume Blockchain Data: Subgraphs vs Substreams

It's worth clarifying how the two of The Graph’s core data products are accessible to AI agents, because they serve different roles depending on what an agent needs to do.

Subgraphs are well-suited for AI agents that need to query existing, hosted data. Because Subgraphs are indexed and served by Indexers on The Graph's decentralized network, an agent only needs an API key to start querying. There's no infrastructure to manage, no data to store, and no indexing logic to write. The agent simply calls the endpoint and gets structured, deterministic data back. This is exactly the pattern PaulieB's MCP uses: the Subgraphs are already live, and the MCP provides a clean interface for an AI agent to query them in natural language.

Substreams serve a different purpose. Rather than querying pre-indexed data that someone else is hosting, Substreams are used when a team needs to build and maintain their own high-performance data pipeline, typically at larger scale, with more complex transformations, or with data that doesn't yet exist in a Subgraph. An agent itself wouldn't typically run Substreams directly. Instead, a platform or team uses Substreams to process and store blockchain data, then exposes that stored data through an API that agents can query.

Both products provide deterministic data, meaning two independent Indexers running the same Subgraph or Substreams module will produce matching outputs assuming they get the same raw data inputs. That consistency is what makes the data reliable enough for AI agents to reason over at scale.

Substreams in Practice: How Platforms Power AI Agents at Scale

The most compelling use of Substreams in an AI context isn't an individual agent querying a stream directly. It's a platform that uses Substreams to ingest and store large volumes of blockchain data, then makes that processed data available for AI agents to work with.

Theoriq illustrates this model clearly. The protocol runs a decentralized network of AI agent swarms designed to optimize DeFi liquidity, executing trades, provisioning liquidity, and rebalancing positions based on live market conditions. For those agents to function autonomously onchain, they need fast, structured data. Substreams provides that foundation.

Theoriq's first live system, the Onchain Liquidity Provisioning Swarm, optimizes Uniswap V3 positions on Base. An Observer Agent consumes Substreams data in real time, tracking granular events including balance changes, mints, burns, and swaps, then triggers downstream actions like LP rebalancing or trade execution. The results were significant: time-to-market for new liquidity pool support dropped from weeks to days, and infrastructure costs fell by 70%.

As Ethan Jackson, Co-Founder and Head of Research at Theoriq, described it: Substreams gives agents direct access to clean, real-time onchain data, powering their ability to make fast, intelligent financial decisions.

This is an important distinction for builders thinking about how to structure an AI-native application. If the goal is to let an agent query existing protocol data on demand, Subgraphs are the right starting point. If the goal is to build a platform where agents operate over a large, custom dataset that needs to be continuously maintained and updated, Substreams are the infrastructure layer that makes that possible.

What This Demonstrates About The Graph's Infrastructure

The `graph-lending-mcp` project is notable not just as a tool but as a proof of concept for a broader model of how The Graph's decentralized network creates compounding value.

The Subgraphs that power it were built once, with a standardized schema, and published to The Graph's decentralized network where Indexers serve them with redundancy and no single point of failure. PaulieB didn't need to set up or manage data infrastructure. The data layer was already there.

The MCP layer on top of that data is what makes it accessible to AI agents. Model Context Protocol, Anthropic's open standard for connecting AI models to external tools, provides the interface. The Graph's indexed Subgraphs provide the deterministic, high-quality data. Together they produce something that didn't previously exist: an AI assistant that can reason over live, structured DeFi lending data across the entire market, queried in natural language.

This pattern, a standardized indexed data layer on The Graph's decentralized network accessed through an MCP interface, is reproducible across any protocol category. Lending is where PaulieB started. The same approach applies to DEXs, prediction markets, governance data, and beyond.

Building on the Work

The `graph-lending-mcp` server is open source and available on npm. Getting started requires a free Graph API key from Subgraph Studio, which takes a few minutes to set up. From there, any MCP-compatible AI assistant can begin querying live lending data across the covered protocols immediately.

For builders interested in extending the tool or applying the same pattern to other protocol categories, the source is available at github.com/PaulieB14/graph-lending-mcp. The standardized Subgraph schema that underpins it is documented by Messari and covers lending, DEXs, and other major DeFi protocol types.

The data layer is open. The infrastructure is live. What gets built on top of it is up to the community.

About The Graph

The Graph is the leading indexing and query protocol powering the decentralized internet. Since launching in 2018, it has empowered tens of thousands of developers to effortlessly build Subgraphs and leverage Substreams across countless blockchains, including Ethereum, Solana, Arbitrum, Optimism, Base, Polygon, Celo, Soneium, and Avalanche. With powerful tools like Substreams and Token API, The Graph delivers high-performance, real-time access to onchain data. From low-latency indexing to rapid token data, it serves as the premier solution for building composable, data drive dapps.

Discover more about how The Graph is shaping the future of decentralized physical infrastructure networks (DePIN) and stay connected with the community. Follow The Graph on X, LinkedIn, Instagram, Facebook, Reddit, Farcaster  and Medium. Join the community on The Graph’s Telegram, join technical discussions on The Graph’s Discord.


Categories
Graph UpdatesRecommended
Published
April 21, 2026

The Graph Foundation

View all blog posts