MCP server for streaming crypto market data via WebSocket
Project description
Ark Market Data MCP
An MCP (Model Context Protocol) server that streams real-time market data to Claude via WebSocket connection.
Features
- Real-time Market Data Streaming - Connects to a WebSocket server and buffers incoming market data
- OHLCV History - Aggregates live stream into 1m/5m candles persisted to a local SQLite database
- Historical Seeding - One-command backfill from Binance (default 6 months, fully configurable)
- MCP Integration - Works seamlessly with Claude via the Model Context Protocol
- Configurable WebSocket URL - Supports environment variable configuration for flexible deployment
- In-memory Buffering - Efficiently buffers up to 500 messages with configurable size
- Auto-reconnect - Automatically reconnects on connection failures with exponential backoff
Installation
Via PyPI
pip install ark-market-data-mcp
From Source
git clone https://github.com/arkhamides/mcp-market-data.git
cd ark-market-data-mcp
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e .
Quick Start
1. Set up your WebSocket endpoint
export WS_URI=ws://your-websocket-url.com
2. Add to Claude
claude mcp add ark-market-data ark-market-data-mcp
3. Use with Claude
claude chat
Ask Claude to use the market data tools, e.g., "What's the latest market data?"
Seeding Historical Data
Before running backtests, seed the local database with historical candles from Binance.
# Install the historical extra
pip install ark-market-data-mcp[historical]
# or just: pip install ccxt
# Default: BTC/USDT, 1m candles, last 6 months
python scripts/seed_historical.py
# Custom symbol / resolution
python scripts/seed_historical.py --symbol ETH/USDT --resolution 5m
# Custom date range
python scripts/seed_historical.py --start 2024-01-01 --end 2024-07-01
# Custom look-back window
python scripts/seed_historical.py --days 90
# Match your live stream symbol format
python scripts/seed_historical.py --symbol BTC/USDT --store-symbol BTC-USD
Candles are written to ~/.ark-market-data/ohlcv.db (override with DATA_DIR env var).
Re-running is safe — existing candles are upserted, so gaps are filled without duplicates.
Available Tools
The MCP server exposes the following tools for Claude:
Real-time stream
get_latest_message- Get the most recent market message from the streamget_recent_messages- Get the last N messages (default: 10, max: 500)get_stream_status- Check WebSocket connection status and buffer statisticsclear_buffer- Clear the message buffer
Order book analysis
get_market_summary- Best bid/ask, spread, volume imbalance, price change %
Alerts
set_price_alert- Trigger when a symbol crosses a price thresholdset_percent_change_alert- Trigger when price moves by a % over N messagesget_alerts- List all active and triggered alerts
Historical OHLCV
get_ohlcv- Recent closed candles for a symbol and resolution (1m/5m)get_candles_range- Candles between two Unix timestamps
Backtesting
run_backtest- Simulate a trading strategy against historical candles; returns P&L, max drawdown, and full trade log
Connecting for the users of the app
Remote server connection
https://mcp-market-data.com/mcp?api=YOUR_API_KEY
Local server connection
source venv/bin/activate
# Defaults to stdio
python3 -m ark_market_data_mcp
# Explicitly use stdio
python3 -m ark_market_data_mcp stdio
# Use HTTP transport (Docker, remote clients)
python3 -m ark_market_data_mcp http
Development
Test with MCP Inspector
# Terminal 1: Start the server
source venv/bin/activate
WS_URI=ws://your-websocket-url.com python3 -m ark_market_data_mcp
# Terminal 2: Open the MCP Inspector
npx @modelcontextprotocol/inspector
Open http://localhost:5173 in your browser to test tools and messages.
Run tests
pytest
Architecture
┌─────────────────────────┐
│ Claude (User) │
└────────────┬────────────┘
│
│ (via stdio)
│
┌────────────▼────────────┐
│ MCP Server (Python) │
│ - Listens on stdio │
│ - Exposes tools │
└────────────┬────────────┘
│
│ (WebSocket)
│
┌────────────▼───────────────┐
│ Ark Market Data Server │
│ (Remote WebSocket) │
└────────────────────────────┘
Troubleshooting
Connection Refused
If you see "Connection refused" errors:
- Ensure your WebSocket server is running
- Verify the
WS_URIenvironment variable is set correctly - Check firewall settings if using a remote server
No Messages Received
- Verify the WebSocket server is sending data in the expected format
- Check the logs: they show all incoming messages
- Use the
get_stream_statustool to verify connection status
MCP Tools Not Showing Up
- Restart Claude after adding the MCP
- Check that the server starts without errors
- Verify the MCP was added correctly:
claude mcp list
License
MIT
Author
arkhamides
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 ark_market_data_mcp-0.2.0.tar.gz.
File metadata
- Download URL: ark_market_data_mcp-0.2.0.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ead4f439c96378bcb2612e9e764f39419d763580444cd618c5faa664e011cfc
|
|
| MD5 |
dd1d479958c7f50b2f9f0a6bd54818c7
|
|
| BLAKE2b-256 |
cf5041fae48c7ae2460f59585f5bfe888315d854dddbbfeea6f582449ccdd5d9
|
File details
Details for the file ark_market_data_mcp-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ark_market_data_mcp-0.2.0-py3-none-any.whl
- Upload date:
- Size: 23.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6f76a15c8e2f04a2d82250c4aa9a3d71f39c2ad97b3cd048358a0fef9c7f2fc
|
|
| MD5 |
47ee1d665af036662d7c443e58ba2192
|
|
| BLAKE2b-256 |
90380999a1d5c97c52e020c2fa148b8338e6982e9258ce479cc48253e8c3e62d
|