Skip to main content
Glama
samklein952-hub

Hyperliquid MCP Server

get_positions

Retrieve current open positions showing unrealized profit/loss, leverage levels, and liquidation prices for portfolio management.

Instructions

List all open positions with unrealized PnL, leverage, and liquidation price

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that implements get_positions logic. Fetches user state and returns a list of open positions with symbol, size, entry price, mark price, unrealized PnL, leverage, liquidation price, and margin used.
    def get_positions(self) -> list[dict[str, Any]]:
        """List all open positions with PnL."""
        if not self.wallet_address:
            raise ValueError("HYPERLIQUID_WALLET_ADDRESS is required.")
        state = self.info.user_state(self.wallet_address)
        positions = []
        for pos in state.get("assetPositions", []):
            p = pos.get("position", {})
            if float(p.get("szi", "0")) != 0:
                positions.append({
                    "symbol": p.get("coin"),
                    "size": p.get("szi"),
                    "entry_price": p.get("entryPx"),
                    "mark_price": p.get("positionValue"),
                    "unrealized_pnl": p.get("unrealizedPnl"),
                    "leverage": p.get("leverage", {}).get("value"),
                    "liquidation_price": p.get("liquidationPx"),
                    "margin_used": p.get("marginUsed"),
                })
        return positions
  • Schema/Tool definition for get_positions. Defines the tool name, description, and input schema (no arguments required).
    Tool(
        name="get_positions",
        description="List all open positions with unrealized PnL, leverage, and liquidation price",
        inputSchema={"type": "object", "properties": {}, "required": []},
    ),
  • Tool dispatch registration in the match/case statement. Routes 'get_positions' tool calls to the client handler.
    case "get_positions":
        return client.get_positions()
Behavior3/5

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

No annotations provided, so description carries full burden. It discloses what data is returned (unrealized PnL, leverage, liquidation price), compensating for missing output schema. However, it fails to declare safety properties (read-only/idempotent) or rate limits that agents need for mutation-risk assessment.

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?

Single, dense sentence with zero waste. Front-loaded action verb, followed by resource scope, followed by return value specification. Every clause earns its place.

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

Completeness4/5

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

Given no output schema exists, the description effectively documents return value structure by listing key fields (unrealized PnL, leverage, liquidation price). Adequate for a zero-parameter read operation, though explicit read-only declaration would improve completeness.

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

Parameters4/5

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

Tool has zero parameters, establishing baseline of 4. Description appropriately requires no parameter elaboration since input schema is empty.

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

Purpose5/5

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

Specific verb 'List' + resource 'open positions' clearly defines scope. Explicitly distinguishes from sibling get_open_orders by using 'positions' vs 'orders', and from close_position via 'List' (read) vs 'close' (write). The inclusion of return fields (unrealized PnL, leverage, liquidation price) further clarifies this retrieves active trading exposure data.

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

Usage Guidelines3/5

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

Provides implicit guidance through specific resource naming (distinguishes positions from orders/account), but lacks explicit when-to-use guidance versus alternatives like get_account_info or set_leverage. No explicit prerequisites or exclusions stated.

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/samklein952-hub/hyperliquid-mcp'

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