Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

okx-mcp

MCP.Pizza Chef: esshka

The okx-mcp server provides real-time cryptocurrency price data from the OKX exchange via the Model Context Protocol. It offers a robust interface to fetch historical candlestick (OHLCV) data for any trading instrument on OKX, supporting various time intervals and limits. The server includes comprehensive error handling, request logging, and respects OKX API rate limits, making it reliable for integrating live market data into AI workflows and applications.

Use This MCP server To

Fetch historical candlestick data for OKX trading pairs Integrate real-time OKX price data into trading bots Log and monitor OKX API requests for analytics Implement rate-limited access to OKX market data Provide structured OHLCV data for financial analysis Enable AI models to query live cryptocurrency prices Support multi-interval candlestick retrieval for charting

README

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:

[
  {
    "timestamp": "2025-03-07T17:00:00.000Z",
    "open": "87242.8",
    "high": "87580.2",
    "low": "86548.0",
    "close": "87191.8",
    "volume": "455.72150427",
    "volumeCurrency": "39661166.242091111"
  }
]

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:

{
  "instrument": "BTC-USDT",
  "lastPrice": "65432.1",
  "bid": "65432.0",
  "ask": "65432.2",
  "high24h": "66000.0",
  "low24h": "64000.0",
  "volume24h": "1234.56",
  "timestamp": "2024-03-07T17:22:28.000Z"
}

Development

Install dependencies:

npm install

Build the server:

npm run build

For development with auto-rebuild:

npm run watch

Installation

To use with Claude Desktop or VSCode, add the server config to your MCP settings:

macOS (VSCode):

~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

macOS (Claude Desktop):

~/Library/Application Support/Claude/claude_desktop_config.json

Windows (VSCode):

%APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

Windows (Claude Desktop):

%APPDATA%/Claude/claude_desktop_config.json

Configuration:

{
  "mcpServers": {
    "okx": {
      "command": "node",
      "args": ["/path/to/okx-mcp-server/build/index.js"],
      "disabled": false,
      "autoApprove": []
    }
  }
}

Error Handling

The server implements comprehensive error handling:

  • Network errors are captured and returned with context
  • Invalid instrument IDs return appropriate error messages
  • API rate limits are respected through axios timeout configuration
  • All errors are logged for debugging purposes

okx-mcp FAQ

How does okx-mcp handle API rate limits?
It implements rate limiting to comply with OKX API restrictions, preventing request overloads.
What data does the get_candlesticks tool return?
It returns OHLCV candlestick data including timestamp, open, high, low, close, volume, and volume in currency.
Can I specify the time interval for candlestick data?
Yes, intervals like 1m, 5m, 1H, and 1D are supported with a default of 1 minute.
How many candlesticks can I request at once?
Up to 100 candlesticks can be retrieved per request, with 100 as the default.
Does okx-mcp support error handling?
Yes, it includes comprehensive error handling to manage API and network issues gracefully.
Is request logging available?
Yes, all API requests are logged for monitoring and debugging purposes.
Can this server be used with multiple LLM providers?
Yes, it is provider-agnostic and can integrate with models like OpenAI, Claude, and Gemini.
How do I specify the instrument for data retrieval?
You provide the instrument ID string, e.g., 'BTC-USDT', as input to the get_candlesticks tool.