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 "Install 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 Servershow 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
| Name | Required | Description | Default |
|---|---|---|---|
| instrument | Yes | Instrument ID (e.g. BTC-USDT) | |
| bar | No | Time interval (e.g. 1m, 5m, 1H, 1D) | 1m |
| limit | No | Number of candlesticks (max 100) | |
| format | No | Output format (json, markdown, or table) | markdown |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It hints at 'visualization options' but doesn't specify what these entail (e.g., formatting effects, rate limits, or data freshness). This leaves gaps in understanding how the tool behaves beyond basic functionality.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that front-loads the core purpose. It could be slightly more structured by separating visualization details, but it avoids unnecessary verbosity and earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no annotations, no output schema, and a tool with multiple parameters for financial data retrieval, the description is incomplete. It lacks details on return values, error handling, or practical constraints (e.g., data latency), leaving significant gaps for effective agent use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, so parameters are well-documented there. The description adds minimal value by implying 'visualization options' relate to the 'format' parameter, but doesn't elaborate on semantics beyond what the schema provides. This meets the baseline for high schema coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Get candlestick data') and resource ('for an OKX instrument'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_live_ticker' or 'get_price' in terms of data type or granularity, which prevents a perfect score.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description mentions 'visualization options' but provides no guidance on when to use this tool versus alternatives like 'get_live_ticker' or 'get_price'. There are no explicit when-to-use or when-not-to-use instructions, leaving usage context unclear.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_live_tickerC
Get the latest ticker data from WebSocket subscription
| Name | Required | Description | Default |
|---|---|---|---|
| instrument | Yes | Instrument ID (e.g. BTC-USDT) | |
| format | No | Output format (json or markdown) | markdown |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'WebSocket subscription' which implies real-time or streaming data, but doesn't specify latency, rate limits, authentication needs, or what happens if the subscription fails. For a tool with no annotations, this leaves significant gaps in understanding its operational behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity of real-time data tools and the absence of both annotations and an output schema, the description is insufficient. It doesn't explain the return format, error conditions, or how the WebSocket integration works, leaving the agent with incomplete context for reliable tool invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, clearly documenting both parameters ('instrument' and 'format') with details like default values. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline score of 3 where the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Get') and resource ('latest ticker data from WebSocket subscription'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_price' or 'get_candlesticks', which likely provide similar financial data but through different mechanisms or timeframes.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives like 'get_price' or 'subscribe_ticker'. It mentions 'WebSocket subscription' but doesn't clarify if this is for real-time data only or how it differs from other data retrieval methods, leaving the agent to infer usage context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_priceC
Get latest price for an OKX instrument with formatted visualization
| Name | Required | Description | Default |
|---|---|---|---|
| instrument | Yes | Instrument ID (e.g. BTC-USDT) | |
| format | No | Output format (json or markdown) | markdown |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must fully disclose behavioral traits. It mentions 'formatted visualization,' which hints at output behavior, but lacks details on critical aspects like whether this is a read-only operation, potential rate limits, authentication needs, or error handling. The description is too vague to adequately inform the agent about how the tool behaves beyond its basic function.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded with the core action ('Get latest price') and includes the key feature ('formatted visualization'). There is no wasted information, making it highly concise and well-structured.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the lack of annotations and output schema, the description is incomplete for a tool that retrieves financial data. It does not address important contextual elements such as the source of the data (e.g., real-time vs. cached), potential limitations, error scenarios, or the structure of the formatted output. This leaves gaps in understanding the tool's full behavior and constraints.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, with clear documentation for both parameters ('instrument' and 'format'). The description adds minimal value beyond the schema, as it does not explain parameter semantics further (e.g., what 'formatted visualization' entails for the 'format' parameter). With high schema coverage, the baseline score of 3 is appropriate, as the description does not compensate with additional insights.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Get latest price for an OKX instrument with formatted visualization.' It specifies the verb ('Get'), resource ('latest price for an OKX instrument'), and includes the unique aspect of 'formatted visualization.' However, it does not explicitly differentiate from siblings like 'get_candlesticks' or 'get_live_ticker,' which might also retrieve price-related data, preventing a score of 5.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It does not mention sibling tools like 'get_candlesticks' (for historical data) or 'get_live_ticker' (for real-time updates), nor does it specify contexts or exclusions. This lack of comparative usage information limits the agent's ability to select the correct tool.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
subscribe_tickerC
Subscribe to real-time ticker updates for an instrument
| Name | Required | Description | Default |
|---|---|---|---|
| instrument | Yes | Instrument ID (e.g. BTC-USDT) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'real-time ticker updates,' implying a streaming or ongoing operation, but fails to detail critical aspects like whether this initiates a persistent connection, requires authentication, has rate limits, or what happens on subscription (e.g., callback mechanisms or data format). This leaves significant gaps for an agent to understand the tool's behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, clear sentence with zero wasted words, making it highly concise and front-loaded. Every part of the sentence directly contributes to understanding the tool's purpose, earning its place effectively.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity of a subscription tool (implying ongoing data flow) with no annotations and no output schema, the description is incomplete. It doesn't explain what 'subscribe' entails operationally (e.g., how updates are delivered, response format, or error handling), leaving the agent with insufficient information to use the tool correctly in context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, with the 'instrument' parameter fully documented in the schema. The description adds no additional semantic context beyond what the schema provides (e.g., it doesn't clarify the scope of 'real-time' or provide examples beyond the schema's 'BTC-USDT'). Thus, it meets the baseline for high schema coverage without adding extra value.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb ('Subscribe to') and resource ('real-time ticker updates for an instrument'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_live_ticker' or 'unsubscribe_ticker', which would be needed for a perfect score.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives like 'get_live_ticker' (for one-time retrieval) or 'unsubscribe_ticker' (for stopping updates). It also lacks context about prerequisites, such as whether a subscription is needed before use or how it relates to other tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
unsubscribe_tickerC
Unsubscribe from real-time ticker updates for an instrument
| Name | Required | Description | Default |
|---|---|---|---|
| instrument | Yes | Instrument ID (e.g. BTC-USDT) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action but doesn't describe what 'unsubscribe' entails—whether it stops updates immediately, affects other users, requires specific permissions, or has side effects. This leaves critical behavioral traits undocumented for a mutation tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, clear sentence with no wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every part of the sentence contributes directly to understanding the tool's purpose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a mutation tool with no annotations and no output schema, the description is incomplete. It lacks information about what happens after unsubscribing (e.g., confirmation, error handling), behavioral details, and how it integrates with sibling tools. This leaves significant gaps for an agent to use it correctly in context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100%, with the single parameter 'instrument' well-documented in the schema. The description adds no additional semantic context about the parameter, such as format examples beyond what's in the schema or constraints like valid instrument types. This meets the baseline for high schema coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Unsubscribe from') and the resource ('real-time ticker updates for an instrument'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from its sibling 'subscribe_ticker' beyond the obvious opposite action, missing an opportunity to clarify scope or relationship.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives or prerequisites. It doesn't mention if it should only be called after subscribing via 'subscribe_ticker', what happens if unsubscribing from a non-subscribed instrument, or any context about its role relative to sibling tools like 'get_live_ticker'.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
5 tool updates
- First observed
get_candlesticks - First observed
get_live_ticker - First observed
get_price - First observed
subscribe_ticker - First observed
unsubscribe_ticker
TDQS
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
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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.21516MIT
- -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.161MIT
- 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-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/badger3000/okx-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server