Trading MCP Server

Turn your words into action with Alpaca’s MCP Server

What You Can Do

  • Account & portfolio: Check balances, buying power, positions, portfolio history, and account activity
  • Trade: Place and manage orders for stocks, options, and crypto (market, limit, stop, trailing stop, brackets, multi-leg spreads)
  • Market data: Query historical and live data: bars, quotes, trades, snapshots, option chains with Greeks
  • Discover: Screen for most active stocks, market movers, news, corporate actions
  • Organize: Create and manage watchlists

Prerequisites

Setup

Add the server to your MCP client configuration with your API keys. No init commands or additional setup required.

Cursor

Add to ~/.cursor/mcp.json:

{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": ["alpaca-mcp-server"],
      "env": {
        "ALPACA_API_KEY": "your_alpaca_api_key",
        "ALPACA_SECRET_KEY": "your_alpaca_secret_key"
      }
    }
  }
}

Claude Desktop

Add to your Claude Desktop config (claude_desktop_config.json):

{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": ["alpaca-mcp-server"],
      "env": {
        "ALPACA_API_KEY": "your_alpaca_api_key",
        "ALPACA_SECRET_KEY": "your_alpaca_secret_key"
      }
    }
  }
}

VS Code

Add to your VS Code settings (.vscode/mcp.json):

{
  "servers": {
    "alpaca": {
      "command": "uvx",
      "args": ["alpaca-mcp-server"],
      "env": {
        "ALPACA_API_KEY": "your_alpaca_api_key",
        "ALPACA_SECRET_KEY": "your_alpaca_secret_key"
      }
    }
  }
}

Claude Code (CLI)

claude mcp add alpaca --scope user --transport stdio uvx alpaca-mcp-server \
  --env ALPACA_API_KEY=your_alpaca_api_key \
  --env ALPACA_SECRET_KEY=your_alpaca_secret_key

Docker

git clone https://github.com/alpacahq/alpaca-mcp-server.git
cd alpaca-mcp-server
docker build -t mcp/alpaca:latest .
docker run -e ALPACA_API_KEY=your_key -e ALPACA_SECRET_KEY=your_secret mcp/alpaca:latest

For other clients (Gemini CLI, PyCharm, ChatGPT), see the README setup section.

Verify

Restart your MCP client, then ask:

"What is my Alpaca account balance and buying power?"

If you get account details back, the server is connected.

Configuration

All configuration is via environment variables in your MCP client config.

VariableRequiredDefaultDescription
ALPACA_API_KEYYesYour Alpaca API key ID
ALPACA_SECRET_KEYYesYour Alpaca secret key
ALPACA_PAPER_TRADENotrueSet false to use live trading
ALPACA_TOOLSETSNoallComma-separated list of toolsets to enable

Toolset Filtering

Control which tools are available to your AI assistant using ALPACA_TOOLSETS. This is useful for limiting scope (e.g. read-only market data) or staying within MCP client tool limits.

ToolsetScope
accountAccount info, config, portfolio history, activities
tradingOrders, positions, exercise / do-not-exercise
watchlistsWatchlist CRUD
assetsAssets, option contracts, calendar, clock, corporate actions
stock-dataStock bars, quotes, trades, snapshots, screeners
crypto-dataCrypto bars, quotes, trades, snapshots, orderbook
options-dataOption bars, trades, quotes, chain, snapshots
corporate-actionsCorporate actions (market data)
newsNews articles
fixed-income-dataFixed income latest quotes
index-dataIndex values and latest index values

Example — read-only market data:

{
  "env": {
    "ALPACA_TOOLSETS": "account,stock-data,crypto-data,options-data,news"
  }
}

Supported MCP Clients

ClientConnection type
Claude DesktopLocal or Remote
VS CodeLocal or Remote
CursorLocal or Remote
PyCharmLocal or Remote
Claude Code (CLI)Local or Remote
Gemini CLILocal or Remote

Available Tools

Alpaca's MCP Server exposes 65 tools across the Trading and Market Data APIs.

Account & Portfolio

ToolDescription
get_account_infoAccount balances, margin, and status
get_account_configTrading restrictions and margin settings
update_account_configUpdate account configuration
get_portfolio_historyEquity and P/L over time
get_account_activitiesFills, dividends, transfers
get_account_activities_by_typeActivities filtered by type

Orders

ToolDescription
place_stock_orderStocks/ETFs; market, limit, stop, stop-limit, trailing stop, brackets
place_crypto_orderCrypto; market, limit, stop-limit
place_option_orderOptions; single-leg or multi-leg strategies
get_ordersRetrieve orders with filters
get_order_by_idSingle order by ID
get_order_by_client_idSingle order by client order ID
replace_order_by_idReplace an existing open order
cancel_order_by_idCancel a specific order
cancel_all_ordersCancel all open orders

