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.
- package/package.json +1 -1
- package/src/index.js +46 -29
package/package.json
CHANGED
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(
|
|
132
|
+
params.push(fetchLimit);
|
|
131
133
|
|
|
132
134
|
const rows = getDb().prepare(sql).all(...params);
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
|
228
|
+
LIMIT 15
|
|
219
229
|
`;
|
|
220
230
|
|
|
221
231
|
const rows = getDb().prepare(sql).all(...params);
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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.
|
|
374
|
+
{ name: "subgraph-registry", version: "0.2.1" },
|
|
358
375
|
{ capabilities: { tools: {} } }
|
|
359
376
|
);
|
|
360
377
|
|