Sponsored by Deepsite.site

0xAuto OKX MCP Server

Created By
Buidl-Land6 months ago
Content

0xAuto OKX MCP Server

This server is based on the Model Context Protocol (MCP), providing a tool interface layer for OKX V5 API and OKX DEX API, offering AI agents simplified access to OKX exchange (CEX) and decentralized exchange (DEX) functionalities.

Features

CEX (Centralized Exchange) Features

  • Hides complex OKX API authentication and signature logic
  • Provides standard MCP tool interfaces
  • Covers core functionalities:
    • Account information (balances, positions, history)
    • Market data (quotes, K-lines)
    • Trading operations (place orders, cancel orders, order management)
    • Funding operations (deposit addresses, withdrawals)

DEX (Decentralized Exchange) Features

  • Provides access to OKX DEX aggregator

  • Supports multi-chain transactions and token exchanges

  • Covers functionalities:

    • Token quote retrieval
    • Token price queries and K-line data
    • On-chain balance queries
    • Token authorization operations
    • Intra-chain and cross-chain swaps
  • Standardized JSON responses and error handling

  • Support for MCP protocol session management and streaming

System Requirements

  • Node.js (v16 or higher)
  • pnpm

Installation Steps

  1. Install dependencies:

    pnpm install
    
  2. Set up environment variables: Create a .env file by copying the contents from .env.example:

    cp .env.example .env
    

    Edit the .env file and fill in your OKX API credentials and other settings:

    # OKX API Configuration
    OKX_API_KEY=your_okx_api_key
    OKX_SECRET_KEY=your_okx_secret_key
    OKX_PASSPHRASE=your_okx_api_password
    OKX_API_BASE_URL=https://www.okx.com
    OKX_DEX_API_BASE=https://web3.okx.com/api/v5/dex
    
    # Simulated trading: 0 for live trading, 1 for demo account
    SIMULATED_TRADING=0
    
    SERVER_PORT=3000
    LOG_LEVEL=info
    

    Important note: Ensure your OKX API Key has the necessary permissions (read, trade).

Running the Server

pnpm start
# or development mode
pnpm dev

The server will start on the port specified by SERVER_PORT (default 3000).

MCP Tool List

The server implements the following MCP tools:

CEX (Centralized Exchange) Tools

  • okx_get_account_info - Get account information
  • okx_get_positions - Get position information
  • okx_get_balance - Get account balance
  • okx_place_order - Place trade order
  • okx_cancel_order - Cancel order
  • okx_get_orders - Get order information
  • okx_get_order_history - Get historical orders

Market Data Tools

  • okx_get_ticker - Get market quotes
  • okx_get_kline - Get K-line data
  • okx_get_instruments - Get product list
  • okx_get_deposit_address - Get deposit address
  • okx_get_deposit_history - Get deposit records
  • okx_withdraw - Withdraw funds

DEX (Decentralized Exchange) Tools

Quotes and Market Data

  • okx_get_quote - Get OKX DEX aggregator quotes (supports slippage settings)
  • okx_get_supported_chains - Get chains supported by OKX DEX
  • okx_get_token_list - Get token list supported by OKX DEX
  • okx_get_price - Get latest price of tokens on OKX DEX
  • okx_get_kline - Get K-line data for tokens on OKX DEX (supports different time granularities)
  • okx_approve_transaction - Get OKX DEX authorization transaction information
  • okx_swap - Initiate OKX DEX swap
  • okx_cross_chain_swap - Initiate OKX DEX cross-chain swap

Balance Queries

  • okx_get_balance - Get all token balances for a wallet address on a specified chain

Project Structure

src/
├── app.js              # Express application configuration
├── index.js            # Server startup entry
├── server.js           # MCP server creation and tool registration
├── config/             # Configuration files
├── controllers/        # Controller logic
├── middleware/         # Middleware
├── services/           # Service layer
│   ├── okxService.js   # OKX CEX API service
│   └── okxDexService.js# OKX DEX API service
├── tools/              # MCP tool implementation
│   ├── accountTools.js # CEX account tools
│   ├── fundingTools.js # CEX funding tools
│   ├── marketTools.js  # CEX market tools
│   ├── tradeTools.js   # CEX trading tools
│   ├── dexTools.js     # DEX tool registration
│   └── dex/            # DEX tool files
│       ├── quoteTool.js         # Quote tool
│       ├── supportedChainsTool.js# Supported chains tool
│       ├── tokenListTool.js     # Token list tool
│       ├── priceTool.js         # Price tool
│       ├── klineTool.js         # K-line tool
│       ├── balanceTool.js       # Balance tool
│       ├── approveTool.js       # Approval tool
│       ├── swapTool.js          # Swap tool
│       └── crossChainSwapTool.js# Cross-chain swap tool
└── utils/              # Utility functions

MCP Client Connection

MCP clients can communicate with the server through the following endpoints:

  • /mcp - Main MCP request endpoint
  • /sse - Backward-compatible SSE endpoint
  • /messages - Backward-compatible message endpoint

Uses standard MCP session management, including session ID and initialization requests.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
DeepChatYour AI Partner on Desktop
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
CursorThe AI Code Editor
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
ChatWiseThe second fastest AI chatbot™
Playwright McpPlaywright MCP server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Amap Maps高德地图官方 MCP Server
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Tavily Mcp
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Serper MCP ServerA Serper MCP Server
WindsurfThe new purpose-built IDE to harness magic
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.