Skip to main content
Glama

get_positions

Retrieve detailed position data from Bybit for specified categories and symbols to monitor and manage your trading portfolio effectively.

Instructions

Get position information

Args:
    category (str): Category (spot, linear, inverse, etc.)
    symbol (Optional[str]): Symbol (e.g., BTCUSDT)

Returns:
    Dict: Position information

Example:
    get_positions("spot", "BTCUSDT")

Reference:
    https://bybit-exchange.github.io/docs/v5/position

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesCategory (spot, linear, inverse, etc.)
symbolNoSymbol (e.g., BTCUSDT)

Implementation Reference

  • MCP tool handler for 'get_positions'. Decorated with @mcp.tool() for registration. Defines input schema using pydantic Field. Calls BybitService.get_positions and handles API response/errors.
    @mcp.tool()
    def get_positions(
        category: str = Field(description="Category (spot, linear, inverse, etc.)"),
        symbol: Optional[str] = Field(default=None, description="Symbol (e.g., BTCUSDT)")
    ) -> Dict:
        """
        Get position information
    
        Args:
            category (str): Category (spot, linear, inverse, etc.)
            symbol (Optional[str]): Symbol (e.g., BTCUSDT)
    
        Returns:
            Dict: Position information
    
        Example:
            get_positions("spot", "BTCUSDT")
    
        Reference:
            https://bybit-exchange.github.io/docs/v5/position
        """
        try:
            result = bybit_service.get_positions(category, symbol)
            if result.get("retCode") != 0:
                logger.error(f"Failed to get position information: {result.get('retMsg')}")
                return {"error": result.get("retMsg")}
            return result
        except Exception as e:
            logger.error(f"Failed to get position information: {e}", exc_info=True)
            return {"error": str(e)}
  • BybitService.get_positions method: core helper that directly calls the pybit.unified_trading.HTTP client.get_positions API.
    def get_positions(self, category: str, symbol: Optional[str] = None) -> Dict:
        """
        Get position information
    
        Args:
            category (str): Category (spot, linear, inverse, etc.)
            symbol (Optional[str]): Symbol (e.g., BTCUSDT)
    
        Returns:
            Dict: Position information
        """
        return self.client.get_positions(
            category=category,
            symbol=symbol
        )
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. While it mentions what the tool does (get position information) and provides an example, it doesn't disclose important behavioral traits like whether this requires authentication, rate limits, what happens with invalid parameters, or the structure of the returned position information beyond 'Dict'. The reference link is helpful but external.

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

Conciseness4/5

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

The description is well-structured with clear sections (Args, Returns, Example, Reference) and appropriately sized. The information is front-loaded with the core purpose first. The example is helpful and the reference provides additional context without cluttering the main description.

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

Completeness3/5

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

For a 2-parameter tool with 100% schema coverage but no output schema and no annotations, the description is adequate but has gaps. It explains what the tool does and provides an example, but doesn't describe the return value structure (beyond 'Dict') or important behavioral considerations. The reference link partially compensates but requires external access.

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 schema already documents both parameters completely. The description adds minimal value beyond what's in the schema - it repeats the same parameter descriptions verbatim and provides an example showing usage. This meets the baseline expectation when schema coverage is high.

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

Purpose3/5

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

The description states 'Get position information' which is a clear verb+resource combination, but it's quite generic. It doesn't specifically differentiate from sibling tools like 'get_wallet_balance' or 'get_open_orders' which also retrieve trading-related information. The purpose is understandable but lacks specificity about what makes this tool unique.

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 is provided about when to use this tool versus alternatives. The description doesn't mention when this tool is appropriate versus other sibling tools like 'get_wallet_balance' or 'get_open_orders'. There's no context about prerequisites, limitations, or typical use cases for position information retrieval.

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

Related 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/dlwjdtn535/mcp-bybit-server'

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