Alpaca MCP Server

Trade and pull market data through an Alpaca brokerage account: stocks, ETFs, options and crypto

Official · Alpaca Python Local · stdio Finance and payments

85 popularity score ★ 1.1k ↓ 42k/mo

Connect your client

Local (PyPI)

Add in one click

Opens the app, which asks before it adds the server. Then replace each <NAME> in its settings with your value.

Or add it by command or config

It needs ALPACA_API_KEY, ALPACA_SECRET_KEY. Replace each <NAME> with your value.

Claude CodeTerminal
claude mcp add alpaca -e ALPACA_API_KEY=<ALPACA_API_KEY> -e ALPACA_SECRET_KEY=<ALPACA_SECRET_KEY> -- uvx alpaca-mcp-server
Claude Desktopclaude_desktop_config.json
{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": [
        "alpaca-mcp-server"
      ],
      "env": {
        "ALPACA_API_KEY": "<ALPACA_API_KEY>",
        "ALPACA_SECRET_KEY": "<ALPACA_SECRET_KEY>"
      }
    }
  }
}
Cursor~/.cursor/mcp.json
{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": [
        "alpaca-mcp-server"
      ],
      "env": {
        "ALPACA_API_KEY": "<ALPACA_API_KEY>",
        "ALPACA_SECRET_KEY": "<ALPACA_SECRET_KEY>"
      }
    }
  }
}
VS Code.vscode/mcp.json
{
  "servers": {
    "alpaca": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "alpaca-mcp-server"
      ],
      "env": {
        "ALPACA_API_KEY": "<ALPACA_API_KEY>",
        "ALPACA_SECRET_KEY": "<ALPACA_SECRET_KEY>"
      }
    }
  }
}
Codex~/.codex/config.toml
[mcp_servers.alpaca]
command = "uvx"
args = ["alpaca-mcp-server"]

[mcp_servers.alpaca.env]
ALPACA_API_KEY = "<ALPACA_API_KEY>"
ALPACA_SECRET_KEY = "<ALPACA_SECRET_KEY>"
Gemini CLITerminal
gemini mcp add --scope user -e ALPACA_API_KEY=<ALPACA_API_KEY> -e ALPACA_SECRET_KEY=<ALPACA_SECRET_KEY> alpaca uvx -- alpaca-mcp-server
Local (container)

Add in one click

Opens the app, which asks before it adds the server. Then replace each <NAME> in its settings with your value.

Or add it by command or config

It needs ALPACA_API_KEY, ALPACA_SECRET_KEY. Replace each <NAME> with your value.

FirstTerminal
git clone https://github.com/alpacahq/alpaca-mcp-server.git
cd alpaca-mcp-server
docker build -t mcp/alpaca:latest .
Claude CodeTerminal
claude mcp add alpaca -e ALPACA_API_KEY=<ALPACA_API_KEY> -e ALPACA_SECRET_KEY=<ALPACA_SECRET_KEY> -- docker run --rm -i -e ALPACA_API_KEY -e ALPACA_SECRET_KEY mcp/alpaca:latest
Claude Desktopclaude_desktop_config.json
{
  "mcpServers": {
    "alpaca": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e",
        "ALPACA_API_KEY",
        "-e",
        "ALPACA_SECRET_KEY",
        "mcp/alpaca:latest"
      ],
      "env": {
        "ALPACA_API_KEY": "<ALPACA_API_KEY>",
        "ALPACA_SECRET_KEY": "<ALPACA_SECRET_KEY>"
      }
    }
  }
}
Cursor~/.cursor/mcp.json
{
  "mcpServers": {
    "alpaca": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e",
        "ALPACA_API_KEY",
        "-e",
        "ALPACA_SECRET_KEY",
        "mcp/alpaca:latest"
      ],
      "env": {
        "ALPACA_API_KEY": "<ALPACA_API_KEY>",
        "ALPACA_SECRET_KEY": "<ALPACA_SECRET_KEY>"
      }
    }
  }
}
VS Code.vscode/mcp.json
{
  "servers": {
    "alpaca": {
      "type": "stdio",
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e",
        "ALPACA_API_KEY",
        "-e",
        "ALPACA_SECRET_KEY",
        "mcp/alpaca:latest"
      ],
      "env": {
        "ALPACA_API_KEY": "<ALPACA_API_KEY>",
        "ALPACA_SECRET_KEY": "<ALPACA_SECRET_KEY>"
      }
    }
  }
}
Codex~/.codex/config.toml
[mcp_servers.alpaca]
command = "docker"
args = ["run", "--rm", "-i", "-e", "ALPACA_API_KEY", "-e", "ALPACA_SECRET_KEY", "mcp/alpaca:latest"]

