Skip to content

cryptomcp/crypto-mcp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MCP Crypto Bot (Python)

MCP

Production-ready Model Context Protocol (MCP) server for crypto trading automation with AI decision support.

πŸš€ Features

Core Functionality

  • Multi-Exchange Support: CEX (Binance, etc.), EVM chains, Solana
  • AI Decision Engine: OpenAI GPT-4, Google Gemini, DeepSeek integration
  • Telegram Bot: Real-time management and notifications
  • Risk Management: Configurable limits and safety checks
  • Wallet Management: EVM and Solana wallet creation/import/export
  • Portfolio Tracking: Real-time balance and position monitoring

Trading Features

  • CEX Trading: Spot orders, OHLCV data, balance management
  • DEX Integration: 0x swaps on EVM, Jupiter swaps on Solana
  • Token Transfers: ERC20 and SPL token transfers
  • AI Trading Assistant: Intelligent trade recommendations with risk assessment
  • News Trading: Real-time news monitoring, sentiment analysis, and AI-powered trading decisions

πŸ“‹ Requirements

  • Python 3.11+
  • Linux/macOS/Windows
  • API keys for exchanges and AI providers

πŸ› οΈ Installation

Option 1: One-liner Installation (Recommended)

# Install with pipx (isolated environment)
pipx install mcp-crypto-bot

# Or with uv (fast package manager)
uvx install mcp-crypto-bot

# Run from anywhere
mcp-crypto-bot

Option 2: Manual Installation

# Clone repository
git clone https://github.com/cryptomcp/crypto-ai-mcp-server.git
cd crypto-ai-mcp-server

# Install in development mode
pip install -e .

# Or using uv (recommended)
uv pip install -e .

Environment Configuration

cp .env.example .env
# Edit .env with your API keys and settings

πŸš€ Usage

Quick Start

# Start the MCP server
mcp-crypto-bot

# Or with custom environment
TELEGRAM_BOT_TOKEN=your_token mcp-crypto-bot

MCP Inspector Integration

# Install MCP Inspector
npm install -g @modelcontextprotocol/inspector

# Run with Inspector
npx @modelcontextprotocol/inspector -- mcp-crypto-bot

# With environment injection
npx @modelcontextprotocol/inspector --env-file .env -- mcp-crypto-bot

πŸ› οΈ MCP Tools & Resources

Available Tools

  • CEX Trading: Price checks, order placement, balance management
  • EVM Operations: Token transfers, DEX swaps, NFT operations
  • Solana Support: SPL token transfers, Jupiter swaps, wallet management
  • AI Decision Engine: Intelligent trading recommendations
  • Portfolio Management: Balance tracking and portfolio snapshots
  • News Trading: News monitoring, sentiment analysis, trending analysis, custom conditions

Available Resources

  • resource: wallets: List current EVM and Solana wallets
  • resource: candles://{venue}/{symbol}/{timeframe}: Real-time OHLCV data

News Trading Features

  • Real-time News Monitoring: RSS feeds, APIs, web scraping from multiple sources
  • Sentiment Analysis: AI-powered sentiment analysis with OpenAI, Gemini, and TextBlob
  • Custom Trading Conditions: Rule-based trading with sentiment, frequency, keyword, and trending conditions
  • Trending Analysis: Multi-platform trending coin detection and ranking
  • AI Decision Making: Intelligent trading decisions based on news and market data
  • Risk Management: Position sizing, stop-loss, take-profit, and daily limits
  • Trading Modes: Manual, AI-assisted, and fully automated trading

Example Usage

from mcp import ClientSession

async with ClientSession() as session:
    # Get wallet information
    wallets = await session.read_resource("resource: wallets")
    
    # Get market data
    candles = await session.read_resource("resource: candles://binance/BTC/USDT/1h")
    
    # Execute trading operations
    result = await session.call_tool("cex_get_price", {"symbol": "BTC/USDT"})

βš™οΈ Configuration

Environment Variables

Variable Description Required Default
LIVE Enable live trading (0=test, 1=live) Yes 0
AM_I_SURE Safety confirmation for live trading Yes NO
MAX_ORDER_USD Maximum order size in USD Yes 100
DAILY_LOSS_LIMIT_USD Daily loss limit in USD Yes 200
TELEGRAM_BOT_TOKEN Telegram bot token No -
OWNER_TELEGRAM_ID Your Telegram user ID No -
OPENAI_API_KEY OpenAI API key for AI decisions No -
GOOGLE_API_KEY Google AI API key No -
DEEPSEEK_API_KEY DeepSeek API key No -
BINANCE_API_KEY Binance API key No -
BINANCE_SECRET Binance secret key No -
ETHEREUM_RPC_URL Ethereum RPC endpoint No -
SOLANA_RPC_URL Solana RPC endpoint No -

