Skip to content

saad-78/Py-Crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP Crypto Market Data Server

Python-based MCP server that exposes real-time and historical cryptocurrency market data using CCXT and FastMCP.

Features

  • MCP tools:
    • health_check – simple server health probe.
    • get_current_price – latest ticker for a symbol (e.g. BTC/USDT) on a given exchange.
    • get_order_book – bids/asks snapshot with configurable limit.
    • get_historical_ohlcv – historical OHLCV candles for a symbol, timeframe, since, and limit.
    • stream_ticker – polling-based ticker streaming via async generator.
  • In-memory TTL cache for:
    • ticker, order book, and OHLCV responses.
  • Robust error handling:
    • custom exceptions for validation, unsupported exchanges/symbols, and upstream API errors.
  • Test suite with pytest, pytest-asyncio, and CCXT mocking.

Tech Stack

  • Python 3.12
  • FastMCP – MCP server framework.
  • CCXT – crypto exchange market data.
  • pytest, pytest-asyncio – testing.

Project Structure

src/mcp_crypto_server/ config.py # Defaults and TTLs cache.py # Simple TTL in-memory cache errors.py # Custom error types and normalization exchanges.py # CCXT wrapper with caching and error mapping schemas.py # Typed dicts for responses tools.py # MCP tools + plain *_impl functions server.py # Entry point (mcp.run()) tests/ test_cache.py test_exchanges.py test_tools.py test_placeholder.py

Setup

git clone <YOUR_REPO_URL> cd mcp-crypto-server

python3 -m venv .venv source .venv/bin/activate # Windows: ..venv\Scripts\activate

python -m pip install --upgrade pip python -m pip install -e ".[dev]"

or, if needed: python -m pip install fastmcp ccxt pytest pytest-asyncio

Running Tests

pytest

All tests should pass.

Running the MCP Server

python -m mcp_crypto_server.server

This starts the MCP server over stdio, ready to be used by an MCP-compatible client (Claude Desktop, etc.). Tools available:

  • health_check
  • get_current_price
  • get_order_book
  • get_historical_ohlcv
  • stream_ticker

Assumptions & Limitations

  • Uses public CCXT endpoints only (no authentication, spot markets only).
  • Caching is in-memory; suitable for a single-process server.
  • stream_ticker uses polling at a configurable interval, not WebSocket streams.
  • Basic validation on symbols (BASE/QUOTE), timeframes, and limits.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages