sonic-crypto-mcp-server

mintedmaterial/sonic-crypto-mcp-server

3.2

If you are the rightful owner of sonic-crypto-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Sonic Crypto MCP Server is an advanced Model Context Protocol server designed to provide comprehensive cryptocurrency market data and AI-powered analysis for the Sonic blockchain ecosystem.

Tools
6
Resources
0
Prompts
0

๐Ÿš€ Sonic Crypto MCP Server

Advanced Model Context Protocol (MCP) server providing comprehensive cryptocurrency market data and AI-powered analysis for the Sonic blockchain ecosystem

Deploy to Cloudflare Workers TypeScript MCP

๐ŸŒŸ Features

Core Capabilities

  • ๐Ÿ”ฅ Real-time Cryptocurrency Data - Live prices, OHLCV data, and market metrics
  • ๐Ÿง  AI-Powered Analysis - Market sentiment analysis using Cloudflare AI (Llama 3.1-8b)
  • ๐Ÿ’ฌ Interactive Chat Assistant - Context-aware AI chat with Hermes-2-Pro-Mistral-7B
  • ๐Ÿ“ฐ News Aggregation - AI-curated crypto news and market updates
  • ๐Ÿ“Š Historical Data Management - Automated seeding and caching of historical market data
  • ๐ŸŽจ Sonic-Themed Dashboard - Beautiful dark mode UI with animated starfield background

Technical Features

  • Multi-Tier Caching - KV, Durable Objects, and R2 storage for optimal performance
  • MCP Protocol Compliance - Full Model Context Protocol implementation
  • Auto-Deployment - GitHub integration with Cloudflare for CI/CD
  • Analytics Integration - Real-time usage tracking with Analytics Engine
  • Scheduled Jobs - Automated data refresh via cron triggers
  • Type-Safe - Strict TypeScript with comprehensive type definitions

๐ŸŽฏ NEW: Advanced Features

Workers for Platforms ๐Ÿš€
  • User-Specific Worker Instances - Isolated execution environments per user
  • NFT-Gated Access - Bandit Kidz NFT holders get premium features
  • Dispatch Namespace: sonic-user-workers (shared with Vibe SDK)
  • Cross-Platform Integration - Seamless integration with Vibe SDK applications
  • Auto Lifecycle Management - Automatic worker creation, routing, and cleanup
Python ML Containers ๐Ÿ (Coming Soon)
  • Advanced Technical Analysis - 50+ indicators via TA-Lib
  • Pattern Recognition - AI-powered candlestick and chart patterns
  • Machine Learning - scikit-learn models for trend prediction
  • Chart Generation - plotly/matplotlib visualizations
  • See for activation guide

๐Ÿ—๏ธ Architecture

src/
โ”œโ”€โ”€ config/           # Environment & configuration
โ”‚   โ””โ”€โ”€ env.ts       # Cloudflare bindings & constants
โ”œโ”€โ”€ services/        # Business logic services
โ”‚   โ”œโ”€โ”€ cache.ts     # KV & Durable Object caching
โ”‚   โ””โ”€โ”€ ai.ts        # AI service abstractions
โ”œโ”€โ”€ storage/         # Storage layer
โ”‚   โ”œโ”€โ”€ r2.ts        # R2 bucket operations
โ”‚   โ””โ”€โ”€ d1.ts        # D1 database operations
โ”œโ”€โ”€ tools/           # MCP tools
โ”‚   โ”œโ”€โ”€ price-tool.ts
โ”‚   โ”œโ”€โ”€ sentiment-tool.ts
โ”‚   โ”œโ”€โ”€ web-search-tool.ts
โ”‚   โ”œโ”€โ”€ historical-tool.ts
โ”‚   โ””โ”€โ”€ index.ts
โ”œโ”€โ”€ workflows/       # Cloudflare Workflows
โ”‚   โ”œโ”€โ”€ data-seeding.ts
โ”‚   โ””โ”€โ”€ data-workflow.ts
โ”œโ”€โ”€ durable-objects/ # Persistent state
โ”‚   โ”œโ”€โ”€ crypto-cache.ts
โ”‚   โ””โ”€โ”€ session-manager.ts
โ”œโ”€โ”€ ui/              # Dashboard
โ”‚   โ””โ”€โ”€ dashboard.ts
โ””โ”€โ”€ index.ts         # Main worker entry point

๐Ÿš€ Quick Start

Prerequisites

Installation

# Clone the repository
git clone https://github.com/mintedmaterial/sonic-crypto-mcp-server.git
cd sonic-crypto-mcp-server

# Install dependencies
npm install

# Generate TypeScript types for Cloudflare bindings
npm run setup

Configuration

  1. Set Cloudflare Secrets:
# Required
wrangler secret put COINDESK_API_KEY

# Optional
wrangler secret put AI_GATEWAY_TOKEN
wrangler secret put ANTHROPIC_API_KEY
  1. Configure Custom Domain (Optional):
    • Update wrangler.toml with your domain settings
    • The server is configured for ss.srvcflo.com

Development

# Start local development server
npm run dev

# The server will be available at http://localhost:8787

Deployment

# Deploy to production
npm run deploy

# Deploy to staging
npm run deploy:staging

# View real-time logs
npm run tail

๐Ÿ“ก API Endpoints

Dashboard

  • GET / - Sonic-themed interactive dashboard with AI chat

MCP Protocol

  • GET /mcp/tools/list - List all available MCP tools
  • POST /mcp/tools/call - Execute an MCP tool

