Skip to main content

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


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

If you're not sure about the file name format, learn more about wheel file names.

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

Hashes for iflow_mcp_nielsen642_crypto_mcp_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cabdbf818f3ee70407f58dc937aeddfe70f7fc7ed2a60df6b906bfc01f694d86
MD5 3c992f729fb6e32ee10262fb16e17b4e
BLAKE2b-256 f1fb7ffd541da5f1b40549a6cb1f22bc4cd396b4e3154a3c52935489b8ed1a11

See more details on using hashes here.

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

Hashes for iflow_mcp_nielsen642_crypto_mcp_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0e86e0463586ac8226a5dc3dff04091d27d804ec9fa76ec4b203274d2cfb516
MD5 c6d6034daa359466556f73d71d4ecd67
BLAKE2b-256 a612bd7500619a40d5a4673105bf23bae5eb07056e51668c296c62ba2d769fc2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page