home / mcp / alpaca mcp server

Alpaca MCP Server

Alpaca’s official MCP Server lets you trade stocks, ETFs, crypto, and options, run data analysis, and build strategies in plain English directly from your favorite LLM tools and IDEs

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "alpacahq-alpaca-mcp-server": {
      "url": "https://your-domain.com/mcp",
      "headers": {
        "ALPACA_API_KEY": "sk_yourapikey",
        "ALPACA_SECRET_KEY": "secret_yoursecret"
      }
    }
  }
}

You can run and connect Alpaca's MCP Server to your preferred MCP client to trade programmatically using natural language prompts. It provides real-time market data, account, positions, orders, and diverse trading capabilities for stocks, crypto, and options within a single, extensible server.

How to use

Connect the Alpaca MCP Server to an MCP client such as Claude Desktop, Cursor, VS Code, or Claude Code. Use the client to issue natural language commands that get translated into trading actions, place orders, fetch market data, manage watchlists, and inspect your portfolio. The server supports real-time quotes, trades, and price bars; historical data; account and position management; and a wide range of order types and options strategies. Start by configuring your MCP server credentials, then add the server to your MCP client of choice. When you issue prompts, the MCP client routes them to the server and returns structured results you can review before execution.

How to install

Prerequisites you need before installing the MCP server.

Then follow concrete installation options to get started quickly.

Security and credentials

Keep your Alpaca API keys secure. Treat all credentials as sensitive. When you use remote hosting or cloud deployments, ensure access is restricted and secured with proper authentication and TLS. The MCP client configuration can override server env settings, so verify that your keys and trading mode (paper vs live) are correct in the appropriate config.

Troubleshooting

If you encounter issues, verify that your environment variables are set, the MCP server is reachable from your MCP client, and the client is restarted after any config change. Check for port conflicts when using HTTP transport and consider using transport with a dedicated port or a proxy with authentication for remote access.

Notes and examples

Several installation and configuration options are provided to suit your environment. You can install locally with uvx, use install.py for Cursor or Claude Desktop, or run via Docker. For remote hosting, you can deploy the MCP server in the cloud and connect it to Claude Web, Claude Mobile, or other MCP clients.

Appendix: Quick configuration references

You can configure the MCP server to run locally using uvx. The following example starts the server and serves MCP requests with environment variables for Alpaca credentials.

Appendix: Available prompts and outputs

Prompts and outputs demonstrate typical trading tasks, such as checking balances, placing orders, retrieving quotes, and inspecting positions. The MCP server returns structured responses that describe the action taken, its status, and any data retrieved or generated.

Available tools

get_account_info

View balance, buying power, and account status

get_all_positions

List all held assets

get_open_position

Detailed info on a specific position

get_asset

Search asset metadata

get_all_assets

List all tradable instruments with filtering options

get_corporate_actions

Historical and future corporate actions (earnings, dividends, splits)

get_portfolio_history

Retrieve account portfolio history with equity and P/L over time

create_watchlist

Create a new watchlist with symbols

get_watchlists

Retrieve all saved watchlists

update_watchlist_by_id

Modify an existing watchlist by ID

get_watchlist_by_id

Get a specific watchlist by ID

add_asset_to_watchlist_by_id

Add an asset to a watchlist

remove_asset_from_watchlist_by_id

Remove an asset from a watchlist

delete_watchlist_by_id

Delete a specific watchlist

get_calendar

Holidays and trading days in a date range

get_clock

Market open/close times and current status

get_stock_bars

OHLCV historical bars with flexible timeframes

get_stock_quotes

Historical quote data (level 1 bid/ask) for a stock

get_stock_trades

Trade-level history for a stock

get_stock_latest_bar

Most recent OHLCV bar for a stock

get_stock_latest_quote

Real-time bid/ask quote for one or more symbols

get_stock_latest_trade

Latest market trade price for a symbol

get_stock_snapshot

Comprehensive snapshot for a stock

get_crypto_bars

Historical price bars for cryptocurrency with configurable timeframe

get_crypto_quotes

Historical quote data for crypto

get_crypto_trades

Historical trade prints for cryptocurrency

get_crypto_latest_quote

Latest quote for one or more crypto symbols

get_crypto_latest_bar

Latest minute bar for crypto

get_crypto_latest_trade

Latest trade for crypto

get_crypto_snapshot

Comprehensive crypto snapshot

get_option_contracts

Get option contracts with flexible filtering

get_option_latest_quote

Latest bid/ask on contract

get_option_snapshot

Get Greeks and underlying

get_orders

Retrieve all or filtered orders

place_stock_order

Place a stock order of any type (market, limit, stop, stop_limit, trailing_stop)

place_crypto_order

Place a crypto order with market, limit, and stop_limit types

place_option_order

Place an options order (single or multi-leg)

cancel_all_orders

Cancel all open orders

cancel_order_by_id

Cancel a specific order

close_position

Close part or all of a position

close_all_positions

Liquidate entire portfolio

exercise_options_position

Exercise a held option contract