Safety Configuration

# Test mode (safe)
LIVE=0
AM_I_SURE=NO
MAX_ORDER_USD=100
DAILY_LOSS_LIMIT_USD=200

# Live trading (dangerous - only if you know what you're doing)
LIVE=1
AM_I_SURE=YES
MAX_ORDER_USD=1000
DAILY_LOSS_LIMIT_USD=1000

πŸ“š Documentation

View the full documentation at docs.cryptomcp.github.io

πŸƒβ€β™‚οΈ Running Documentation Locally

# 1. Navigate to docs directory
cd docs

# 2. Install dependencies
npm install

# 3. Start development server
npm run start

# 4. Open browser to http://localhost:3000

πŸ—οΈ Building Documentation

# Build for production
npm run build

# Serve built documentation locally
npm run serve

πŸš€ Deploying to GitHub Pages

# Deploy to GitHub Pages
npm run deploy

# Documentation will be available at:
# https://cryptomcp.github.io/crypto-ai-mcp-server/

⚠️ Risk Management

Safety Features

  • Double Confirmation: LIVE=1 AND AM_I_SURE=YES required
  • Order Limits: MAX_ORDER_USD enforces maximum trade size
  • Loss Limits: DAILY_LOSS_LIMIT_USD prevents excessive losses
  • Dry Run Mode: Test all operations with dry_run: true
  • Risk Assessment: AI evaluates all trade recommendations

Critical Safety Rules

  1. Never set LIVE=1 without AM_I_SURE=YES
  2. Always test with dry_run: true first
  3. Monitor daily loss limits
  4. Backup wallet private keys securely
  5. Start Small: Begin with small amounts

πŸ§ͺ Testing

Unit Tests

pytest tests/

Integration Tests

pytest tests/ -m integration

Manual Testing

# Start server in test mode
LIVE=0 python src/server.py

# Use MCP inspector
npx @modelcontextprotocol/inspector -- python src/server.py

πŸ—οΈ Architecture

src/
β”œβ”€β”€ server.py              # MCP server bootstrap
β”œβ”€β”€ mcp_tools.py           # All MCP tool definitions
β”œβ”€β”€ config/
β”‚   └── env.py            # Environment configuration
β”œβ”€β”€ cex/
β”‚   └── ccxt_client.py    # CEX trading client
β”œβ”€β”€ evm/
β”‚   └── evm_client.py     # EVM blockchain client
β”œβ”€β”€ solana/
β”‚   └── solana_client.py  # Solana blockchain client
β”œβ”€β”€ wallets/              # Wallet management
β”œβ”€β”€ portfolio/            # Portfolio tracking
β”œβ”€β”€ ai/                   # AI decision engine
β”‚   β”œβ”€β”€ engine.py
β”‚   └── prompts.py
β”œβ”€β”€ telegram/
β”‚   └── bot.py           # Telegram bot
└── logging.py           # Logging configuration

πŸ”§ Development

Adding New Tools

  1. Define Pydantic model in mcp_tools.py
  2. Implement tool function with @mcp.tool() decorator
  3. Add error handling and logging
  4. Update tests

Adding New AI Providers

  1. Add provider to AIProvider enum
  2. Implement query method in AIDecisionEngine
  3. Add to ensemble logic if desired
  4. Update configuration

πŸ“ API Reference

Response Format

All tools return structured JSON:

{
  "success": true|false,
  "data": { ... } | null,
  "error": "error message" | null
}

Error Handling

  • Network errors are automatically retried
  • Validation errors return descriptive messages
  • Risk violations prevent execution
  • All errors are logged with context

🀝 Contributing

  1. Fork the repository
  2. Create feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass
  5. Submit pull request

24/7 Live Support

We provide 24/7 live support with guaranteed instant response to all requests.

  • All requests are acknowledged within 5 minutes.
  • Support is available 7 days a week, 24 hours a day without interruption.
  • Resolution time may vary depending on the type of issue, but initial response is always instant.
  • We provide multilingual support, but our primary language is English.

Contact Us

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

This software is for educational and research purposes only. Crypto trading involves substantial risk of loss and is not suitable for every investor. Past performance does not guarantee future results. You should not trade with money you cannot afford to lose.

The authors and contributors of this project are not responsible for any financial losses incurred through the use of this software.

About

Production-ready MCP server for crypto trading automation with AI decision support

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages