subgraph-registry-mcp 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +46 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "subgraph-registry-mcp",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "MCP server for agent-friendly subgraph discovery on The Graph Network. 15,500+ classified subgraphs with reliability scoring.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -118,6 +118,8 @@ function searchSubgraphs({
118
118
  }
119
119
 
120
120
  const where = conditions.length ? `WHERE ${conditions.join(" AND ")}` : "";
121
+ // Over-fetch to allow dedup by IPFS hash (same deployment, different subgraph IDs)
122
+ const fetchLimit = limit * 3;
121
123
  const sql = `
122
124
  SELECT id, display_name, description, auto_description, domain, protocol_type, network,
123
125
  reliability_score, ipfs_hash, entity_count, canonical_entities,
@@ -127,23 +129,31 @@ function searchSubgraphs({
127
129
  ORDER BY reliability_score DESC
128
130
  LIMIT ?
129
131
  `;
130
- params.push(limit);
132
+ params.push(fetchLimit);
131
133
 
132
134
  const rows = getDb().prepare(sql).all(...params);
133
- const results = rows.map((r) => ({
134
- id: r.id,
135
- display_name: r.display_name,
136
- description: (r.description || r.auto_description || "").slice(0, 300),
137
- domain: r.domain,
138
- protocol_type: r.protocol_type,
139
- network: r.network,
140
- reliability_score: r.reliability_score,
141
- ipfs_hash: r.ipfs_hash,
142
- entity_count: r.entity_count,
143
- canonical_entities: JSON.parse(r.canonical_entities),
144
- powered_by_substreams: Boolean(r.powered_by_substreams),
145
- query_url: `https://gateway.thegraph.com/api/[api-key]/subgraphs/id/${r.id}`,
146
- }));
135
+ // Dedup by IPFS hash — keep highest reliability per deployment
136
+ const seenIpfs = new Set();
137
+ const results = [];
138
+ for (const r of rows) {
139
+ if (r.ipfs_hash && seenIpfs.has(r.ipfs_hash)) continue;
140
+ if (r.ipfs_hash) seenIpfs.add(r.ipfs_hash);
141
+ results.push({
142
+ id: r.id,
143
+ display_name: r.display_name,
144
+ description: (r.description || r.auto_description || "").slice(0, 300),
145
+ domain: r.domain,
146
+ protocol_type: r.protocol_type,
147
+ network: r.network,
148
+ reliability_score: r.reliability_score,
149
+ ipfs_hash: r.ipfs_hash,
150
+ entity_count: r.entity_count,
151
+ canonical_entities: JSON.parse(r.canonical_entities),
152
+ powered_by_substreams: Boolean(r.powered_by_substreams),
153
+ query_url: `https://gateway.thegraph.com/api/[api-key]/subgraphs/id/${r.id}`,
154
+ });
155
+ if (results.length >= limit) break;
156
+ }
147
157
 
148
158
  return {
149
159
  total: results.length,
@@ -215,22 +225,29 @@ function recommendSubgraph({ goal, chain = "" }) {
215
225
  FROM subgraphs
216
226
  ${where}
217
227
  ORDER BY reliability_score DESC
218
- LIMIT 5
228
+ LIMIT 15
219
229
  `;
220
230
 
221
231
  const rows = getDb().prepare(sql).all(...params);
222
- const recommendations = rows.map((r) => ({
223
- id: r.id,
224
- display_name: r.display_name,
225
- description: (r.description || r.auto_description || "").slice(0, 300),
226
- domain: r.domain,
227
- protocol_type: r.protocol_type,
228
- network: r.network,
229
- reliability_score: r.reliability_score,
230
- ipfs_hash: r.ipfs_hash,
231
- canonical_entities: JSON.parse(r.canonical_entities),
232
- query_url: `https://gateway.thegraph.com/api/[api-key]/subgraphs/id/${r.id}`,
233
- }));
232
+ const seenIpfs = new Set();
233
+ const recommendations = [];
234
+ for (const r of rows) {
235
+ if (r.ipfs_hash && seenIpfs.has(r.ipfs_hash)) continue;
236
+ if (r.ipfs_hash) seenIpfs.add(r.ipfs_hash);
237
+ recommendations.push({
238
+ id: r.id,
239
+ display_name: r.display_name,
240
+ description: (r.description || r.auto_description || "").slice(0, 300),
241
+ domain: r.domain,
242
+ protocol_type: r.protocol_type,
243
+ network: r.network,
244
+ reliability_score: r.reliability_score,
245
+ ipfs_hash: r.ipfs_hash,
246
+ canonical_entities: JSON.parse(r.canonical_entities),
247
+ query_url: `https://gateway.thegraph.com/api/[api-key]/subgraphs/id/${r.id}`,
248
+ });
249
+ if (recommendations.length >= 5) break;
250
+ }
234
251
 
235
252
  return {
236
253
  goal,
@@ -354,7 +371,7 @@ async function main() {
354
371
  await ensureDb();
355
372
 
356
373
  const server = new Server(
357
- { name: "subgraph-registry", version: "0.2.0" },
374
+ { name: "subgraph-registry", version: "0.2.1" },
358
375
  { capabilities: { tools: {} } }
359
376
  );
360
377