home / mcp / okx mcp server

OKX MCP Server

Provides access to OKX account, trading actions, and market data through an MCP interface using either stdio or HTTP endpoints.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "aahl-mcp-okx": {
      "url": "http://0.0.0.0:8811/mcp",
      "headers": {
        "OKX_API_KEY": "your-okx-api-key",
        "OKX_BASE_URL": "https://www.okx.com",
        "MCP_AUTH_TOKEN": "your-custom-token",
        "OKX_API_SECRET": "api-secret-key",
        "OKX_PASSPHRASE": "api-passphrase",
        "OKX_TRADE_FLAG": "1"
      }
    }
  }
}

You run an MCP server that connects to OKX to fetch market data, manage accounts, and execute trading actions through a unified, programmable interface. This server lets you use both local process execution and remote HTTP endpoints to interact with OKX, exposing a set of trading, market, and account tools you can drive from any MCP client.

How to use

You can access the OKX MCP server from an MCP client by using either a local, stdio-based process or a remote HTTP endpoint. The local option runs a background process that starts with a command and environment variables you provide. The HTTP option exposes a remote, streamable endpoint you can query with standard MCP requests.

How to install

Prerequisites: ensure you have a modern runtime and MCP client setup. You will configure either a local stdio server using uvx or a Docker-based HTTP server that exposes an MCP URL.

Additional configuration and usage notes

Environment variables you will typically set for the local stdio method include your OKX API credentials and trading mode. You can also specify a base URL and an optional authentication token. For the HTTP method, you will point to the MCP URL and provide an Authorization header that contains your API key or a custom token.

Available tools include Account Tools for querying your account state, Trading Tools for placing and managing orders, and Market Data tools for retrieving current market information. Use these tools to build high-level trading automations or dashboards that reflect your OKX trading activity.

Security and best practices

Treat API keys and secrets as sensitive credentials. Use environment isolation for each deployment, rotate credentials regularly, and limit trading permissions to the minimum required by your automation.

Available tools

account_config

Get account configuration

account_balance

Get account balance

account_positions

Get account positions

account_position_risk

Get account position risk

place_order

Place a new order

cancel_order

Cancel an incomplete order

get_trade_order

Get order details

get_order_list

Get incomplete order list

get_orders_history

Get Order History

close_positions

Liquidate all positions

market_tickers

Get cryptocurrency rankings

OKX MCP Server - aahl/mcp-okx