🚀 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
Metadata
Release files for iflow-mcp_nielsen642-crypto_mcp_server 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| iflow_mcp_nielsen642_crypto_mcp_server-0.1.0.tar.gz | 7.7 kB | Without provenance | Details for iflow_mcp_nielsen642_crypto_mcp_server-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| iflow_mcp_nielsen642_crypto_mcp_server-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for iflow_mcp_nielsen642_crypto_mcp_server-0.1.0-py3-none-any.whl |
Total release size: 17.0 kB
Release files / iflow_mcp_nielsen642_crypto_mcp_server-0.1.0.tar.gz
| Download URL | iflow_mcp_nielsen642_crypto_mcp_server-0.1.0.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cabdbf818f3ee70407f58dc937aeddfe70f7fc7ed2a60df6b906bfc01f694d86
|
|
BLAKE2b-256 checksum How to use checksums |
f1fb7ffd541da5f1b40549a6cb1f22bc4cd396b4e3154a3c52935489b8ed1a11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / iflow_mcp_nielsen642_crypto_mcp_server-0.1.0-py3-none-any.whl
| Download URL | iflow_mcp_nielsen642_crypto_mcp_server-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c0e86e0463586ac8226a5dc3dff04091d27d804ec9fa76ec4b203274d2cfb516
|
|
BLAKE2b-256 checksum How to use checksums |
a612bd7500619a40d5a4673105bf23bae5eb07056e51668c296c62ba2d769fc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Security for iflow-mcp_nielsen642-crypto_mcp_server 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.