0xAuto-okx-mcp-server

Buidl-Land/0xAuto-okx-mcp-server

3.3

If you are the rightful owner of 0xAuto-okx-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

0xAuto OKX MCP Server is a Model Context Protocol server providing a tool interface layer for OKX V5 API and OKX DEX API.

Tools
  1. okx_get_account_info

    Get account information

  2. okx_get_positions

    Get position information

  3. okx_get_balance

    Get account balance

  4. okx_place_order

    Place trade order

  5. okx_cancel_order

    Cancel order

  6. okx_get_orders

    Get order information

  7. okx_get_order_history

    Get historical orders

  8. okx_get_ticker

    Get market quotes

  9. okx_get_kline

    Get K-line data

  10. okx_get_instruments

    Get product list

  11. okx_get_deposit_address

    Get deposit address

  12. okx_get_deposit_history

    Get deposit records

  13. okx_withdraw

    Withdraw funds

  14. okx_get_quote

    Get OKX DEX aggregator quotes

  15. okx_get_supported_chains

    Get chains supported by OKX DEX

  16. okx_get_token_list

    Get token list supported by OKX DEX

  17. okx_get_price

    Get latest price of tokens on OKX DEX

  18. okx_get_kline

    Get K-line data for tokens on OKX DEX

  19. okx_approve_transaction

    Get OKX DEX authorization transaction information

  20. okx_swap

    Initiate OKX DEX swap

  21. okx_cross_chain_swap

    Initiate OKX DEX cross-chain swap

  22. okx_get_balance

    Get all token balances for a wallet address on a specified chain

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

Account-related Tools
  • okx_get_account_info - Get account information
  • okx_get_positions - Get position information
  • okx_get_balance - Get account balance
Trading-related Tools
  • 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
Funding-related Tools
  • 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)
Trading-related Tools
  • 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.