Provides real-time cryptocurrency market data from OKX exchange through API endpoints for historical candlestick pattern...
Created byApr 23, 2025
OKX MCP Server
A Model Context Protocol server that provides real-time cryptocurrency price data from OKX exchange.
Features
This MCP server connects to the OKX API to provide cryptocurrency price information through a simple tool interface. It includes comprehensive error handling, request logging, and rate limiting via OKX's API.
Tools
`get_candlesticks`
Retrieves historical candlestick (OHLCV) data for any instrument on OKX.
**Input**:
- `instrument`: String (required) - Instrument ID (e.g. "BTC-USDT")
- `bar`: String (optional) - Time interval (e.g. "1m", "5m", "1H", "1D"), default "1m"
- `limit`: Number (optional) - Number of candlesticks to return (max 100), default 100
**Output**: Array of JSON objects, each containing:
- `timestamp`: ISO timestamp of the candlestick
- `open`: Opening price
- `high`: Highest price
- `low`: Lowest price
- `close`: Closing price
- `volume`: Trading volume
- `volumeCurrency`: Volume in currency terms
Example usage:
`get_price`
Fetches the latest price and 24-hour market data for any instrument on OKX.
**Input**:
- `instrument`: String (required) - Instrument ID (e.g. "BTC-USDT")
**Output**: JSON object containing:
- `instrument`: The requested instrument ID
- `lastPrice`: Latest trade price
- `bid`: Current best bid price
- `ask`: Current best ask price
- `high24h`: 24-hour high price
- `low24h`: 24-hour low price
- `volume24h`: 24-hour trading volume
- `timestamp`: ISO timestamp of the data
Example usage:
Development
Install dependencies:
Build the server:
For development with auto-rebuild:
Installation
To use with Claude Desktop or VSCode, add the server config to your MCP settings:
macOS (VSCode):
macOS (Claude Desktop):
Windows (VSCode):
Windows (Claude Desktop):
Configuration:
Error Handling
The server implements comprehensive error handling:
Network errors are captured and returned with context