mcp-crypto-server

tanvi-argade/mcp-crypto-server

3.1

If you are the rightful owner of mcp-crypto-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 dayong@mcphub.com.

The Crypto MCP Server is a Python-based server that provides real-time and historical cryptocurrency market data using the CCXT library.

📘 Crypto MCP Server

🚀 Overview

This project is a Python-based MCP (Market Context Protocol) server that provides real-time and historical cryptocurrency market data using the CCXT library.

Key features:

  • 📈 Real-time crypto prices
  • 🕒 Historical OHLCV (1-hour candles) data
  • ⚡ In-memory caching to reduce API calls
  • 🧪 Automated tests using PyTest
  • 🛡 Error handling for invalid symbols or API issues

📂 Project Structure

mcp-crypto-server/
│── src/
│   ├── server.py
│   ├── handlers/
│   │   ├── prices.py
│   │   └── historical.py
│   ├── utils/
│   │   └── cache.py
│── tests/
│   ├── test_prices.py
│── requirements.txt
│── README.md

🛠 Tech Stack

ComponentPurpose
Python 3.10+Main language
FastAPIServer framework
CCXTFetch crypto market data
UvicornDevelopment server
PyTestUnit testing
In-memory cacheReduce repeated API calls

🔧 Installation

  1. Clone the repo:
git clone https://github.com/<tanvi-argade>/mcp-crypto-server.git
cd mcp-crypto-server
  1. Create virtual environment:
python -m venv venv
# Activate venv
# Windows
venv\Scripts\activate
# Linux/Mac
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt

▶️ Run the MCP Server

uvicorn src.server:app --reload

Server runs at:

http://127.0.0.1:8000

🔌 API Endpoints

1️⃣ Real-time Prices

GET /prices/current?symbol=BTC/USDT

Example Response:

{
  "symbol": "BTC/USDT",
  "price": 97852.15,
  "timestamp": 1731666406266,
  "cached": false
}

2️⃣ Historical OHLCV Data

GET /historical?symbol=BTC/USDT&days=1

Example Response:

{
  "symbol": "BTC/USDT",
  "days": 1,
  "cached": false,
  "data": [
    {
      "timestamp": "2025-11-15T12:30:00",
      "open": 96121.27,
      "high": 96372.68,
      "low": 95947.68,
      "close": 96333.86,
      "volume": 618.02
    }
  ]
}

🧠 Caching System

  • Cache key: historical:{symbol}:{days}
  • Cached responses return "cached": true
  • Reduces API calls and respects rate limits
  • In-memory cache; resets on server restart

🧪 Running Tests

pytest -v

Expected output:

4 passed in XXs

📌 Assumptions

  • Binance is the default crypto exchange
  • OHLCV timeframe: 1-hour candles
  • No external database; cache stays in memory
  • API rate limits are respected

📈 Future Improvements

  • Replace in-memory cache with Redis
  • Add WebSocket for live prices
  • Add technical indicators (RSI, MACD, EMA)
  • Support multiple exchanges
  • Dockerize the project