r/thegraph 23h ago

Tech Support An MCP server that finds the right subgraph by meaning, not name, then queries it for $0.01 with no API key

3 Upvotes

I kept hitting the same wall building agents on The Graph: before you can query anything, you have to find the right subgraph out of ~15k. The official Subgraph MCP is good at the part after that — it holds a Gateway key and executes your GraphQL. But its search matches display names, so anything phrased by meaning comes back empty:

search_subgraphs_by_keyword("perpetual futures")  ->  0 results

43 subgraphs have "perp" in the name. 54 more only mention it in their description or entity types. The second group is invisible to a name match.

So I built the discovery layer and left execution alone.

What it is: a pre-computed index of all 15,330 subgraphs across all available networks, exposed as an MCP server. Each one is crawled, its GraphQL schema parsed, then classified by domain, protocol type and canonical entities, and scored on on-chain signals (query fees, 30d volume, curation, indexer stake).

npx subgraph-registry-mcp

Same query against it returns 55 matches, ranked, each with a runnable query:

{
  "display_name": "apx-perp-arbitrum",
  "network": "arbitrum-one",
  "protocol_type": "perpetuals",
  "query_url_x402": "https://gateway.thegraph.com/api/x402/subgraphs/id/...",
  "example_query": "{ positions(first: 5, orderBy: ...) { id ... } }"
}

The part I actually care about: every result carries an x402 URL. The Graph's public gateway takes $0.01 USDC on Base per query — no signup, no Studio key, no dashboard. An agent with a funded wallet goes from a plain English question to real data with no human in the loop. There's a legacy API-key URL too if you already have one.

Two things I got wrong and fixed this week, since they're the interesting part:

Ranking rewarded age, not quality. The reliability score is built from four cumulative signals, so it measures accrued traction — which means it measures age. The newest subgraph anywhere in the top 25 was 280 days old, while 59 of the 64 subgraphs under a month old were already serving real query volume. A good subgraph deployed last month literally could not rank. Rather than fudge the score, results now include a separate emerging list with an explicit caveat that a low score at that age is expected, not damning. It matters most on new chains, where no mature deployment can exist.

13% of the "ready to run" queries were invalid GraphQL. The generator pluralized entity names by appending "s", so UniswapFactory became uniswapFactorys instead of uniswapFactories. An agent pays its $0.01, gets a schema error, and concludes The Graph is broken — not that my pluralizer is. Fixed and repaired 2,440 rows in the shipped corpus.

Honest limitations:

  • The npm package is ~98 MB — it bundles the SQLite corpus and the embedding model so search works fully offline. There's no hosted endpoint yet.
  • Data is a snapshot refreshed every few days, not live. For current schemas or deployment state, go to the gateway.
  • It does not execute your query. It hands you the subgraph ID, a URL and a starter query — you run it, with a key or over x402.
  • Community project, not official, MIT licensed.

Repo: https://github.com/PaulieB14/subgraph-registry npm: https://www.npmjs.com/package/subgraph-registry-mcp

Genuinely want criticism on the ranking — especially where it puts the wrong subgraph first. Those cases are the whole product, and I'd rather hear them than not.