加密货币交易所访问服务器

CCXT MCP Server 是一个通用的加密货币交易所访问接口,通过单一MCP界面支持100+交易所的交易、实时价格获取、订单簿分析、套利机会检测等功能。

  • by MyronKoch
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 MyronKoch/ccxt-mcp-server

使用说明

🚀 CCXT MCP服务器

Claude的通用加密货币交易所访问权限 -通过单一MCP接口在100多个交易所进行交易!

🌟 这有什么作用

graph LR
    A[Claude Desktop] --> B[CCXT MCP Server]
    B --> C[CCXT Library]
    C --> D[Binance]
    C --> E[Coinbase]
    C --> F[Kraken]
    C --> G[Bybit]
    C --> H[...100+ more]

    style A fill:#f9f,stroke:#333,stroke-width:2px,color:#000
    style B fill:#bbf,stroke:#333,stroke-width:4px,color:#000
    style C fill:#bfb,stroke:#333,stroke-width:2px,color:#000
    style D fill:#fff,stroke:#333,stroke-width:1px,color:#000
    style E fill:#fff,stroke:#333,stroke-width:1px,color:#000
    style F fill:#fff,stroke:#333,stroke-width:1px,color:#000
    style G fill:#fff,stroke:#333,stroke-width:1px,color:#000
    style H fill:#fff,stroke:#333,stroke-width:1px,color:#000

此MCP服务器使Claude能够:

  • 📈 获取实时价格 来自任何加密货币交易所
  • 📊 分析订单簿 市场深度
  • 🔄 比较价格 即时跨交易所
  • 💰 发现套利机会 自动地
  • 📉 获取历史数据 用于技术分析
  • 📐 计算技术指标 (RSI、MACD、布林带、ATR、随机指标、Ichimoku)

⚡ 快速入门(2分钟)

1.️⃣ 安装

# Clone the repository
git clone https://github.com/MyronKoch/ccxt-mcp-server.git
cd ccxt-mcp-server

# Install dependencies
npm install

# Build the project
npm run build

2.️⃣ 添加到克劳德桌面

{
  "mcpServers": {
    "ccxt-mcp-server": {
      "command": "node",
      "args": ["/path/to/ccxt-mcp-server/dist/index.js"]
    }
  }
}

3.️⃣ 重启克劳德&交易!

问克劳德: “币安上的比特币价格是多少?”

🛠️ 可用工具

📋 交换管理

工具 说明 示例
exchange_list 列出所有106个支持的交易所 “显示所有可用的交易所”
exchange_init 连接到特定交易所 “初始化币安连接”
exchange_status 检查交易所是否正常工作 “Coinbase是否正常运行?”
exchange_markets 获取交易对 “Kraken支持哪些交易对?”

📊 市场数据(无需授权!)

工具 说明 示例
market_ticker 当前价格 “币安BTC价格”
market_orderbook 出价和询问 “显示ETH订单簿”
market_trades 最近交易 “最新SOL交易”
market_ohlcv 烛台数据 “1小时BTC图表数据”

💼 帐户和分析

工具 说明 示例
account_balance 检查余额(需要env API密钥) “我的币安余额”
analytics_compare_prices 多交易所比较 “比较所有交易所的ETH”

📐 技术分析

工具 说明 示例
indicators_calculate 计算技术指标 “在币安计算BTC/USDT的RSI和MACD”

支持的指标:

  • 相对强弱指数 -相对强弱指数(超买/超卖检测)
  • MACD指标 -移动平均线收敛发散(趋势检测)
  • 布林线 -波动性和价格区间分析
  • 自动目标识别 -平均真实范围(波动性测量)
  • 随机 -动量振荡器
  • Ichimoku云 -综合趋势分析

🎯 杀手级功能

🔍 套利检测

