Skip to main content
Glama
samklein952-hub

Hyperliquid MCP Server

set_leverage

Adjust leverage settings for perpetual trading positions on Hyperliquid to manage risk exposure and trading strategy.

Instructions

Set leverage for a perpetual market

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesMarket symbol
leverageYesLeverage multiplier (e.g. 5, 10, 20)
is_crossNoUse cross margin (default: true)

Implementation Reference

  • The handler function that executes set_leverage logic. It calls the Hyperliquid exchange API to update leverage for a given symbol.
    def set_leverage(self, symbol: str, leverage: int, is_cross: bool = True) -> dict[str, Any]:
        """Set leverage for a market."""
        exchange = self._require_exchange()
        result = exchange.update_leverage(leverage, symbol.upper(), is_cross=is_cross)
        return {"symbol": symbol, "leverage": leverage, "cross": is_cross, "result": result}
  • The JSON schema definition for the set_leverage tool, specifying input parameters: symbol (string), leverage (integer), and is_cross (boolean, default true).
    Tool(
        name="set_leverage",
        description="Set leverage for a perpetual market",
        inputSchema={
            "type": "object",
            "properties": {
                "symbol": {"type": "string", "description": "Market symbol"},
                "leverage": {"type": "integer", "description": "Leverage multiplier (e.g. 5, 10, 20)"},
                "is_cross": {"type": "boolean", "description": "Use cross margin (default: true)", "default": True},
            },
            "required": ["symbol", "leverage"],
        },
    ),
  • The dispatch case that routes set_leverage tool calls to the client handler, extracting symbol, leverage, and optional is_cross from arguments.
    case "set_leverage":
        return client.set_leverage(args["symbol"], args["leverage"], args.get("is_cross", True))
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 but fails to mention critical trading implications: whether this affects liquidation prices, if changes apply retroactively to existing positions, validation limits on leverage values, or that this is a state-mutating operation with financial risk.

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

Conciseness3/5

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

Extremely brief at 6 words. While front-loaded and without filler, this level of brevity is inappropriate for a high-stakes trading operation, omitting necessary warnings and behavioral context that should earn their place in the description.

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?

For a financial tool that modifies margin requirements and liquidation risk, the description is dangerously incomplete. It lacks disclosure of side effects, error conditions (e.g., excessive leverage), or output expectations. No output schema exists to compensate for these gaps.

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?

Schema coverage is 100%, so the baseline is 3. The description mentions 'perpetual market' which loosely contextualizes the 'symbol' parameter, but adds no semantic detail beyond the schema's own descriptions (e.g., doesn't explain cross vs isolated margin implications or valid leverage ranges).

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 core action ('Set leverage') and scope ('perpetual market'), using a specific verb and resource. However, it lacks differentiation from siblings (though none are leverage-related) and doesn't clarify whether this sets account default or position-specific leverage.

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?

No guidance provided on when to use this tool versus alternatives, prerequisites (e.g., requiring an open position), or sequencing (whether to set before or after placing orders). The description stands alone without workflow context.

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