|
| 1 | +# AGENTS.md — The Graph |
| 2 | + |
| 3 | +> Machine-readable guide for autonomous AI agents that want to access blockchain data through The Graph at runtime. The Graph indexes and serves on-chain data across 60+ networks. Agents can consume it three ways: native MCP servers (recommended) and an x402-enabled Subgraph gateway. |
| 4 | +
|
| 5 | +**Audience:** AI agents, LLM tools, and autonomous systems integrating The Graph as a data source. **Last updated:** 2026-05-29 **Related files:** [/llms.txt](https://thegraph.com/llms.txt) · [/pricing.md](https://thegraph.com/pricing.md) · [/robots.txt](https://thegraph.com/robots.txt) |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Recommended: MCP server |
| 10 | + |
| 11 | +The Graph publishes Model Context Protocol (MCP) servers — the preferred interface for agents. They work with Claude, Cursor, Cline, and any MCP-compatible client. |
| 12 | + |
| 13 | +### Subgraph MCP |
| 14 | + |
| 15 | +Search, inspect, and query 15,000+ Subgraphs on The Graph Network in natural language. |
| 16 | + |
| 17 | +- **Endpoint:** `https://subgraphs.mcp.thegraph.com/sse` |
| 18 | +- **Transport:** SSE (remote) |
| 19 | +- **Auth:** `Authorization: Bearer <GATEWAY_API_KEY>` — get a Gateway API key from [Subgraph Studio](https://thegraph.com/studio/) |
| 20 | +- **Docs:** https://thegraph.com/docs/en/ai-suite/subgraph-mcp/introduction/ |
| 21 | + |
| 22 | +**Tools:** | Tool | Purpose | |---|---| | `search_subgraphs_by_keyword` | Find Subgraphs by protocol/keyword | | `get_top_subgraph_deployments` | Rank deployments for a keyword by activity | | `get_deployment_30day_query_counts` | Check 30-day query volume (verify a deployment is live before querying) | | `get_schema_by_subgraph_id` / `get_schema_by_deployment_id` / `get_schema_by_ipfs_hash` | Fetch the GraphQL schema | | `execute_query_by_subgraph_id` / `execute_query_by_deployment_id` / `execute_query_by_ipfs_hash` | Run a GraphQL query against a deployment | |
| 23 | + |
| 24 | +**Recommended agent workflow:** identify the protocol → `search_subgraphs_by_keyword` → `get_deployment_30day_query_counts` to confirm an active deployment → `get_schema_by_*` → build and `execute_query_by_*`. |
| 25 | + |
| 26 | +**Cursor / Claude config:** |
| 27 | + |
| 28 | +```json |
| 29 | +{ |
| 30 | + "mcpServers": { |
| 31 | + "subgraph": { |
| 32 | + "command": "npx", |
| 33 | + "args": ["mcp-remote", "--header", "Authorization:${AUTH_HEADER}", "https://subgraphs.mcp.thegraph.com/sse"], |
| 34 | + "env": { "AUTH_HEADER": "Bearer GATEWAY_API_KEY" } |
| 35 | + } |
| 36 | + } |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +### Subgraphs via Subgraph (GraphQL) gateway |
| 41 | + |
| 42 | +Query any Subgraph on the decentralized network directly over GraphQL. |
| 43 | + |
| 44 | +- **URL pattern:** https://gateway.thegraph.com/api/<API_KEY>/subgraphs/id/<SUBGRAPH_ID> |
| 45 | +- **Method:** POST (GraphQL). If you get a 405 on GET, switch to POST. |
| 46 | +- **Auth:** API key from Subgraph Studio embedded in the URL path |
| 47 | +- **Discovery:** find <SUBGRAPH_ID> via Graph Explorer or the Subgraph MCP search_subgraphs_by_keyword tool |
| 48 | +- **Docs:** https://thegraph.com/docs/en/subgraphs/querying/from-an-application/ |
| 49 | +- **Skills:** https://thegraph.com/docs/en/subgraphs/skills/ |
| 50 | + |
| 51 | +Example: |
| 52 | + |
| 53 | +``` |
| 54 | +curl -X POST \ |
| 55 | + "https://gateway.thegraph.com/api/<API_KEY>/subgraphs/id/<SUBGRAPH_ID>" \ |
| 56 | + -H "Content-Type: application/json" \ |
| 57 | + -d '{"query":"{ tokens(first: 5) { id symbol } }"}' |
| 58 | +``` |
| 59 | + |
| 60 | +### Substreams via The Graph Market |
| 61 | + |
| 62 | +High-throughput, real-time streaming data pipelines. Served via a provider marketplace; discovery and packages are MCP-accessible. |
| 63 | + |
| 64 | +- **Marketplace:** https://thegraph.market |
| 65 | +- **Substreams registry / discovery:** Substreams.dev lets you search packages, inspect modules, and get sink configs programmatically |
| 66 | +- **Docs:** https://thegraph.com/docs/en/substreams/quick-start/ |
| 67 | +- **Skills:** https://thegraph.com/docs/en/substreams/skills/ |
| 68 | + |
| 69 | +### Authentication summary |
| 70 | + |
| 71 | +| Surface | Credential | Where to get it | |
| 72 | +| ------------------------ | ------------------------ | ------------------------- | |
| 73 | +| Subgraph MCP | Gateway API key (Bearer) | Subgraph Studio | |
| 74 | +| Subgraph GraphQL gateway | API key (in URL) | Subgraph Studio | |
| 75 | +| Substreams | JWT access token | thegraph.market dashboard | |
| 76 | + |
| 77 | +### Rate limits & cost |
| 78 | + |
| 79 | +Pricing and rate limits are documented in /pricing.md. Subgraph queries: 100,000/month free, then $2 per 100,000. Requests over a plan's rate limit return HTTP 429. |
| 80 | + |
| 81 | +### Support |
| 82 | + |
| 83 | +Docs: https://thegraph.com/docs/en/ AI Suite overview: https://thegraph.com/docs/en/ai-suite/ai-introduction/ Discord: https://discord.gg/graphprotocol |
0 commit comments