crypto-mcp-server

Deepikatingare/crypto-mcp-server

3.1

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

A lightweight FastAPI backend that provides real-time and historical cryptocurrency data using CCXT.

  1. Problem Statement

Cryptocurrency market data is dynamic and changes every second. The goal of this assignment was to build a lightweight Python-based MCP-style backend server that can:

Fetch real-time prices of cryptocurrencies

Fetch historical OHLCV data

Use clean Python structure, caching, and proper API endpoints

Follow MCP-like modular design

This server simulates how a Model Context Protocol source would provide structured external data.

  1. Dataset / APIs Used

Instead of a dataset, this project uses live API data from crypto exchanges.

Data Source: CCXT (Binance API)

Modalities (types of data):

Real-time price feed

OHLCV historical candles (Open, High, Low, Close, Volume)

Format Returned: JSON

Example symbols: "BTC/USDT", "ETH/USDT"

  1. Methods / System Design
  2. Modular Architecture

crypto_service.py → Handles exchange connection + data fetching

cache.py → Small TTL-based cache

mcp_server.py → FastAPI server with routes

  1. Features Implemented

Real-time price endpoint

Historical data endpoint

Error handling

In-memory caching for reducing API load

Clean routing with FastAPI

  1. Evaluation

Since this is a backend server, evaluation is based on:

Response correctness

API uptime

Speed before/after caching

Clean structure & readability

  1. Results ✔ Real-time Price Example

GET /price?symbol=BTC/USDT

Outputs:

{ "data": { "symbol": "BTC/USDT", "price": 96018.44, "timestamp": 1763144986002 }, "cached": false }

✔ Historical Data Example

GET /history?symbol=BTC/USDT&timeframe=1h&limit=50

Returns a list of OHLCV candles.

✔ Caching Performance Feature Without Cache With Cache Response Time Slow Fast API Load High Low

📊 Visualization (optional): /models/results_plot.png (if you add later)

  1. Conclusion

FastAPI provides a clean and reliable structure for MCP-style servers.

CCXT allows easy access to crypto prices and historical data.

Caching greatly improves performance and reduces external calls.

The project demonstrates backend development, API design, and modular Python skills — fulfilling the assignment requirements.

  1. How to Run

  2. Create virtual environment python -m venv venv

  3. Activate

Windows PowerShell:

.\venv\Scripts\Activate.ps1

  1. Install dependencies pip install -r requirements.txt

  2. Run the server uvicorn mcp_server:app --reload

Server runs at:

http://127.0.0.1:8000

  1. API Endpoints GET /price http://127.0.0.1:8000/price?symbol=BTC/USDT

GET /history http://127.0.0.1:8000/history?symbol=BTC/USDT&timeframe=1h&limit=50

  1. Project Structure crypto-mcp-server/ │ ├── mcp_server.py ├── crypto_service.py ├── cache.py ├── requirements.txt └── README.md