Skip to main content
Glama

get_positions

Retrieve current portfolio positions and cash balance for portfolio management and trading analysis.

Instructions

Retrieves the current state of all held positions and cash balance.

Returns:
    Dict with 'cash' and 'positions' keys

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler function for the 'get_positions' tool. It fetches the current portfolio positions, cash balance, equity, and buying power from the Alpaca trading broker, handling errors gracefully.
    def get_positions() -> Dict[str, Any]:
        """
        Retrieves the current state of all held positions and cash balance.
        
        Returns:
            Dict with 'cash' and 'positions' keys
        """
        if broker is None:
            return {
                "error": "Alpaca broker not initialized. Check your API credentials.",
                "cash": 0,
                "positions": {}
            }
        
        try:
            account = broker.get_account()
            positions_raw = broker.get_all_positions()
            
            # Convert to simple format: {symbol: qty}
            positions = {
                symbol: details['qty'] 
                for symbol, details in positions_raw.items()
            }
            
            return {
                "cash": account['cash'],
                "equity": account['equity'],
                "buying_power": account['buying_power'],
                "positions": positions
            }
        except Exception as e:
            logger.error(f"Failed to get positions: {e}")
            return {
                "error": str(e),
                "cash": 0,
                "positions": {}
            }
  • server.py:375-378 (registration)
    Registration of the 'get_positions' tool (along with other execution tools) in the MCP server using the register_tools helper, which applies the @mcp.tool() decorator.
    register_tools(
        [place_order, cancel_order, get_positions, flatten, get_order_history],
        "Execution"
    )
  • app.py:288-288 (registration)
    Inclusion of 'get_positions' in the tools_map for the Gradio UI which also supports MCP server mode.
    "Execution": [place_order, cancel_order, get_positions, flatten, get_order_history],
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the return structure but lacks critical behavioral details: whether this requires authentication, if it's read-only (implied by 'Retrieves' but not explicit), rate limits, latency, or error conditions. For a financial tool with no annotations, this is a significant gap in transparency.

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 extremely concise and front-loaded: the first sentence states the core purpose, and the second clarifies the return format. Every sentence earns its place with no wasted words, making it easy for an agent to parse quickly.

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?

Given the tool has no parameters, an output schema exists (implied by 'Returns' section), and annotations are absent, the description is minimally complete. However, for a financial data retrieval tool, it lacks context on prerequisites (e.g., authentication), data freshness, or error handling, which could hinder an agent's effective use.

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?

The tool has 0 parameters, and schema description coverage is 100% (though empty). The description doesn't need to explain parameters, so it appropriately focuses on output. Baseline for 0 params is 4, as it efficiently describes the tool's function without unnecessary parameter details.

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 ('Retrieves') and the exact resources ('current state of all held positions and cash balance'), distinguishing it from siblings like get_account_info (likely broader account data) or get_order_history (historical orders). It precisely defines what the tool does without ambiguity.

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 on when to use this tool versus alternatives. For example, it doesn't clarify if this is for real-time portfolio snapshots versus historical data, or how it differs from get_account_info which might include similar information. The description only states what it does, not when it's appropriate.

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/N-lia/MonteWalk'

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