Skip to main content
Glama
laukikk

Alpaca Trading MCP Server

by laukikk

get_account_info_tool

Retrieve current account balance, status, and summary details from your Alpaca trading account to monitor portfolio performance and make informed investment decisions.

Instructions

Get current account information.

Returns: Account summary with balance and status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the core logic of get_account_info_tool. It calls the helper to fetch account data and formats the response string.
    @mcp.tool() def get_account_info_tool() -> str: """ Get current account information. Returns: Account summary with balance and status """ account = calls.get_account(trading_client) return ( f"Account Summary:\n" f"Status: {account.status}\n" f"Cash: ${account.cash:.2f}\n" f"Portfolio Value: ${account.portfolio_value:.2f}\n" f"Buying Power: ${account.buying_power:.2f}\n" f"Equity: ${account.equity:.2f}\n" f"Daytrade Count: {account.daytrade_count}\n" f"Pattern Day Trader: {account.pattern_day_trader}\n" )
  • Helper function that retrieves the account information from the Alpaca TradingClient and parses it into the AlpacaAccount Pydantic model, used directly by the tool handler.
    def get_account(client: TradingClient): """ Retrieve account details :param client: Alpaca trading client :return: AlpacaAccount model """ account = client.get_account() return AlpacaAccount(**account.__dict__)
  • Pydantic model defining the structure and validation for Alpaca account data, used by the helper function to parse API responses.
    class AlpacaAccount(BaseModel): id: UUID account_number: str status: str currency: str buying_power: float regt_buying_power: float daytrading_buying_power: float non_marginable_buying_power: float cash: float portfolio_value: float pattern_day_trader: bool trading_blocked: bool transfers_blocked: bool trade_suspended_by_user: bool maintenance_margin: float last_maintenance_margin: float initial_margin: float last_equity: float equity: float daytrade_count: int multiplier: float sma: float class Config: extra = "ignore"

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/laukikk/alpaca-mcp'

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