mcp-eth-test-subgraph-3
Version:
MCP server for ethereum_transactions_test subgraph - Track all Ethereum ERC20 transfers for testing
73 lines (72 loc) • 3.08 kB
JavaScript
export class SchemaService {
subgraphId;
constructor(subgraphId) {
this.subgraphId = subgraphId;
}
async getSchema() {
// This will be replaced during generation with real data from chat_interface
return {
subgraph_id: this.subgraphId,
critical_filtering_rules: [
"EVERY node in your query MUST be filtered by subgraph_id property: WHERE n.subgraph_id = $subgraph_id",
"EVERY relationship in your query MUST be filtered by subgraph_id property: WHERE r.subgraph_id = $subgraph_id"
],
filtering_examples: [
"Single node: MATCH (t:Transfer) WHERE t.subgraph_id = $subgraph_id RETURN t LIMIT 10"
],
base_node_types: ["Wallet", "Transfer", "Token", "NFT", "Swap"],
base_relationships: ["SENT", "RECEIVED", "OF_TOKEN", "OWNS", "SWAPPED"],
subscribed_event_types: [],
event_schemas: {},
example_queries: [
"Show me recent transfers",
"Find active wallets"
],
node_types: ["Wallet", "Transfer", "Token", "NFT", "Swap"],
relationship_types: ["SENT", "RECEIVED", "OF_TOKEN", "OWNS", "SWAPPED"]
};
}
async refreshSchema() {
return this.getSchema();
}
getSubgraphId() {
return this.subgraphId;
}
formatSchemaForToolDescription(schema) {
let description = '';
if (schema.critical_filtering_rules?.length) {
description += '\\n\\nCRITICAL FILTERING RULES:\\n';
schema.critical_filtering_rules.forEach(rule => {
description += `- ${rule}\\n`;
});
}
if (schema.base_node_types?.length) {
description += `\\nNODE TYPES: ${schema.base_node_types.join(', ')}`;
}
if (schema.base_relationships?.length) {
description += `\\nRELATIONSHIP TYPES: ${schema.base_relationships.join(', ')}`;
}
if (schema.subscribed_event_types?.length) {
description += `\\n\\nSUBSCRIBED EVENT TYPES: ${schema.subscribed_event_types.join(', ')}`;
}
if (schema.event_schemas && Object.keys(schema.event_schemas).length > 0) {
description += '\\n\\nEVENT-SPECIFIC SCHEMAS:';
for (const [eventType, eventSchema] of Object.entries(schema.event_schemas)) {
description += `\\n- ${eventType}: ${eventSchema?.description || 'Event schema available'}`;
}
}
if (schema.filtering_examples?.length) {
description += '\\n\\nFILTERING EXAMPLES:\\n';
schema.filtering_examples.forEach(example => {
description += `- ${example}\\n`;
});
}
if (schema.example_queries?.length) {
description += '\\n\\nEXAMPLE QUERIES:\\n';
schema.example_queries.slice(0, 5).forEach(query => {
description += `- ${query}\\n`;
});
}
return description;
}
}