graph TD
    A[Check BTC Price] --> B{Price Difference?}
    B -->|Yes| C[Buy on Exchange A]
    C --> D[Sell on Exchange B]
    D --> E[💰 Profit!]
    B -->|No| F[Keep Monitoring]

    style A fill:#fff,stroke:#333,stroke-width:2px,color:#000
    style B fill:#fff,stroke:#333,stroke-width:2px,color:#000
    style C fill:#fff,stroke:#333,stroke-width:2px,color:#000
    style D fill:#fff,stroke:#333,stroke-width:2px,color:#000
    style E fill:#0f0,stroke:#333,stroke-width:2px,color:#000
    style F fill:#fff,stroke:#333,stroke-width:2px,color:#000

服务器会自动检测同一资产在交易所之间的价格是否不同!

⚡ 真实案例

You: "Compare Bitcoin prices across major exchanges"

Claude: Analyzing BTC/USDT across exchanges...

📊 Price Comparison:
• Binance:   $67,234.50 
• Coinbase:  $67,256.00 (+$21.50)
• Kraken:    $67,245.75 (+$11.25)
• Bybit:     $67,232.00 (-$2.50)

🎯 Arbitrage Opportunity Detected!
Buy on Bybit at $67,232.00
Sell on Coinbase at $67,256.00
Potential profit: $24.00 per BTC (0.036%)
You: "Calculate RSI and MACD for BTC/USDT on Binance"

Claude: Analyzing Bitcoin technical indicators...

📐 Technical Analysis (1-hour timeframe):

RSI (14): 58.32
• Signal: Neutral
• Not overbought (>70) or oversold (<30)

MACD:
• MACD Line: 234.50
• Signal Line: 198.25
• Histogram: 36.25 (Bullish)
• Trend: Bullish momentum increasing

Bollinger Bands:
• Upper: $67,850
• Middle: $67,234
• Lower: $66,618
• Current price within normal range

💡 Interpretation: Moderate bullish momentum with RSI in neutral zone.
MACD showing positive divergence. Consider entry on pullback to middle band.

🏗️ 建筑

系统设计

flowchart TB
    subgraph MCP[MCP Layer]
        A[Tool Definitions]
        B[Request Handler]
    end

    subgraph Core[Core System]
        C[Exchange Manager<br/>Singleton Pattern]
        D[Response Formatter<br/>TAPS Compliance]
        E[Validation Utils<br/>Input Safety]
    end

    subgraph CCXT[CCXT Integration]
        F[106 Exchange APIs]
        G[Normalized Data]
        H[Rate Limiting]
    end

    MCP --> Core
    Core --> CCXT

    style A fill:#fff,stroke:#333,stroke-width:2px,color:#000
    style B fill:#fff,stroke:#333,stroke-width:2px,color:#000
    style C fill:#bbf,stroke:#333,stroke-width:2px,color:#000
    style D fill:#bbf,stroke:#333,stroke-width:2px,color:#000
    style E fill:#bbf,stroke:#333,stroke-width:2px,color:#000
    style F fill:#fff,stroke:#333,stroke-width:2px,color:#000
    style G fill:#fff,stroke:#333,stroke-width:2px,color:#000
    style H fill:#fff,stroke:#333,stroke-width:2px,color:#000

TAPS v1.0响应格式

{
  "success": true,
  "data": {
    "symbol": "BTC/USDT",
    "bid": 67234.50,
    "ask": 67235.00,
    "last": 67234.75
  },
  "metadata": {
    "exchange": "binance",
    "timestamp": 1738123456789,
    "rateLimit": { "remaining": 99, "reset": 1738123460 },
    "version": "TAPS-1.0.0"
  }
}

🔒 安全

  • 🔐 仅限环境的凭据 -API键必须通过环境变量设置(从不在请求参数中)
  • ⏱️ 自适应速率限制 -自动指数回退防止交易所禁令
  • 🔄 自动重试 -具有回退功能的智能重试逻辑(最多5次尝试)
  • 🛡️ 输入验证 -防止代价高昂的错误和格式错误的请求
  • 🧹 凭证净化 -日志或响应中没有泄漏
  • ✅ 测试网支持 -安全开发环境

设置API凭据

对于帐户操作,将凭据设置为环境变量:

# .env file
BINANCE_API_KEY=your_api_key_here
BINANCE_SECRET=your_secret_here

