HarshadPanchal12/MCP_server_assignment
If you are the rightful owner of MCP_server_assignment 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 production-grade Model Context Protocol server that provides real-time and historical cryptocurrency market data from multiple exchanges.
🚀 Crypto MCP Server
A production-grade Model Context Protocol (MCP) server that exposes real‑time and historical cryptocurrency market data from multiple exchanges (Binance, Coinbase, Kraken, Bybit, KuCoin) with caching, indicators, and a fully tested Python codebase.
📦 Project Overview
This project implements a Crypto MCP Server that provides:
- 10 fully implemented MCP tools for market data and analytics
- 42 functions across cleanly separated modules (
crypto,mcp_server,utils) - Intelligent TTL‑based caching for performance and rate‑limit protection
- Strong validation and error handling using a custom exception hierarchy
- 32 automated tests (unit + integration) with 90%+ coverage
The codebase is structured and documented as if it were part of a real production system.
📁 Folder Structure
crypto-mcp-server/
├── main.py
├── requirements.txt
├── config.yaml
├── Dockerfile
├── .gitignore
├── README.md
├── API.md
├── SETUP.md
├── src/
│ ├── __init__.py
│ ├── mcp_server/
│ │ ├── __init__.py
│ │ ├── server.py
│ │ └── handlers.py
│ ├── crypto/
│ │ ├── __init__.py
│ │ ├── exchange.py
│ │ ├── market_data.py
│ │ └── cache.py
│ └── utils/
│ ├── __init__.py
│ ├── errors.py
│ ├── logger.py
│ └── validators.py
├── tests/
│ ├── __init__.py
│ ├── unit/
│ │ ├── __init__.py
│ │ ├── test_cache.py
│ │ ├── test_exchange.py
│ │ └── test_market_data.py
│ └── integration/
│ ├── __init__.py
│ └── test_mcp_server.py
├── config/
│ └── __init__.py
└── logs/
└── __init__.py
🔧 Features
Core MCP Tools (10)
get_price– Real‑time price for a single symbolget_prices– Batch prices for up to 100 symbolsget_historical– OHLCV candles (configurable timeframe & periods)get_market_summary– Combined snapshot across multiple symbolsget_sma– Simple Moving Average over historical closesget_volatility– Percentage volatility based on standard deviationget_orderbook– Best bids/asks with configurable depthget_24h_change– 24‑hour change, high, low, and volumecache_status– Cache size, TTL, and keys storedexchange_info– Capabilities and timeframes of the connected exchange
Technical Highlights
- Multi‑exchange support via CCXT
- Intelligent TTL cache with pattern‑based invalidation
- Centralized validation for symbols, timeframes, and limits
- Custom errors for exchange, cache, rate‑limit, and validation failures
- Colored logging to console + rotating log files
- Modular design to reuse
MarketDataServicein other projects
📊 Project Metrics
- Functions: 42
- MCP Tools: 10
- Test Cases: 32 (unit + integration)
- Coverage: 90%+ (line coverage on
src/) - Supported Exchanges: 5
- Supported Timeframes: 9 (1m → 1M)
These numbers can be included in a submission email or documentation.
🚀 Getting Started
1. Clone and enter the project
git clone https://github.com/YOUR_USERNAME/crypto-mcp-server.git
cd crypto-mcp-server
2. Create and activate a virtual environment
python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
source venv/bin/activate
3. Install dependencies
pip install --upgrade pip
pip install -r requirements.txt
4. Run the test suite
pytest -v --cov=src
You should see all 32 tests pass and coverage above 90%.
🖥 Usage
Interactive Mode
Starts an interactive loop where you type JSON requests for tools.
python main.py --mode interactive --exchange binance
Example request:
>>> {"tool": "get_price", "arguments": {"symbol": "BTC/USDT"}}
Example (other useful commands):
tools– list all available tools and their descriptionsquit– exit interactive mode
Demo Mode
Runs a few predefined requests to show typical outputs.
python main.py --mode demo --exchange binance
This will automatically call:
exchange_infoget_priceforBTC/USDTcache_status
⚙️ Configuration
Main configuration is in config.yaml:
server.host/server.port– basic runtime settingscache.enabled,cache.max_size,cache.ttl_seconds– cache tuningexchange.default,exchange.supported– exchange selectionlogging.level,logging.file_path– logging behaviourdata.timeframes,data.max_periods– allowed OHLCV parameters
You can adjust these values without changing code.
🐳 Docker
Build and run using Docker:
docker build -t crypto-mcp-server .
docker run -it --rm crypto-mcp-server
This uses the same entrypoint (main.py) and reads config.yaml from the container.
🧪 Testing Strategy
The tests are split into unit and integration:
tests/unit/test_cache.py– cache behaviour, key generation, invalidationtests/unit/test_exchange.py– exchange connector logic with CCXT mocked- `tests