Positions

ToolDescription
get_all_positionsAll current positions
get_open_positionDetails for a specific position
close_positionClose a specific position (full or partial)
close_all_positionsLiquidate entire portfolio
exercise_options_positionExercise a held option contract
do_not_exercise_options_positionDo-not-exercise instruction

Watchlists

ToolDescription
create_watchlistCreate a new watchlist
get_watchlistsList all watchlists
get_watchlist_by_idGet a specific watchlist
update_watchlist_by_idUpdate a watchlist
delete_watchlist_by_idDelete a watchlist
add_asset_to_watchlist_by_idAdd an asset to a watchlist
remove_asset_from_watchlist_by_idRemove an asset from a watchlist

Assets & Market Info

ToolDescription
get_all_assetsList assets with optional filtering
get_assetDetailed info for a specific asset
get_option_contractsOption contracts for underlying symbol(s)
get_option_contractSingle option contract by symbol or ID
get_calendarMarket calendar for a date range
get_clockCurrent market status and next open/close
get_corporate_action_announcementsCorporate action announcements
get_corporate_action_announcementSingle announcement by ID

Stock Data

ToolDescription
get_stock_barsHistorical OHLCV bars
get_stock_quotesHistorical bid/ask quotes
get_stock_tradesHistorical trades
get_stock_latest_barLatest minute bar
get_stock_latest_quoteLatest quote
get_stock_latest_tradeLatest trade
get_stock_snapshotComprehensive snapshot (quote, trade, bars)
get_most_active_stocksMost active by volume/trade count
get_market_moversTop gainers and losers

Crypto Data

ToolDescription
get_crypto_barsHistorical OHLCV bars
get_crypto_quotesHistorical quotes
get_crypto_tradesHistorical trades
get_crypto_latest_barLatest minute bar
get_crypto_latest_quoteLatest quote
get_crypto_latest_tradeLatest trade
get_crypto_snapshotComprehensive snapshot
get_crypto_latest_orderbookLatest orderbook with bid/ask depth

Options Data

ToolDescription
get_option_barsHistorical OHLCV bars
get_option_tradesHistorical trades
get_option_latest_tradeLatest trade
get_option_latest_quoteLatest quote with bid/ask
get_option_snapshotSnapshot with Greeks and IV
get_option_chainFull option chain for an underlying
get_option_exchange_codesExchange code to name mapping

Fixed Income Data

ToolDescription
get_fixed_income_latest_quotesLatest quotes for fixed income securities by ISIN

Index Data

ToolDescription
get_index_latest_valuesLatest values for market indices
get_index_valuesHistorical values for market indices

Corporate Actions & News

ToolDescription
get_corporate_actionsCorporate actions from market data API
get_newsNews articles for stocks and crypto

Example Prompts

Here are some things you can ask once connected:

Account & Portfolio

  • "What's my current account balance and buying power?"
  • "Show me all my open positions."
  • "What's my portfolio performance over the last month?"

Trading

  • "Buy 10 shares of AAPL at market price."
  • "Place a limit order to sell 50 shares of TSLA at $350."
  • "Set a trailing stop on my NVDA position at 5%."
  • "Cancel all my open orders."

Market Data

  • "Show me AAPL's daily price bars for the last week."
  • "What's the latest quote for BTC/USD?"
  • "Get a snapshot of MSFT including latest trade and quote."
  • "What are the most active stocks right now?"

Options

  • "Show me available AAPL options expiring next month."
  • "What are the Greeks for this TSLA 300 put?"
  • "Place a bull call spread on SPY."

Watchlists

  • "Create a watchlist called Tech Earnings with AAPL, MSFT, NVDA, and GOOGL."

Tip: Use paper trading API keys to test strategies safely. Switch to live trading only when you set ALPACA_PAPER_TRADE=false with live API keys.

Important Considerations

  • API key security: Never paste API keys into chat. Configure them only in your MCP client's env block or OS secret store.
  • Order execution: Orders execute directly against Alpaca's Trading API. Review AI-suggested orders before confirming.
  • Paper vs. live: The server defaults to paper trading. Set ALPACA_PAPER_TRADE=false with live keys to trade with real capital.
  • Rate limits: Alpaca's API has rate limits per account. High-frequency querying may trigger rate limiting.
  • Market data subscriptions: Some real-time data may require an Algo Trader Plus subscription.

Upgrading from V1

V2 is not a drop-in replacement for V1. Tool names and parameters changed. If you need V1, pin an older PyPI version:

{
  "args": ["alpaca-mcp-server==1.x.x", "serve"]
}

For details, see the Upgrading from V1 section in the README.

Resources

Disclosure

Insights generated by our MCP server and connected AI agents are for educational and informational purposes only and should not be taken as investment advice. Past performance from models does not guarantee future results. Please conduct your own due diligence before making any decisions.