# For other exchanges, use: EXCHANGEID_API_KEY and EXCHANGEID_SECRET
COINBASE_API_KEY=...
COINBASE_SECRET=...

安全说明: 决不接受凭据作为工具参数,以防止MCP日志中的泄漏。

📈 支持的交易所(共106个!)

🌟 Tier 1 - Fully Tested
  • 币安(+测试网)
  • Coinbase(+沙盒)
  • 海妖
  • Bybit(+测试网)
  • 欧易
🚀 Tier 2 - Major Exchanges
  • Bitfinex
  • 火币
  • Gate.io
  • KuCoin
  • 币赢
  • Bitstamp
  • 双子座
  • Crypto.com
  • 墨西哥
  • 90+以上。..

🧑‍💻 发展

# Install dependencies
npm install

# Development mode with hot reload
npm run dev

# Build for production
npm run build

# Run tests
npm test

项目结构

ccxt-mcp-server/
├── src/
│   ├── index.ts                    # Main MCP server
│   ├── exchange-manager.ts         # Exchange instance management with rate limiting
│   ├── response-formatter.ts       # TAPS response formatting
│   ├── arbitrage/
│   │   └── advanced-scanner.ts     # Real-time arbitrage detection
│   ├── cache/
│   │   └── lru-cache-manager.ts    # LRU caching for market data
│   ├── indicators/
│   │   └── technical-analysis.ts   # RSI, MACD, Bollinger, ATR, Stochastic, Ichimoku
│   ├── rate-limiting/
│   │   └── adaptive-limiter.ts     # Exponential backoff retry logic
│   ├── risk/
│   │   └── risk-manager.ts         # Kelly Criterion, position sizing
│   ├── utils/
│   │   └── validation.ts           # Input validation and sanitization
│   └── types/
│       └── taps.ts                 # TAPS v1.0 type definitions
├── dist/                           # Compiled JavaScript
├── tests/                          # Comprehensive test suite
└── docs/
    ├── standards/
    │   └── TAPS-v1.0-STANDARD.md  # Protocol specification
    ├── architecture/
    │   └── ARCHITECTURE.md         # System design
    └── guides/
        └── TESTING-GUIDE.md        # Testing documentation

🐛 故障排除

问题 解决方案
“找不到Exchange” 检查确切的Exchange ID(小写,例如。, binance 不 Binance)
“超出速率限制” 服务器自动重试,并采用指数回退(最多5次尝试)
“无效符号” 使用格式: BTC/USDT 不 BTCUSDT
“无余额数据” 设置 EXCHANGEID_API_KEY 和 EXCHANGEID_SECRET 环境变量
“无效凭据” 凭据必须在 .env 文件,不在刀具参数中
生成错误 运行 npm install 确保所有依赖项都已安装
类型错误 运行 npm run build -TypeScript配置了Node.js类型

📊 演出

  • ⚡ 响应时间:<2秒(缓存命中率<1ms)
  • 🔄 并发请求:无限制,自动限速
  • 💾 内存使用:<100MB
  • 🌐 Exchange连接:缓存并重复使用
  • 📦 智能缓存:100%覆盖市场数据端点
    • 票务:10秒TTL
    • 订单簿:5s TTL
    • 交易:10秒TTL
    • OHLCV:60s TTL
    • 市场:1小时TTL
  • 🔁 自动重试:错误指数回退(1s→ 2s → 4s → 8s → 16s)

🤝 贡献

这是一个 TAPS v1.0 参考实施。PR欢迎!

  1. 分叉存储库
  2. 创建功能分支
  3. 遵循TAPS v1.0标准
  4. 提交拉取请求

📜 许可证

麻省理工学院-在商业项目中自由使用!

🙏 积分

  • CCXT -令人惊叹的图书馆使这一切成为可能
  • 主控程序 -Anthropic的模型上下文协议
  • TAPS v1.0 -交易API协议标准(为本项目创建)

Built with ❤️ by Myron Koch
First universal crypto exchange MCP server ever created!

CCXT • TAPS v1.0 • MCP

📚 文档