[mcp_servers.alpaca.env]
ALPACA_API_KEY = "<ALPACA_API_KEY>"
ALPACA_SECRET_KEY = "<ALPACA_SECRET_KEY>"
Gemini CLITerminal
gemini mcp add --scope user -e ALPACA_API_KEY=<ALPACA_API_KEY> -e ALPACA_SECRET_KEY=<ALPACA_SECRET_KEY> alpaca docker -- run --rm -i -e ALPACA_API_KEY -e ALPACA_SECRET_KEY mcp/alpaca:latest

Settings 6

ALPACA_API_KEY Required: Alpaca API key ID (paper or live).
ALPACA_SECRET_KEY Required: Alpaca API secret key.
ALPACA_PAPER_TRADE Optional: Paper trading unless set to something other than true/1/yes; false trades live.
ALPACA_TOOLSETS Optional: Comma-separated toolsets to enable, e.g. stock-data,crypto-data; all by default.
DATA_API_URL Optional: Market data host; defaults to https://data.alpaca.markets.
ALPACA_MCP_USER_AGENT Optional: Overrides the user-agent sent to Alpaca; empty string sends none.

In a container, a setting goes in with -e NAME=value after docker run.

What it does

Alpaca's own server for its Trading and Market Data APIs. Running on your machine with your Alpaca key pair, it can read your account, balances, positions and order history. It can also submit, replace and cancel orders for stocks, ETFs, crypto and options (including multi-leg option strategies), close positions and exercise options. On the data side it returns historical and latest bars, quotes and trades, snapshots, option chains with Greeks, crypto order books, news, corporate actions, market movers and bond quotes. Five extra tools look up Alpaca's own documentation and API reference.

Version 2 is a full rewrite: most tools are generated from Alpaca's OpenAPI specs, and the order and historical-data tools are written by hand. Its makers warn that none of the v1 tools carry over unchanged, so prompts or scripts built on v1 tool names need redoing. You can pin a 1.x release to stay on v1.

It trades on a paper (simulated) account unless ALPACA_PAPER_TRADE is set otherwise. In server.py at v2.4.0, only true, 1 or yes (any case) keep it on paper. Any other value, "on" included, sends orders to the live endpoint api.alpaca.markets. The same file reads a DATA_API_URL setting the README does not list, which overrides the market-data host, and gives each API call a 30-second timeout. ALPACA_TOOLSETS narrows the API tools to named groups, but the five documentation tools are registered whatever it says (server.py, toolsets.py).

What it needs

RuntimePython 3.10+orDocker

Python 3.10+ and uv (the launch command is uvx). An Alpaca account and an API key and secret; a free paper-trading account is enough to start. Live trading needs a funded live account and its own keys. Some recent market data needs a paid Alpaca data plan (Algo Trader Plus). For Docker, you build the image yourself from a clone of the repository.

Limits

Talks to Alpaca only; Broker API endpoints are left out of both the tools and the docs lookup. The short-sale locate tools do not work in paper trading. Watchlists can only be seen and changed if they were created through the Trading API. Its HTTP mode (--transport streamable-http) has no MCP sign-in. Its makers say not to expose it to the public internet, so clients that need a remote server (ChatGPT, Claude mobile) are not supported. v2 tool names and parameters differ from v1. Its makers say its output is not investment advice.

