Skip to main content

MCP server and client for WhiteBit cryptocurrency exchange API

Project description

aiowhitebit-mcp

Message Control Protocol (MCP) server and client implementation for WhiteBit cryptocurrency exchange API. Built on top of aiowhitebit library and fastmcp.

Features

  • MCP server for WhiteBit API with public endpoints
  • Support for multiple transport protocols (stdio, SSE, WebSocket)
  • Easy-to-use client for interacting with the MCP server
  • Command-line interface for running the server
  • Integration with Claude Desktop
  • Real-time market data via WebSocket
  • Comprehensive test coverage and type checking
  • Modern development tools (ruff, pyright, pre-commit)
  • Caching with disk persistence
  • Rate limiting and circuit breaker patterns

Quick Start

# Install the package
pip install aiowhitebit-mcp

# Run the server (stdio transport for Claude Desktop)
aiowhitebit-mcp --transport stdio

# Or run with SSE transport
aiowhitebit-mcp --transport sse --host 127.0.0.1 --port 8000

Basic Usage

Client with Network Transport

import asyncio
import os
from aiowhitebit_mcp.client import WhiteBitMCPClient

async def main():
    # Set the server URL (or use environment variable)
    server_url = "http://localhost:8000/sse"
    os.environ["WHITEBIT_MCP_URL"] = server_url
    
    async with WhiteBitMCPClient() as client:
        # Get market info
        btc_usdt = await client.get_market_resource("BTC_USDT")
        print("BTC/USDT Market Info:", btc_usdt)

        # Get real-time price via WebSocket
        price = await client.get_last_price("BTC_USDT")
        print("Current BTC/USDT price:", price)

        # Get order book
        orderbook = await client.get_orderbook("BTC_USDT")
        print("Order book:", orderbook)

if __name__ == "__main__":
    asyncio.run(main())

Server Configuration

from aiowhitebit_mcp.server import create_server
import asyncio

# Create the server with custom configuration
server = create_server(
    name="WhiteBit API"
)

# Run the server with desired transport
if __name__ == "__main__":
    asyncio.run(
        server.run(
            transport="stdio",  # or "sse"
            host="127.0.0.1",   # for network transports
            port=8000           # for network transports
        )
    )

Available Tools

Public API

  • get_server_time(): Get current server time
  • get_market_info(): Get all markets information
  • get_orderbook(market: str): Get order book
  • get_recent_trades(market: str, limit: int = 100): Get recent trades
  • get_ticker(market: str): Get ticker information
  • get_fee(market: str): Get trading fees
  • get_server_status(): Get server status
  • get_asset_status_list(): Get status of all assets

WebSocket API

  • get_last_price(market: str): Get real-time price
  • get_market_depth(market: str): Get real-time order book

Resources

  • whitebit://markets: Get all markets information
  • whitebit://markets/{market}: Get specific market information
  • whitebit://assets: Get all assets information
  • whitebit://assets/{asset}: Get specific asset information

Command-line Interface

# Show help
aiowhitebit-mcp --help

# Run with stdio transport (for Claude Desktop)
aiowhitebit-mcp --transport stdio

# Run with SSE transport
aiowhitebit-mcp --transport sse --host localhost --port 8000

Development

# Clone the repository
git clone https://github.com/yourusername/aiowhitebit-mcp.git
cd aiowhitebit-mcp

# Install development dependencies
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

# Run tests
pytest

# Run type checking
pyright src/aiowhitebit_mcp

# Run linting
ruff check .

Examples

Check the examples/ directory for more usage examples:

  • claude_desktop_server.py: Run the server with stdio transport for Claude Desktop
  • claude_desktop_client.py: Client for connecting to a stdio server
  • sse_server.py: Run the server with SSE transport
  • sse_client.py: Client for connecting to an SSE server

License

Apache License 2.0

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

aiowhitebit_mcp-0.2.3.tar.gz (35.4 kB view details)

Uploaded Source

Built Distribution

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

aiowhitebit_mcp-0.2.3-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

Details for the file aiowhitebit_mcp-0.2.3.tar.gz.

File metadata

  • Download URL: aiowhitebit_mcp-0.2.3.tar.gz
  • Upload date:
  • Size: 35.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for aiowhitebit_mcp-0.2.3.tar.gz
Algorithm Hash digest
SHA256 17e998b2add6424a55f5c8a0700e967fc44883ab5fc726e2305701a555839578
MD5 fcbe20f6af0af09b57db7b86add9aa03
BLAKE2b-256 c2a76aa8a2530fb57d4a3540100ab39c7d24771f9934ab82b1fadf2a07d68943

See more details on using hashes here.

File details

Details for the file aiowhitebit_mcp-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for aiowhitebit_mcp-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 21ea0c37ba725854c3308e9ccf64eb4ded2877485f8b481ebece1dc4d17f2f05
MD5 a64b47f2711fa1fb5939d6e19296f2a0
BLAKE2b-256 ad059d64f85c1d95852e4d2bdae382e5fa56c3f1b3f9e7a4f46bc1d1771e7f89

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