Skip to main content
Glama
Habinar

MCP Paradex Server

by Habinar

paradex_vault_balance

Retrieve current balance information for a specific vault on the Paradex platform, including available funds, locked funds, and total balance to assess financial state before trades or withdrawals.

Instructions

Get the current balance of a specific vault.

Retrieves the current balance information for a specific vault, including available funds, locked funds, and total balance. This is essential for understanding the financial state of a vault before executing trades or withdrawals.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vault_addressYesThe address of the vault to get balance for.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main execution logic for the 'paradex_vault_balance' tool. Fetches vault balance data from Paradex API, validates it using Pydantic TypeAdapter, and returns list of VaultBalance objects.
    @server.tool(name="paradex_vault_balance")
    async def get_vault_balance(
        vault_address: Annotated[
            str, Field(description="The address of the vault to get balance for.")
        ],
    ) -> list[VaultBalance]:
        """
        Get the current balance of a specific vault.
    
        Retrieves the current balance information for a specific vault,
        including available funds, locked funds, and total balance.
        This is essential for understanding the financial state of a vault
        before executing trades or withdrawals.
    
        """
        try:
            client = await get_paradex_client()
            response = await api_call(client, "vaults/balance", params={"address": vault_address})
            if "error" in response:
                raise Exception(response["error"])
            results = response["results"]
            balances = vault_balance_adapter.validate_python(results)
            return balances
        except Exception as e:
            logger.error(f"Error fetching balance for vault {vault_address}: {e!s}")
            raise e
  • Pydantic BaseModel defining the structure and validation for VaultBalance output objects returned by the tool.
    class VaultBalance(BaseModel):
        """Model representing the balance of a vault."""
    
        token: Annotated[str, Field(description="Name of the token")]
        size: Annotated[str, Field(description="Balance amount of settlement token")]
        last_updated_at: Annotated[int, Field(description="Balance last updated time")]
  • The @server.tool decorator registers the get_vault_balance function as the MCP tool named 'paradex_vault_balance'.
    @server.tool(name="paradex_vault_balance")
  • Supporting resource endpoint that performs the actual API call to Paradex for vault balance data, invoked indirectly by the tool handler.
    @server.resource("paradex://vaults/balance/{vault_id}")
    async def get_vault_balance(vault_id: str) -> dict[str, Any]:
        """
        Get a summary of market information for a specific trading pair.
    
        This endpoint requires authentication and provides detailed
        information about the market, including order book, ticker, and
        market statistics.
    
        Args:
            market_id (str): The ID of the trading pair to get summary for.
    
        Returns:
            Dict[str, Any]: Summary of market information.
        """
        try:
            # Get market summary from Paradex
            client = await get_paradex_client()
            summary = await api_call(client, "vaults/balance", params={"address": vault_id})
            return summary
        except Exception as e:
            logger.error(f"Error fetching market summary: {e!s}")
            return {
                "success": False,
                "timestamp": datetime.now().isoformat(),
                "environment": config.ENVIRONMENT,
                "error": str(e),
                "summary": None,
            }
  • TypeAdapter for list[VaultBalance] used for input validation/parsing of the API response in the handler.
    vault_balance_adapter = TypeAdapter(list[VaultBalance])

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.0.0
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$defs": {
      +    "VaultBalance": {
      +      "description": "Model representing the balance of a vault.",
      +      "properties": {
      +        "last_updated_at": {
      +          "description": "Balance last updated time",
      +          "title": "Last Updated At",
      +          "type": "integer"
      +        },
      +        "size": {
      +          "description": "Balance amount of settlement token",
      +          "title": "Size",
      +          "type": "string"
      +        },
      +        "token": {
      +          "description": "Name of the token",
      +          "title": "Token",
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "token",
      +        "size",
      +        "last_updated_at"
      +      ],
      +      "title": "VaultBalance",
      +      "type": "object"
      +    }
      +  },
      +  "properties": {
      +    "result": {
      +      "items": {
      +        "$ref": "#/$defs/VaultBalance"
      +      },
      +      "title": "Result",
      +      "type": "array"
      +    }
      +  },
      +  "required": [
      +    "result"
      +  ],
      +  "title": "get_vault_balanceOutput",
      +  "type": "object"
      +}
  2. First observed

TDQS

A4/5.0
Behavior3/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 clearly indicates this is a read operation ('Get', 'Retrieves') and describes what information will be returned (available funds, locked funds, total balance), but doesn't mention potential limitations like rate limits, authentication requirements, or error conditions.

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 efficiently structured with three sentences that each earn their place: stating the purpose, detailing what's retrieved, and explaining the usage context. No wasted words or redundancy.

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?

For a single-parameter read tool with 100% schema coverage and an output schema, the description provides adequate context. It explains the purpose, what information is returned, and when to use it. The main gap is lack of behavioral details like authentication or rate limits, but the output schema will handle return values.

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 description coverage is 100%, so the input schema already fully documents the single parameter. The description doesn't add any additional parameter semantics beyond what's in the schema, but doesn't need to since the schema coverage is complete.

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?

The description clearly states the specific action ('Get the current balance') and resource ('of a specific vault'), distinguishing it from sibling tools like paradex_vault_summary or paradex_vault_account_summary by focusing on detailed balance breakdown rather than summary information.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('essential for understanding the financial state of a vault before executing trades or withdrawals'), but doesn't explicitly mention when NOT to use it or name specific alternatives among the sibling tools.

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