subgraph-registry-mcp 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -2
- package/data/registry.db +0 -0
- package/package.json +2 -2
- package/src/index.js +50 -12
package/README.md
CHANGED
|
@@ -18,8 +18,48 @@ Agents querying The Graph need to discover and select the right subgraph before
|
|
|
18
18
|
2. **Fetches** the GraphQL schema for every deployment
|
|
19
19
|
3. **Classifies** each subgraph by domain, protocol type, canonical entities, and schema family
|
|
20
20
|
4. **Scores** reliability using on-chain signals (query fees, volume, curation, stake)
|
|
21
|
-
5. **
|
|
22
|
-
6. **
|
|
21
|
+
5. **Returns x402 + legacy query URLs** — agents can pay $0.01 USDC on Base per query (no API key) or use a Studio key
|
|
22
|
+
6. **Publishes** as SQLite database + REST API + MCP server
|
|
23
|
+
7. **Generates** visual dashboards and bot-readable category files (auto-updated with each sync)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Querying with x402 (no API key)
|
|
28
|
+
|
|
29
|
+
Every result includes `query_url_x402` alongside the legacy `query_url`. The Graph's public x402 gateway (live since 2026-05-08) accepts **$0.01 USDC on Base** per query with zero signup.
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
// An x402-native agent — discovery to data in two calls
|
|
33
|
+
const { recommendations } = await mcp.call("recommend_subgraph", {
|
|
34
|
+
goal: "find DEX trades on Arbitrum",
|
|
35
|
+
});
|
|
36
|
+
const top = recommendations[0];
|
|
37
|
+
|
|
38
|
+
// POST your GraphQL query. The first call returns HTTP 402 with a
|
|
39
|
+
// base64 `payment-required` header; the x402 client signs the
|
|
40
|
+
// EIP-3009 USDC transfer on Base and retries automatically.
|
|
41
|
+
const data = await x402Fetch(top.query_url_x402, {
|
|
42
|
+
method: "POST",
|
|
43
|
+
body: JSON.stringify({ query: "{ swaps(first: 5) { id amountUSD } }" }),
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Pricing manifest returned per subgraph:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"amount_usd": 0.01,
|
|
52
|
+
"asset": "USDC",
|
|
53
|
+
"asset_contract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
54
|
+
"chain": "base",
|
|
55
|
+
"network": "eip155:8453",
|
|
56
|
+
"pay_to": "0x79DC34E41B2b591078d3dE222C43EcaaBD52FcCB",
|
|
57
|
+
"scheme": "exact",
|
|
58
|
+
"asset_transfer_method": "eip3009"
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Client libraries: [`@graphprotocol/client-x402`](https://www.npmjs.com/package/@graphprotocol/client-x402), `x402-fetch`, or any generic x402 wrapper.
|
|
23
63
|
|
|
24
64
|
---
|
|
25
65
|
|
package/data/registry.db
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "subgraph-registry-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"mcpName": "io.github.PaulieB14/subgraph-registry-mcp",
|
|
5
|
-
"description": "MCP server for agent-friendly subgraph discovery on The Graph Network. 14,733 classified subgraphs with query
|
|
5
|
+
"description": "MCP server for agent-friendly subgraph discovery on The Graph Network. 14,733 classified subgraphs with x402 query URLs ($0.01 USDC on Base, no API key required), reliability scoring, and protocol classification.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
8
|
"subgraph-registry-mcp": "src/index.js"
|
package/src/index.js
CHANGED
|
@@ -50,6 +50,32 @@ const EXPECTED_DB_SHA256 =
|
|
|
50
50
|
// locally and know what you're doing — never set in agent-runtime defaults).
|
|
51
51
|
const SKIP_VERIFY = process.env.SUBGRAPH_REGISTRY_SKIP_VERIFY === "1";
|
|
52
52
|
|
|
53
|
+
// ── x402 gateway constants ─────────────────────────────────
|
|
54
|
+
// The Graph's public x402 gateway (live since 2026-05-08) lets agents pay
|
|
55
|
+
// per-query in USDC on Base without any API key. POST GraphQL to query_url_x402
|
|
56
|
+
// and the gateway returns HTTP 402 with a payment manifest; an x402 client
|
|
57
|
+
// (e.g. @graphprotocol/client-x402, x402-fetch) signs the EIP-3009 USDC
|
|
58
|
+
// transfer and retries automatically.
|
|
59
|
+
const X402_GATEWAY_BASE = "https://gateway.thegraph.com/api/x402";
|
|
60
|
+
const X402_PRICING = {
|
|
61
|
+
amount_usd: 0.01,
|
|
62
|
+
asset: "USDC",
|
|
63
|
+
asset_contract: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base
|
|
64
|
+
chain: "base",
|
|
65
|
+
network: "eip155:8453",
|
|
66
|
+
pay_to: "0x79DC34E41B2b591078d3dE222C43EcaaBD52FcCB", // Graph x402 gateway
|
|
67
|
+
scheme: "exact",
|
|
68
|
+
asset_transfer_method: "eip3009",
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
function buildQueryEndpoints(subgraphId) {
|
|
72
|
+
return {
|
|
73
|
+
query_url: `https://gateway.thegraph.com/api/[api-key]/subgraphs/id/${subgraphId}`,
|
|
74
|
+
query_url_x402: `${X402_GATEWAY_BASE}/subgraphs/id/${subgraphId}`,
|
|
75
|
+
pricing: X402_PRICING,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
53
79
|
// ── Download DB from GitHub if missing ─────────────────────
|
|
54
80
|
|
|
55
81
|
function sha256OfFile(path) {
|
|
@@ -210,7 +236,7 @@ function searchSubgraphs({
|
|
|
210
236
|
entity_count: r.entity_count,
|
|
211
237
|
canonical_entities: JSON.parse(r.canonical_entities),
|
|
212
238
|
powered_by_substreams: Boolean(r.powered_by_substreams),
|
|
213
|
-
|
|
239
|
+
...buildQueryEndpoints(r.id),
|
|
214
240
|
});
|
|
215
241
|
if (results.length >= limit) break;
|
|
216
242
|
}
|
|
@@ -218,7 +244,7 @@ function searchSubgraphs({
|
|
|
218
244
|
return {
|
|
219
245
|
total: results.length,
|
|
220
246
|
subgraphs: results,
|
|
221
|
-
query_instructions: "
|
|
247
|
+
query_instructions: "Two ways to query: (a) RECOMMENDED — POST GraphQL to query_url_x402 and pay $0.01 USDC on Base per query via x402 (no API key required; gateway returns HTTP 402 with a payment manifest, use an x402 client like @graphprotocol/client-x402 to sign and retry). (b) LEGACY — replace [api-key] in query_url with a Graph API key from https://thegraph.com/studio/apikeys/. Call get_subgraph_detail first for the schema.",
|
|
222
248
|
};
|
|
223
249
|
}
|
|
224
250
|
|
|
@@ -304,7 +330,7 @@ function recommendSubgraph({ goal, chain = "" }) {
|
|
|
304
330
|
reliability_score: r.reliability_score,
|
|
305
331
|
ipfs_hash: r.ipfs_hash,
|
|
306
332
|
canonical_entities: JSON.parse(r.canonical_entities),
|
|
307
|
-
|
|
333
|
+
...buildQueryEndpoints(r.id),
|
|
308
334
|
});
|
|
309
335
|
if (recommendations.length >= 5) break;
|
|
310
336
|
}
|
|
@@ -333,12 +359,24 @@ function getSubgraphDetail({ subgraph_id }) {
|
|
|
333
359
|
if (!result.description && result.auto_description) {
|
|
334
360
|
result.description = result.auto_description;
|
|
335
361
|
}
|
|
336
|
-
|
|
362
|
+
const endpoints = buildQueryEndpoints(result.id);
|
|
363
|
+
result.query_url = endpoints.query_url;
|
|
364
|
+
result.query_url_x402 = endpoints.query_url_x402;
|
|
365
|
+
result.pricing = endpoints.pricing;
|
|
337
366
|
result.query_instructions = {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
367
|
+
recommended: "x402",
|
|
368
|
+
x402: {
|
|
369
|
+
url: endpoints.query_url_x402,
|
|
370
|
+
payment: endpoints.pricing,
|
|
371
|
+
flow: "POST GraphQL to url. Gateway returns HTTP 402 with a base64 payment-required header containing the payment manifest. Sign $0.01 USDC on Base with an x402 client and retry. No API key, no signup.",
|
|
372
|
+
client_libraries: ["@graphprotocol/client-x402", "x402-fetch"],
|
|
373
|
+
example_query: "{ pools(first: 5, orderBy: totalValueLockedUSD, orderDirection: desc) { id token0 { symbol } token1 { symbol } totalValueLockedUSD } }",
|
|
374
|
+
},
|
|
375
|
+
api_key_legacy: {
|
|
376
|
+
url: endpoints.query_url,
|
|
377
|
+
flow: "Get an API key from https://thegraph.com/studio/apikeys/, replace [api-key] in the url, then POST GraphQL.",
|
|
378
|
+
},
|
|
379
|
+
schema_hint: "Use the all_entities field above to see what entities and fields are available to query.",
|
|
342
380
|
};
|
|
343
381
|
return result;
|
|
344
382
|
}
|
|
@@ -370,7 +408,7 @@ const TOOLS = [
|
|
|
370
408
|
{
|
|
371
409
|
name: "search_subgraphs",
|
|
372
410
|
description:
|
|
373
|
-
"Search and filter the classified subgraph registry (15,500+ subgraphs). Filter by domain (defi, nfts, dao, gaming, identity, infrastructure, social, analytics), network (mainnet, arbitrum-one, base, matic, bsc, optimism, avalanche), protocol_type (dex, lending, bridge, staking, options, perpetuals, nft-marketplace, yield-aggregator, governance, name-service), canonical entity type (liquidity_pool, trade, token, position, vault, loan, collateral, liquidation, nft_collection, nft_item, nft_sale, proposal, delegate, domain_name, account, transaction, daily_snapshot, hourly_snapshot), or free-text keyword. Returns subgraphs ranked by reliability score
|
|
411
|
+
"Search and filter the classified subgraph registry (15,500+ subgraphs). Filter by domain (defi, nfts, dao, gaming, identity, infrastructure, social, analytics), network (mainnet, arbitrum-one, base, matic, bsc, optimism, avalanche), protocol_type (dex, lending, bridge, staking, options, perpetuals, nft-marketplace, yield-aggregator, governance, name-service), canonical entity type (liquidity_pool, trade, token, position, vault, loan, collateral, liquidation, nft_collection, nft_item, nft_sale, proposal, delegate, domain_name, account, transaction, daily_snapshot, hourly_snapshot), or free-text keyword. Returns subgraphs ranked by reliability score. Each result includes query_url_x402 (POST GraphQL and pay $0.01 USDC on Base per query — no API key needed) and a legacy query_url (Studio API key required).",
|
|
374
412
|
inputSchema: {
|
|
375
413
|
type: "object",
|
|
376
414
|
properties: {
|
|
@@ -387,7 +425,7 @@ const TOOLS = [
|
|
|
387
425
|
{
|
|
388
426
|
name: "recommend_subgraph",
|
|
389
427
|
description:
|
|
390
|
-
"Given a natural-language goal like 'find DEX trades on Arbitrum' or 'get lending liquidation data', returns the best matching subgraphs with reliability scores
|
|
428
|
+
"Given a natural-language goal like 'find DEX trades on Arbitrum' or 'get lending liquidation data', returns the best matching subgraphs with reliability scores. Automatically infers domain and protocol type from the goal. Each result includes query_url_x402 (preferred — POST GraphQL, pay $0.01 USDC on Base per query, no API key) and a legacy query_url for Studio-key flows.",
|
|
391
429
|
inputSchema: {
|
|
392
430
|
type: "object",
|
|
393
431
|
properties: {
|
|
@@ -400,7 +438,7 @@ const TOOLS = [
|
|
|
400
438
|
{
|
|
401
439
|
name: "get_subgraph_detail",
|
|
402
440
|
description:
|
|
403
|
-
"Get full classification detail for a specific subgraph by its subgraph ID or IPFS hash. Returns domain, protocol type, canonical entities, all entity names with field counts, reliability score, signal data, query
|
|
441
|
+
"Get full classification detail for a specific subgraph by its subgraph ID or IPFS hash. Returns domain, protocol type, canonical entities, all entity names with field counts, reliability score, signal data, both query URLs (x402 and legacy), the x402 pricing manifest ($0.01 USDC on Base), and step-by-step instructions for both query paths.",
|
|
404
442
|
inputSchema: {
|
|
405
443
|
type: "object",
|
|
406
444
|
properties: {
|
|
@@ -429,7 +467,7 @@ const HANDLERS = {
|
|
|
429
467
|
|
|
430
468
|
function createServer() {
|
|
431
469
|
const server = new Server(
|
|
432
|
-
{ name: "subgraph-registry", version: "0.
|
|
470
|
+
{ name: "subgraph-registry", version: "0.6.0" },
|
|
433
471
|
{ capabilities: { tools: {} } }
|
|
434
472
|
);
|
|
435
473
|
|