System architecture and design patterns for Neo N3 MCP Server
Neo N3 MCP Server is built as a modular, extensible system that bridges the gap between AI applications and the Neo N3 blockchain. The architecture follows industry best practices for security, performance, and maintainability.
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ β AI Client β β MCP Server β β Neo N3 β β (Claude, etc) βββββΊβ (This System) βββββΊβ Network β βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ β βΌ ββββββββββββββββββββ β Tool & Resourceβ β Management β ββββββββββββββββββββ β βββββββββββββΌββββββββββββ βΌ βΌ βΌ ββββββββββββ ββββββββββββ ββββββββββββ βBlockchainβ β Wallet β β Security β β Service β β Service β β Service β ββββββββββββ ββββββββββββ ββββββββββββ
Manages the Model Context Protocol communication, handling tool calls, resource requests, and maintaining session state.
Core blockchain interaction layer that handles all Neo N3 network communications and operations.
Secure wallet operations including creation, import, and transaction signing with enterprise-grade encryption.
Manages famous contracts and provides standardized interfaces for smart contract interactions.
Comprehensive security controls including input validation, rate limiting, and access control.
Real-time monitoring, metrics collection, and health checks for operational excellence.
1. AI Client Request β βΌ 2. MCP Protocol Validation β βΌ 3. Security Checks β ββ Input Validation β ββ Rate Limiting β ββ Authorization βΌ 4. Tool Router β βΌ 5. Service Layer β ββ Blockchain Service β ββ Wallet Service β ββ Contract Service βΌ 6. Neo N3 Network β βΌ 7. Response Processing β ββ Data Transformation β ββ Error Handling β ββ Metrics Collection βΌ 8. MCP Response to Client
{ "dependencies": { "@cityofzion/neon-js": "^5.4.0", "@neo-project/neo-js": "^3.15.0", "express": "^4.18.2", "ws": "^8.13.0", "crypto": "node:crypto", "dotenv": "^16.3.1", "joi": "^17.9.2", "winston": "^3.10.0", "prom-client": "^14.2.0" }, "devDependencies": { "@types/node": "^20.4.5", "typescript": "^5.1.6", "jest": "^29.6.2", "eslint": "^8.45.0", "prettier": "^3.0.0" } }
Tool creation and service instantiation based on configuration and runtime requirements.
Different network handlers (mainnet/testnet) and encryption strategies for various security levels.
Event-driven architecture for monitoring, logging, and metric collection across components.
Prevents cascading failures when Neo N3 network is unavailable or experiencing issues.
βββββββββββββββββββββββββββββββββββββββββββ β Application Layer β β ββ Input Validation β β ββ Rate Limiting β β ββ Request Authentication β βββββββββββββββββββββββββββββββββββββββββββ€ β Service Layer β β ββ Business Logic Validation β β ββ Permission Checks β β ββ Operation Confirmation β βββββββββββββββββββββββββββββββββββββββββββ€ β Data Layer β β ββ Encryption at Rest β β ββ Secure Key Derivation β β ββ Audit Logging β βββββββββββββββββββββββββββββββββββββββββββ€ β Network Layer β β ββ TLS/SSL Encryption β β ββ Connection Security β β ββ Network Isolation β βββββββββββββββββββββββββββββββββββββββββββ
Efficient Neo N3 RPC connection management with automatic load balancing and failover.
Non-blocking operations with proper error handling and timeout management.
Intelligent caching of blockchain data with appropriate TTL and invalidation strategies.
Memory-efficient operations with garbage collection optimization and leak prevention.