Who it suits

Suits developers and traders who already use Alpaca and want an assistant to check positions, pull quotes and bars, or place orders. Start on paper keys: the default is paper trading, and live trading is one setting away. With ALPACA_TOOLSETS you can expose only data groups (for example stock-data,crypto-data) and leave the order tools out. Not for other brokers, for a hosted endpoint, or for anyone who wants an assistant that cannot place trades unless the toolsets are restricted.

Tools 60 of 72

get_account_info
Show balance, margin and account status
get_account_config
Read account settings such as trading restrictions and day-trade checks
update_account_config
Change account configuration settings
get_portfolio_history
Equity and profit/loss over a period
get_account_activities
List account activity such as fills, dividends and transfers
get_orders
List orders, with filters
get_order_by_id
Fetch one order by its ID
get_order_by_client_id
Fetch one order by the client order ID
replace_order_by_id
Replace an open order with new terms
cancel_order_by_id
Cancel one order
cancel_all_orders
Cancel every open order
place_stock_order
Submit a stock or ETF order, including stop, trailing-stop and bracket types
place_crypto_order
Submit a crypto order: market, limit or stop-limit
place_option_order
Submit a single-leg or multi-leg options order
get_all_positions
List all open positions
get_open_position
Details of one open position
close_position
Close all or part of one position
close_all_positions
Liquidate every position in the account
exercise_options_position
Exercise a held option contract
do_not_exercise_options_position
Submit a do-not-exercise instruction for an option
create_watchlist
Create a watchlist
get_watchlists
List watchlists
get_watchlist_by_id
Fetch one watchlist
update_watchlist_by_id
Rename or replace the contents of a watchlist
delete_watchlist_by_id
Delete a watchlist
add_asset_to_watchlist_by_id
Add a symbol to a watchlist
remove_asset_from_watchlist_by_id
Remove a symbol from a watchlist
get_all_assets
List tradable assets, with filters
get_asset
Details of one asset
get_option_contracts
Find option contracts for one or more underlyings
get_option_contract
Fetch one option contract by symbol or ID
get_calendar
Market trading days and hours for a date range
get_clock
Whether the market is open and the next open and close
get_corporate_action_announcements
List corporate action announcements
get_stock_bars
Historical price bars for stocks
get_stock_quotes
Historical bid/ask quotes for stocks
get_stock_trades
Historical stock trades
get_stock_latest_bar
Most recent minute bar for a stock
get_stock_latest_quote
Most recent stock quote
get_stock_latest_trade
Most recent stock trade
get_stock_snapshot
Quote, trade and bars for a stock in one call
get_most_active_stocks
Stocks ranked by volume or trade count
get_market_movers
Top gaining and losing stocks
get_crypto_bars
Historical price bars for crypto pairs
get_crypto_latest_bar
Most recent minute bar for a crypto pair
get_crypto_latest_quote
Most recent crypto quote
get_crypto_latest_trade
Most recent crypto trade
get_crypto_snapshot
Quote, trade and bars for a crypto pair in one call
get_crypto_latest_orderbook
Current order book for a crypto pair
get_option_bars
Historical price bars for option contracts
get_option_latest_trade
Most recent option trade
get_option_latest_quote
Most recent option quote with exchange
get_option_snapshot
Option snapshot including Greeks and implied volatility
get_option_chain
Option chain for an underlying symbol
get_corporate_actions
Dividends, splits and other corporate actions from market data
get_news
News articles for stocks and crypto, by symbol and date
get_fixed_income_latest_quotes
Latest bond and treasury quotes by ISIN
create_locate
Request shares to borrow for a short sale (not in paper trading)
search_alpaca_docs
Search Alpaca's documentation pages and guides
get_alpaca_endpoint_docs
Reference docs for one Alpaca API endpoint by method and path

Similar servers