OKX Cryptocurrency MCP server

Provides real-time cryptocurrency market data from OKX exchange through API endpoints for historical candlestick patterns and current price information
Back to servers
Provider
esshka
Release date
Mar 08, 2025
Language
TypeScript
Stats
9 stars

This server provides real-time cryptocurrency price data from OKX exchange through the Model Context Protocol framework. It allows AI assistants to access current and historical price information for any cryptocurrency instrument available on OKX.

Installation

To install and configure the OKX MCP server, follow these steps:

Prerequisites

Ensure you have Node.js installed on your system.

Server Setup

  1. Clone the repository or download the source code
  2. Install dependencies:
npm install
  1. Build the server:
npm run build

Configuration

Add the server to your MCP settings based on your operating system and application:

For VSCode

MacOS:

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

Windows:

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

For Claude Desktop

MacOS:

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

Windows:

%APPDATA%/Claude/claude_desktop_config.json

Add the following configuration to your MCP settings file:

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

Make sure to replace /path/to/okx-mcp-server with the actual path where you installed the server.

Usage

The OKX MCP server provides two main tools for accessing cryptocurrency data:

Get Current Price

The get_price tool provides the latest price and 24-hour market data for any cryptocurrency instrument on OKX.

Input parameters:

  • instrument: String (required) - Instrument ID (e.g., "BTC-USDT")

Example output:

{
  "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"
}

Get Historical Candlestick Data

The get_candlesticks tool retrieves historical OHLCV (Open, High, Low, Close, Volume) data for any instrument on OKX.

Input parameters:

  • 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

Example output:

[
  {
    "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"
  }
]

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
  • All errors are logged for debugging purposes

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later