OKX MCP Server
Fetches real-time cryptocurrency data from the OKX exchange, including current prices, historical candlestick data, and WebSocket-based live ticker updates for trading pairs.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@OKX MCP Server show me the current price of Bitcoin with a visual chart"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
OKX MCP Server
This project creates a Model Context Protocol (MCP) server that fetches real-time cryptocurrency data from the OKX exchange. It allows AI assistants like Claude to access up-to-date cryptocurrency price information and historical data through defined tools with enhanced visualization capabilities and WebSocket live updates.
Features
get_price: Fetches the latest price data for a cryptocurrency trading pair with visual formattingget_candlesticks: Retrieves historical candlestick data with visualization options including ASCII chartssubscribe_ticker: Subscribes to real-time WebSocket updates for a trading pairget_live_ticker: Retrieves the latest live data from WebSocket connectionunsubscribe_ticker: Stops receiving updates for a specific trading pair
Related MCP server: OKX MCP Server
Prerequisites
Node.js (v16 or higher recommended)
npm or yarn
VSCode with Claude extension (if using VSCode integration)
Claude Desktop (if not using VSCode)
Installation
Clone the repository
git clone https://github.com/yourusername/okx-mcp-server.git cd okx-mcp-serverInstall dependencies
npm installAdd the WebSocket dependency
npm install ws npm install --save-dev @types/wsBuild the project
npm run buildMake the compiled script executable
chmod +x build/index.js
Usage
Running the Server Directly
You can run the server directly with:
npm startOr:
node build/index.jsTesting with MCP Inspector
To test your MCP server before integration:
npx @modelcontextprotocol/inspector node build/index.jsIn the inspector, you can test:
get_pricewith input:{ "instrument": "BTC-USDT", "format": "markdown" }get_candlestickswith input:{ "instrument": "BTC-USDT", "bar": "1m", "limit": 10, "format": "markdown" }subscribe_tickerwith input:{ "instrument": "BTC-USDT" }get_live_tickerwith input:{ "instrument": "BTC-USDT", "format": "markdown" }unsubscribe_tickerwith input:{ "instrument": "BTC-USDT" }
Each tool supports different visualization formats:
format: Choose betweenmarkdown,json, ortable(for candlesticks)
Integration with VSCode
Install the Claude extension for VSCode
Configure the MCP server in VSCode settings:
Create or edit the following file:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.jsonAdd the following configuration:
{ "mcpServers": { "okx": { "command": "node", "args": ["/absolute/path/to/okx-mcp-server/build/index.js"], "disabled": false, "autoApprove": [] } } }Replace
/absolute/path/to/okx-mcp-server/build/index.jswith your actual file path
Restart VSCode or reload the Claude extension
Integration with Claude Desktop
If using Claude Desktop, check their documentation for the appropriate location to place MCP configuration settings.
Example Prompts
Once integrated, you can ask Claude:
"What's the current price of Bitcoin (BTC-USDT)? Show me a nicely formatted display."
"Show me the price trend of Ethereum (ETH-USDT) over the last hour using 5-minute intervals with a visual representation."
"Compare the current prices of BTC-USDT and ETH-USDT."
"Analyze the most recent 20 candlesticks for SOL-USDT with 1-minute intervals and display them in a table format."
"Is the current price of BTC-USDT higher or lower than its 24-hour high? Visualize the price range."
"Subscribe to live updates for Bitcoin price and tell me when it changes."
"Show me the latest real-time data for Ethereum."
"Monitor BTC-USDT in real-time and alert me if the price moves by more than 1% in either direction."
Data Visualization Features
The enhanced MCP server provides rich data visualization:
Price Data Visualization
Formatted markdown output with clear price information
Visual price range bar showing where current price sits between 24h high/low
Directional indicators (▲/▼) for price changes
Formatted numbers for better readability
Candlestick Data Visualization
Markdown format: Includes summary statistics, ASCII chart of price movements, and recent price action table
Table format: Clean tabular presentation of candlestick data
JSON format: Raw data for programmatic use
Format Options
get_price: Supports
markdown(default) orjsonformatsget_candlesticks: Supports
markdown(default),table, orjsonformatsget_live_ticker: Supports
markdown(default) orjsonformats
WebSocket Real-time Updates
This server includes WebSocket support for receiving live data from OKX:
How WebSockets Work
Establishes a persistent connection to OKX's WebSocket API
Receives push updates whenever prices change
Maintains a cache of the latest data for each subscribed instrument
Automatically reconnects if the connection is lost
WebSocket Tools
subscribe_ticker: Starts a subscription for real-time ticker updates
get_live_ticker: Gets the latest data from active subscriptions
unsubscribe_ticker: Ends a subscription when monitoring is no longer needed
Use Cases for Real-time Updates
Monitoring price movements in real-time
Setting up price alerts
Tracking market volatility as it happens
Making informed trading decisions with the latest data
Environment Variables (Optional)
This basic implementation uses OKX's public API endpoints that don't require authentication. If you extend the server to use authenticated endpoints, you may want to add these environment variables:
OKX_API_KEY=your_api_key
OKX_API_SECRET=your_api_secret
OKX_API_PASSPHRASE=your_api_passphraseSecurity Notes
The current implementation only uses public OKX API endpoints, so no API keys are required
No sensitive data is stored in the codebase
It's safe to commit this code to Git as is
Extending the Server
You can extend this MCP server by:
Adding more tools for other OKX API endpoints
Implementing authenticated endpoints with API keys
Adding support for other exchanges
Further enhancing the visualizations with more complex charts
Adding technical analysis indicators (RSI, MACD, Moving Averages)
Implementing price comparison tools for multiple cryptocurrencies
Adding market summary features for broader market analysis
License
MIT
Available Tools
5 toolsget_candlesticksC
Get candlestick data for an OKX instrument with visualization options
Inputs: instrument (required), bar, limit, format.
get_live_tickerC
Get the latest ticker data from WebSocket subscription
Inputs: instrument (required), format.
get_priceC
Get latest price for an OKX instrument with formatted visualization
Inputs: instrument (required), format.
subscribe_tickerC
Subscribe to real-time ticker updates for an instrument
Inputs: instrument (required).
unsubscribe_tickerC
Unsubscribe from real-time ticker updates for an instrument
Inputs: instrument (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
The tools are mostly distinct with clear purposes: get_candlesticks for historical data, get_live_ticker for real-time data, get_price for current price, and subscribe/unsubscribe_ticker for WebSocket management. However, get_live_ticker and get_price could be confused as both provide current price information, though one is WebSocket-based and the other is a simple fetch.
All tool names follow a consistent verb_noun pattern with snake_case, such as get_candlesticks, get_live_ticker, and subscribe_ticker. This predictability makes it easy for an agent to understand and use the tools without confusion.
With 5 tools, the server is well-scoped for its purpose of providing OKX market data and real-time updates. Each tool serves a specific function, and there are no redundant or unnecessary additions, making the count appropriate for the domain.
The toolset covers core market data operations well, including historical data, real-time updates, and subscription management. A minor gap exists in the lack of tools for order placement or account management, but for a data-focused server, the coverage is sufficient for typical agent workflows.
Maintenance
Related MCP Connectors
Real-time crypto prices from Binance, Coinbase, Kraken, OKX, and Bybit
Real-time crypto market data: candles, tickers, orderbooks across 13+ exchanges via MCP.
Provide real-time cryptocurrency price data and market analysis.
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides real-time cryptocurrency price data from OKX exchange through a Model Context Protocol interface, allowing access to historical candlestick data and current market prices for any trading instrument.222 npm16MIT
- -licenseBqualityDmaintenanceProvides real-time cryptocurrency price data from OKX exchange through a Model Context Protocol interface.2-
- AlicenseNot gradedqualityDmaintenanceProvides real-time cryptocurrency market data from Binance API, including price queries, 24h statistics, K-line data, market trend analysis, and order book depth information for trading analysis.25 npm1MIT
- FlicenseNot gradedqualityDmaintenanceProvides real-time and historical cryptocurrency market data using ccxt, enabling users to fetch live prices, historical candlestick data, and stream real-time ticker updates across multiple exchanges.14-