UNPKG

mcp-eth-test-subgraph-9

Version:

MCP server for ethereum_transactions_test subgraph - Track all Ethereum ERC20 transfers for testing

84 lines (83 loc) 4.04 kB
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"], subscribed_event_types: ["ERC20.Transfer"], event_schemas: { "ERC20.Transfer": { "description": "ERC20 token transfers", "schema": "- Transfer nodes: id, value, value_usd, block_number, transaction_hash, log_index, timestamp, created_at\n - Wallet nodes: address, created_at, first_seen_block, last_seen_block, transaction_count, total_sent, total_received \n - Token nodes: address, symbol, name, decimals, created_at, first_seen_block, last_seen_block\n - Relationships: SENT (Wallet->Transfer), RECEIVED (Transfer->Wallet), OF_TOKEN (Transfer->Token)", "examples": [ "Show me all transfers of USDT tokens in the last 24 hours", "What's the total volume of transfers for wallet 0x123?", "Find large token transfers (>$10,000) this week", "Show me wallets that sent the most USDC" ] } }, example_queries: [ "Show me recent transfers", "Find active wallets" ], node_types: ["Wallet", "Transfer", "Token", "NFT", "Swap"], relationship_types: ["SENT", "RECEIVED", "OF_TOKEN"] }; } 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; } }