Skip to main content
Glama
aahl

OKX MCP Server

by aahl

Get account position risk

account_position_risk

Analyze overall holding risk for your OKX account across margin, futures, swaps, and options to monitor portfolio exposure.

Instructions

Obtain the overall holding risk of the OKX account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instTypeNoInstrument type: `MARGIN`: 币币杠杆/`SWAP`: 永续合约/`FUTURES`: 交割合约/`OPTION`: 期权. Optional, all by default if not passed

Implementation Reference

  • The handler function for the 'account_position_risk' tool. It calls the OKX AccountAPI to get position risk data based on instrument type and attaches a detailed response schema.
    def account_position_risk(
        instType: str = Field("", description="Instrument type: "
                                              "`MARGIN`: 币币杠杆/"
                                              "`SWAP`: 永续合约/"
                                              "`FUTURES`: 交割合约/"
                                              "`OPTION`: 期权. "
                                              "Optional, all by default if not passed"),
    ):
        resp = ACCOUNT.get_position_risk(instType) or {}
        if int(resp.get("code", 0)):
            return resp
        resp["_response_schema"] = """
        adjEq: Adjusted / Effective equity in USD. Applicable to Multi-currency margin and Portfolio margin
        balData: Detailed asset information in all currencies
        balData.ccy: Currency
        balData.eq: Equity of currency
        balData.disEq: Discount equity of currency in USD
        posData: Detailed position information in all currencies
        posData.mgnMode: Margin mode: cross/isolated
        posData.instId: Instrument ID, e.g. BTC-USDT-SWAP
        posData.pos: Quantity of positions contract. In the isolated margin mode, when doing manual transfers,
            a position with pos of 0 will be generated after the deposit is transferred
        posData.posSide: Position side: long/short
            net (FUTURES/SWAP/OPTION: positive pos means long position and negative pos means short position. MARGIN: posCcy being base currency means long position, posCcy being quote currency means short position.)
        posData.posCcy: Position currency, only applicable to MARGIN positions
        posData.ccy: Currency used for margin
        posData.notionalCcy: Notional value of positions in coin
        posData.notionalUsd: Notional value of positions in USD
        """
        return resp
  • The @mcp.tool decorator registers the account_position_risk tool with FastMCP inside the add_tools function.
    @mcp.tool(
        title="Get account position risk",
        description="Obtain the overall holding risk of the OKX account",
    )
  • Top-level registration call that invokes add_tools from the account module to register all account-related tools, including account_position_risk.
    account.add_tools(mcp)
  • The response schema documentation string attached to the API response for the account_position_risk tool.
    resp["_response_schema"] = """
    adjEq: Adjusted / Effective equity in USD. Applicable to Multi-currency margin and Portfolio margin
    balData: Detailed asset information in all currencies
    balData.ccy: Currency
    balData.eq: Equity of currency
    balData.disEq: Discount equity of currency in USD
    posData: Detailed position information in all currencies
    posData.mgnMode: Margin mode: cross/isolated
    posData.instId: Instrument ID, e.g. BTC-USDT-SWAP
    posData.pos: Quantity of positions contract. In the isolated margin mode, when doing manual transfers,
        a position with pos of 0 will be generated after the deposit is transferred
    posData.posSide: Position side: long/short
        net (FUTURES/SWAP/OPTION: positive pos means long position and negative pos means short position. MARGIN: posCcy being base currency means long position, posCcy being quote currency means short position.)
    posData.posCcy: Position currency, only applicable to MARGIN positions
    posData.ccy: Currency used for margin
    posData.notionalCcy: Notional value of positions in coin
    posData.notionalUsd: Notional value of positions in USD
    """
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'obtains' risk data, implying a read-only operation, but doesn't clarify permissions, rate limits, or what 'overall holding risk' entails (e.g., metrics, format, or scope). This leaves significant gaps for a tool that likely involves financial data.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that directly states the tool's purpose without unnecessary words. It's front-loaded and efficiently conveys the essential information, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of financial risk data and the lack of annotations and output schema, the description is insufficient. It doesn't explain what 'overall holding risk' includes (e.g., risk metrics, calculations, or output format), leaving the agent without enough context to use the tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, documenting the single optional parameter 'instType' with its types and default behavior. The description adds no parameter-specific information beyond what's in the schema, so it meets the baseline for adequate but not enhanced coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Obtain') and target resource ('overall holding risk of the OKX account'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'account_positions' or 'account_balance', which might also provide risk-related information, so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, context, or compare it to siblings such as 'account_positions' or 'account_balance', leaving the agent with no usage instructions beyond the basic purpose.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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