Skip to main content
Glama
aahl

OKX MCP Server

by aahl

account_config

Retrieve current OKX account configuration to prepare for trading operations and account management tasks on the cryptocurrency exchange.

Instructions

Retrieve current OKX account configuration. It is recommended to use this tool to obtain account configuration information before using all other tools

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'account_config' tool. It fetches the account configuration from the OKX API using the pre-initialized ACCOUNT instance and attaches a detailed response schema documentation.
    @mcp.tool(
        title="Get account configuration",
        description="Retrieve current OKX account configuration. "
                    "It is recommended to use this tool to obtain account configuration information before using all other tools",
    )
    def account_config():
        resp = ACCOUNT.get_account_config() or {}
        if int(resp.get("code", 0)):
            return resp
        resp["_response_schema"] = """
        uid	String	Account ID of current request
        mainUid	String	Main Account ID of current request.
            The current request account is main account if uid = mainUid.
            The current request account is sub-account if uid != mainUid.
        acctLv	String	Account mode
            1: Spot mode
            2: Futures mode
            3: Multi-currency margin
            4: Portfolio margin
        acctStpMode	String	Account self-trade prevention mode: cancel_maker/cancel_taker/cancel_both
            The default value is cancel_maker. Users can log in to the webpage through the master account to modify this configuration
        posMode	String	Position mode. long_short_mode: long/short, only applicable to FUTURES/SWAP; net_mode: net
        autoLoan	Boolean	Whether to borrow coins automatically
            true: borrow coins automatically
            false: not borrow coins automatically
        feeType	String	Fee type
            0: fee is charged in the currency you receive from the trade
            1: fee is always charged in the quote currency of the trading pair
        level	String	The user level of the current real trading volume on the platform, e.g Lv1, which means regular user level
        levelTmp	String	Temporary experience user level of special users, e.g Lv1
        ctIsoMode	String	Contract isolated margin trading settings. automatic: Auto transfers; autonomy: Manual transfers
        mgnIsoMode	String	Margin isolated margin trading settings
            auto_transfers_ccy: New auto transfers, enabling both base and quote currency as the margin for isolated margin trading
            automatic: Auto transfers
            quick_margin: Quick Margin Mode (For new accounts, including subaccounts, some defaults will be automatic, and others will be quick_margin)
        roleType	String	Role type
            0: General user
            1: Leading trader
            2: Copy trader
        traderInsts	Array of strings	Leading trade instruments, only applicable to Leading trader
        spotRoleType	String	SPOT copy trading role type. 0: General user; 1: Leading trader; 2: Copy trader
        spotTraderInsts	Array of strings	Spot lead trading instruments, only applicable to lead trader
        opAuth	String	Whether the optional trading was activated. 0: not activate; 1: activated
        kycLv	String	Main account KYC level
            0: No verification
            1: level 1 completed
            2: level 2 completed
            3: level 3 completed
            If the request originates from a subaccount, kycLv is the KYC level of the main account.
            If the request originates from the main account, kycLv is the KYC level of the current account.
        label	String	API key note of current request API key. No more than 50 letters (case sensitive) or numbers, which can be pure letters or pure numbers
        ip	String	IP addresses that linked with current API key, separate with commas if more than one. It is an empty string "" if there is no IP bonded.
        perm	String	The permission of the current requesting API key or Access token. read_only: Read; trade: Trade; withdraw: Withdraw
        liquidationGear	String	The maintenance margin ratio level of liquidation alert
            3 and -1 means that you will get hourly liquidation alerts on app and channel "Position risk warning" when your margin level drops to or below 300%. -1 is the initial value which has the same effect as -3
            0 means that there is not alert
        enableSpotBorrow	Boolean	Whether borrow is allowed or not in Spot mode. true: Enabled; false: Disabled
        spotBorrowAutoRepay	Boolean	Whether auto-repay is allowed or not in Spot mode. true: Enabled; false: Disabled
        type	String	Account type
            0: Main account
            1: Standard sub-account
            2: Managed trading sub-account
            5: Custody trading sub-account - Copper
            9: Managed trading sub-account - Copper
            12: Custody trading sub-account - Komainu
        settleCcy	String	Current account's USD-margined contract settle currency
        settleCcyList	String	Current account's USD-margined contract settle currency list, like ["USD", "USDC", "USDG"]
        """
        return resp
  • Registration of the account tools, including 'account_config', by calling add_tools on the imported account module with the MCP server instance.
    account.add_tools(mcp)
  • Initialization of the OKX AccountAPI client instance used by the account_config handler, configured with credentials from config.py.
    ACCOUNT = AccountAPI(
        api_key=OKX_API_KEY,
        api_secret_key=OKX_API_SECRET,
        passphrase=OKX_PASSPHRASE,
        flag=OKX_TRADE_FLAG,
        domain=OKX_BASE_URL,
    )
  • Detailed schema and field descriptions for the response returned by the account_config tool.
    resp["_response_schema"] = """
    uid	String	Account ID of current request
    mainUid	String	Main Account ID of current request.
        The current request account is main account if uid = mainUid.
        The current request account is sub-account if uid != mainUid.
    acctLv	String	Account mode
        1: Spot mode
        2: Futures mode
        3: Multi-currency margin
        4: Portfolio margin
    acctStpMode	String	Account self-trade prevention mode: cancel_maker/cancel_taker/cancel_both
        The default value is cancel_maker. Users can log in to the webpage through the master account to modify this configuration
    posMode	String	Position mode. long_short_mode: long/short, only applicable to FUTURES/SWAP; net_mode: net
    autoLoan	Boolean	Whether to borrow coins automatically
        true: borrow coins automatically
        false: not borrow coins automatically
    feeType	String	Fee type
        0: fee is charged in the currency you receive from the trade
        1: fee is always charged in the quote currency of the trading pair
    level	String	The user level of the current real trading volume on the platform, e.g Lv1, which means regular user level
    levelTmp	String	Temporary experience user level of special users, e.g Lv1
    ctIsoMode	String	Contract isolated margin trading settings. automatic: Auto transfers; autonomy: Manual transfers
    mgnIsoMode	String	Margin isolated margin trading settings
        auto_transfers_ccy: New auto transfers, enabling both base and quote currency as the margin for isolated margin trading
        automatic: Auto transfers
        quick_margin: Quick Margin Mode (For new accounts, including subaccounts, some defaults will be automatic, and others will be quick_margin)
    roleType	String	Role type
        0: General user
        1: Leading trader
        2: Copy trader
    traderInsts	Array of strings	Leading trade instruments, only applicable to Leading trader
    spotRoleType	String	SPOT copy trading role type. 0: General user; 1: Leading trader; 2: Copy trader
    spotTraderInsts	Array of strings	Spot lead trading instruments, only applicable to lead trader
    opAuth	String	Whether the optional trading was activated. 0: not activate; 1: activated
    kycLv	String	Main account KYC level
        0: No verification
        1: level 1 completed
        2: level 2 completed
        3: level 3 completed
        If the request originates from a subaccount, kycLv is the KYC level of the main account.
        If the request originates from the main account, kycLv is the KYC level of the current account.
    label	String	API key note of current request API key. No more than 50 letters (case sensitive) or numbers, which can be pure letters or pure numbers
    ip	String	IP addresses that linked with current API key, separate with commas if more than one. It is an empty string "" if there is no IP bonded.
    perm	String	The permission of the current requesting API key or Access token. read_only: Read; trade: Trade; withdraw: Withdraw
    liquidationGear	String	The maintenance margin ratio level of liquidation alert
        3 and -1 means that you will get hourly liquidation alerts on app and channel "Position risk warning" when your margin level drops to or below 300%. -1 is the initial value which has the same effect as -3
        0 means that there is not alert
    enableSpotBorrow	Boolean	Whether borrow is allowed or not in Spot mode. true: Enabled; false: Disabled
    spotBorrowAutoRepay	Boolean	Whether auto-repay is allowed or not in Spot mode. true: Enabled; false: Disabled
    type	String	Account type
        0: Main account
        1: Standard sub-account
        2: Managed trading sub-account
        5: Custody trading sub-account - Copper
        9: Managed trading sub-account - Copper
        12: Custody trading sub-account - Komainu
    settleCcy	String	Current account's USD-margined contract settle currency
    settleCcyList	String	Current account's USD-margined contract settle currency list, like ["USD", "USDC", "USDG"]
    """

Latest Blog Posts

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/aahl/mcp-okx'

If you have feedback or need assistance with the MCP directory API, please join our Discord server