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.
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 pairClone the repository
git clone https://github.com/yourusername/okx-mcp-server.git
cd okx-mcp-server
Install dependencies
npm install
Add the WebSocket dependency
npm install ws
npm install --save-dev @types/ws
Build the project
npm run build
Make the compiled script executable
chmod +x build/index.js
You can run the server directly with:
npm start
Or:
node build/index.js
To test your MCP server before integration:
npx @modelcontextprotocol/inspector node build/index.js
In the inspector, you can test:
get_price
with input: { "instrument": "BTC-USDT", "format": "markdown" }
get_candlesticks
with input: { "instrument": "BTC-USDT", "bar": "1m", "limit": 10, "format": "markdown" }
subscribe_ticker
with input: { "instrument": "BTC-USDT" }
get_live_ticker
with input: { "instrument": "BTC-USDT", "format": "markdown" }
unsubscribe_ticker
with input: { "instrument": "BTC-USDT" }
Each tool supports different visualization formats:
format
: Choose between markdown
, json
, or table
(for candlesticks)Install the Claude extension for VSCode
Configure the MCP server in VSCode settings:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
{
"mcpServers": {
"okx": {
"command": "node",
"args": ["/absolute/path/to/okx-mcp-server/build/index.js"],
"disabled": false,
"autoApprove": []
}
}
}
/absolute/path/to/okx-mcp-server/build/index.js
with your actual file pathRestart VSCode or reload the Claude extension
If using Claude Desktop, check their documentation for the appropriate location to place MCP configuration settings.
Once integrated, you can ask Claude:
The enhanced MCP server provides rich data visualization:
markdown
(default) or json
formatsmarkdown
(default), table
, or json
formatsmarkdown
(default) or json
formatsThis server includes WebSocket support for receiving live data from OKX:
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_passphrase
You can extend this MCP server by:
MIT
{
"mcpServers": {
"okx": {
"env": {},
"args": [
"/absolute/path/to/okx-mcp-server/build/index.js"
],
"command": "node"
}
}
}
Seamless access to top MCP servers powering the future of AI integration.