Crypto MCP Server - Provides real-time and historical cryptocurrency market data using ccxt
Project description
๐ Crypto MCP Server
๐ Overview
Crypto MCP Server is a Model Context Protocol (MCP) compatible server that provides real-time and historical cryptocurrency market data using ccxt. It exposes three fully tested tools:
get_ticker โ Live price & market summary
get_ohclv โ Historical candlestick data
stream_ticker โ Real-time price streaming (async generator)
The project includes:
Custom error handling
In-memory caching
A lightweight MCP server architecture
Complete test suite (pytest)
Local client for manual testing
โจ Features
๐น get_ticker
Fetches:
last price
high & low
base volume
price_change_percent
๐น get_ohclv
Fetches OHLCV candles with:
timestamp
open
high
low
close
volume
๐น stream_ticker
Real-time streaming ticker with async generator that yields updates every N seconds.
๐งฉ Project Structure
crypto-mcp-server/ โ โโโ server/ โ โโโ main.py โ โโโ mcp_server.py โ โโโ cache.py โ โโโ errors.py โ โโโ exchanges.py โ โโโ tools/ โ โโโ get_ticker.py โ โโโ get_ohclv.py โ โโโ stream_ticker.py โ โโโ tests/ โ โโโ test_get_ticker.py โ โโโ test_ohclv.py โ โโโ test_stream_ticker.py โ โโโ client_test.py โโโ README.md โโโ requirements.txt โโโ .gitignore
๐ ๏ธ Tech Stack
Python 3.10+
ccxt for exchange APIs
pytest for testing
asyncio for streaming
MCP server protocol style
๐ฆ Installation
git clone https://github.com/yourusername/crypto-mcp-server cd crypto-mcp-server pip install -r requirements.txt
โถ๏ธ Running the MCP Server
From the server/ directory:
python -m server.main
You should see:
Crypto MCP Server runningโฆ Registered tools: get_ticker, get_ohclv, stream_ticker
๐งช Running Tests
All tests are under tests/ and cover:
Valid/invalid symbols
Unsupported exchanges
API errors
Streaming behavior
Run:
pytest -vv
๐ Tools Implemented
๐น get_ticker
Handles:
Invalid symbols
Unsupported exchanges
ccxt API exceptions
Caching responses for 20 seconds
๐น get_ohclv
Returns OHCLV historical candles
Validates timeframe & limit
Raises custom errors
๐น stream_ticker
Async generator
Streams live ticker updates
Internal delay using asyncio.sleep()
Full validation & error handling
Caching Layer
cache.py implements simple in-memory TTL cache:
save(key, value, ttl)
get(key)
Prevents extra API calls
๐งช Testing Strategy
Unit Tests (pytest)
Each tool has:
success test
invalid symbol test
invalid exchange test
API failure test
Streaming Tests
Uses asyncio.mark
Simulates multiple ticker updates
Checks generator behavior
๐งช Local Testing Without MCP CLI
Run:
python client_test.py
It prints:
get_ticker result
get_ohclv candles
3 streamed ticker updates
๐ Example Output
--- Testing get_ticker --- {...}
--- Testing get_ohclv --- {...}
--- Testing stream_ticker --- {...}
๐ Key Learning & Highlights
Designed full MCP-style server
Implemented async streaming tool
Wrote complete test suite
Built caching + error handling abstraction
Validated exchange + symbol inputs safely
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iflow_mcp_nielsen642_crypto_mcp_server-0.1.0.tar.gz.
File metadata
- Download URL: iflow_mcp_nielsen642_crypto_mcp_server-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cabdbf818f3ee70407f58dc937aeddfe70f7fc7ed2a60df6b906bfc01f694d86
|
|
| MD5 |
3c992f729fb6e32ee10262fb16e17b4e
|
|
| BLAKE2b-256 |
f1fb7ffd541da5f1b40549a6cb1f22bc4cd396b4e3154a3c52935489b8ed1a11
|
File details
Details for the file iflow_mcp_nielsen642_crypto_mcp_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: iflow_mcp_nielsen642_crypto_mcp_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0e86e0463586ac8226a5dc3dff04091d27d804ec9fa76ec4b203274d2cfb516
|
|
| MD5 |
c6d6034daa359466556f73d71d4ecd67
|
|
| BLAKE2b-256 |
a612bd7500619a40d5a4673105bf23bae5eb07056e51668c296c62ba2d769fc2
|