Skip to main content
Glama
OKX MCP Server

OKX MCP Server

by esshka

OKX MCP 服务器

提供来自 OKX 交易所的实时加密货币价格数据的模型上下文协议服务器。

特征

该 MCP 服务器连接到 OKX API,通过简单的工具界面提供加密货币价格信息。它通过 OKX 的 API 提供全面的错误处理、请求日志记录和速率限制。

工具

get_candlesticks

检索 OKX 上任何工具的历史烛台(OHLCV)数据。

  • 输入:

    • instrument :字符串(必需)- 工具 ID(例如“BTC-USDT”)

    • bar :字符串(可选) - 时间间隔(例如“1m”、“5m”、“1H”、“1D”),默认“1m”

    • limit :数字(可选) - 返回的烛台数量(最多 100 个),默认 100

  • 输出:JSON 对象数组,每个对象包含:

    • timestamp :烛台的 ISO 时间戳

    • open :开盘价

    • high :最高价格

    • low :最低价格

    • close :收盘价

    • volume :交易量

    • volumeCurrency :以货币计算的交易量

使用示例:

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

获取 OKX 上任何工具的最新价格和 24 小时市场数据。

  • 输入:

    • instrument :字符串(必需)- 工具 ID(例如“BTC-USDT”)

  • 输出:JSON 对象包含:

    • instrument :请求的仪器 ID

    • lastPrice :最新成交价

    • bid :当前最佳出价

    • ask :当前最佳卖价

    • high24h :24小时最高价

    • low24h :24小时最低价

    • volume24h :24小时交易量

    • timestamp :数据的 ISO 时间戳

使用示例:

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

Related MCP server: OKX MCP Server

发展

安装依赖项:

npm install

构建服务器:

npm run build

对于使用自动重建的开发:

npm run watch

安装

要与 Claude Desktop 或 VSCode 一起使用,请将服务器配置添加到您的 MCP 设置中:

macOS(VSCode):

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

macOS(克劳德桌面):

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

Windows(VSCode):

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

Windows(Claude 桌面):

%APPDATA%/Claude/claude_desktop_config.json

配置:

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

错误处理

服务器实现了全面的错误处理:

  • 捕获网络错误并返回上下文

  • 无效的仪器 ID 返回相应的错误消息

  • 通过 axios 超时配置来实现 API 速率限制

  • 所有错误均已记录,以用于调试目的

Available Tools

2 tools
get_candlesticksC

Get candlestick data for an OKX instrument

Inputs: instrument (required), bar, limit.

get_priceC

Get latest price for an OKX instrument

Inputs: instrument (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 2 tools

    Disambiguation4/5

    The two tools have distinct purposes: get_candlesticks retrieves historical price data in candlestick format, while get_price fetches the latest price. There is minimal overlap as they target different data types (historical vs. current), though both relate to instrument pricing which could cause slight confusion in some contexts.

    Naming Consistency5/5

    Both tools follow a consistent verb_noun naming pattern (get_candlesticks, get_price) with clear, descriptive names. The snake_case style is uniform throughout, making the tools easy to identify and predict.

    Tool Count2/5

    With only 2 tools, the server feels severely under-scoped for a financial trading platform like OKX. This minimal set lacks essential operations such as placing orders, managing accounts, or accessing market depth, which are core to trading workflows.

    Completeness2/5

    The tool surface is highly incomplete for an OKX server, covering only price data retrieval. There are significant gaps in trading functionality (e.g., no create_order, cancel_order), account management, or market data beyond basic prices, which will likely cause agent failures in typical trading scenarios.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      F
      maintenance
      A Model Context Protocol server that provides read-only access to Bybit's cryptocurrency exchange API, allowing users to query real-time cryptocurrency data using natural language.
      12
      16
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Provides real-time and historical cryptocurrency price data from the OKX exchange, including live WebSocket updates, candlestick charts, and visual price analysis for trading pairs.
      5
      3
      ISC
    • F
      license
      B
      quality
      D
      maintenance
      Provides access to Tastytrade historical price data via the Model Context Protocol. It enables users to retrieve historical candle data for specific financial symbols and time intervals.
      1
      -