Provides real-time and historical cryptocurrency market data from Binance exchange, including live price lookups and OHLCV (Open, High, Low, Close, Volume) historical queries for cryptocurrency trading pairs.
MCP Crypto Market Data Server
This project is a Python-based MCP server that provides real-time and historical cryptocurrency market data. The server is built using FastAPI, and it fetches data from major exchanges through CCXT. The goal of this project was to understand how MCP servers work, how to interact with crypto APIs, and how to build a clean, modular Python backend.
*Why I Built It
The assignment required a small MCP server with features like:
endpoints to fetch data
support for real-time updates
historical queries
caching
structured code
test coverage
I kept the code simple so anyone can read it easily, while still keeping the structure clean.
*Features Implemented
Live price lookup
Historical OHLCV (1 hour candles, last 24 hours)
Lightweight caching
Error handling
Tests using pytest
Clean folder structure
**Project Structure
mcp-server/ ├─ app/ │ ├─ main.py │ ├─ services/ccxt_client.py │ ├─ cache.py │ ├─ models.py │ └─ exceptions.py ├─ tests/test_api.py ├─ requirements.txt └─ README.md
***Technologies Used
FastAPI
CCXT
Pytest
Uvicorn
Python
**Endpoints
Root GET / Response: { "message": "Crypto MCP Server running" }
Latest Price GET /price/{symbol} Example: /price/BTC
Historical OHLCV GET /history/{symbol} Example: /history/ETH
***How to Run
Install dependencies pip install -r requirements.txt
Start the server uvicorn app.main:app --reload
Test API http://127.0.0.1:8000/price/BTC http://127.0.0.1:8000/history/ETH
Run Tests pytest
***Assumptions
Binance is the default exchange.
Symbols assumed to trade against USDT.
Cache expiry: 10 seconds.
Historical timeframe: 1h.
***Possible Improvements
Support multiple exchanges
WebSocket streaming
Redis caching
More detailed tests
Environment variables
Conclusion
This project meets the MCP assignment requirements with clear Python code, real-time crypto data, historical queries, caching, structured layout, and test coverage.