Direct API Access

  • GET|POST /api/price - Get latest cryptocurrency prices
  • GET|POST /api/sentiment - AI-powered market sentiment analysis
  • GET|POST /api/news - Search crypto news
  • POST /api/chat - AI chat assistant with context-aware responses

User Worker Management (Workers for Platforms)

  • POST /api/user-worker/create - Create or get user-specific worker (NFT-gated)
  • POST /api/user-worker/dispatch - Dispatch request to user worker
  • POST /api/user-worker/update-nft - Update user worker NFT status
  • GET /api/user-worker/stats - Get worker statistics (monitoring)
  • GET /api/user-worker/list - List all user workers (admin)
  • POST /api/user-worker/delete - Delete user worker (cleanup)
  • POST /api/verify-nft - Verify Bandit Kidz NFT ownership

Data Management

  • POST /api/init-db - Initialize D1 database schema
  • POST /api/seed-data - Seed historical data (accepts config JSON)
  • POST /api/refresh-data - Refresh recent data

System

  • GET /health - Health check with service status
  • GET /docs - API documentation

๐Ÿ› ๏ธ MCP Tools

1. get_latest_index_tick

Get real-time cryptocurrency prices with OHLC metrics.

{
  "market": "cadli",
  "instruments": ["BTC-USD", "ETH-USD", "S-USD", "SONIC-USD"]
}

2. analyze_sonic_market_sentiment

AI-powered sentiment analysis for Sonic ecosystem.

{
  "sentiment_sources": ["price_action", "volume_analysis"],
  "timeframe": "1d",
  "instruments": ["S-USD", "BTC-USD", "ETH-USD"]
}

3. search_crypto_news

Search and summarize cryptocurrency news.

{
  "query": "Sonic blockchain news",
  "tokens": ["Sonic", "S-USD"],
  "max_results": 5
}

4. get_historical_ohlcv_daily

Fetch historical daily OHLCV data (up to 5000 points).

5. get_historical_ohlcv_hourly

Fetch hourly data for intraday analysis.

6. get_historical_ohlcv_minutes

Fetch minute-level data for high-frequency analysis.

๐Ÿ”ง Environment Variables

Required

  • COINDESK_API_KEY - CoinDesk API authentication

Optional

  • AI_GATEWAY_TOKEN - Cloudflare AI Gateway token
  • ANTHROPIC_API_KEY - Alternative AI provider

Build-time (in wrangler.toml)

  • API_VERSION - API version (default: "1.0.0")
  • ENVIRONMENT - Deployment environment
  • MCP_SERVER_NAME - Server name (default: "sonic-crypto-mcp")

๐Ÿ—„๏ธ Cloudflare Services

Storage

  • KV Namespaces: SONIC_CACHE, API_RATE_LIMIT
  • R2 Buckets: HISTORICAL_DATA, MARKET_REPORTS
  • D1 Database: CONFIG_DB (for metadata and configuration)

Compute

  • Durable Objects: CryptoDataCache, MCPSessionManager, OverviewAgent, ChartsAgent
  • Workflows: DATA_UPDATE_WORKFLOW, DATA_SEEDING_WORKFLOW
  • Queue: CRYPTO_QUEUE (for background processing)
  • Dispatch Namespace: sonic-user-workers (Workers for Platforms)
  • Containers: CHARTS_CONTAINER (Python ML - when available)

AI & Analytics

  • Workers AI: Llama 3.1-8b, Hermes-2-Pro-Mistral-7B
  • Analytics Engine: Usage tracking and monitoring

๐Ÿ“Š Data Seeding

Initialize Database

curl -X POST https://ss.srvcflo.com/api/init-db

Seed Historical Data

curl -X POST https://ss.srvcflo.com/api/seed-data \
  -H "Content-Type: application/json" \
  -d '{
    "instruments": ["BTC-USD", "ETH-USD", "S-USD"],
    "markets": ["cadli"],
    "daysOfHistory": 90
  }'

๐Ÿ”„ Auto-Deployment

GitHub Integration

  1. Go to Cloudflare Dashboard โ†’ Workers & Pages
  2. Select your worker โ†’ Settings โ†’ Builds
  3. Click "Connect" and authorize GitHub
  4. Select the sonic-crypto-mcp-server repository
  5. Configure build settings (automatic)

Push to main branch = automatic deployment! ๐ŸŽ‰

๐Ÿงช Testing

Local Testing

# Start dev server
npm run dev

# Test MCP endpoint
curl http://localhost:8787/mcp/tools/list

# Test price API
curl "http://localhost:8787/api/price"

# Test chat
curl -X POST http://localhost:8787/api/chat \
  -H "Content-Type: application/json" \
  -d '{"message":"What is the price of BTC?"}'

Production Testing

# Health check
curl https://ss.srvcflo.com/health

# View logs
npm run tail

๐Ÿ“ Scripts

npm run build          # Compile TypeScript
npm run dev            # Start local development server
npm run deploy         # Deploy to default environment
npm run deploy:staging # Deploy to staging
npm run deploy:prod    # Deploy to production
npm run tail           # View real-time logs
npm run lint           # Type-check without emitting
npm run setup          # Generate Cloudflare types

๐Ÿค Contributing

Contributions are welcome! Please see for guidelines.

๐Ÿ“„ License

ISC License - see for details.

๐Ÿ”— Links

๐Ÿ“ž Support

For issues, questions, or contributions:


Made with โค๏ธ for the Sonic ecosystem