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
- Python 3.10+ (official installation guide)
- uv with
uvx(install guide) - Alpaca API keys: a free paper trading account is enough to start
- MCP client: Claude Desktop, Cursor, VS Code, Claude Code, Gemini CLI, PyCharm, or any MCP-compatible tool
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_keyDocker
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:latestFor 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.
| Variable | Required | Default | Description |
|---|---|---|---|
ALPACA_API_KEY | Yes | — | Your Alpaca API key ID |
ALPACA_SECRET_KEY | Yes | — | Your Alpaca secret key |
ALPACA_PAPER_TRADE | No | true | Set false to use live trading |
ALPACA_TOOLSETS | No | all | Comma-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.
| Toolset | Scope |
|---|---|
account | Account info, config, portfolio history, activities |
trading | Orders, positions, exercise / do-not-exercise |
watchlists | Watchlist CRUD |
assets | Assets, option contracts, calendar, clock, corporate actions |
stock-data | Stock bars, quotes, trades, snapshots, screeners |
crypto-data | Crypto bars, quotes, trades, snapshots, orderbook |
options-data | Option bars, trades, quotes, chain, snapshots |
corporate-actions | Corporate actions (market data) |
news | News articles |
fixed-income-data | Fixed income latest quotes |
index-data | Index values and latest index values |
Example — read-only market data:
{
"env": {
"ALPACA_TOOLSETS": "account,stock-data,crypto-data,options-data,news"
}
}Supported MCP Clients
| Client | Connection type |
|---|---|
| Claude Desktop | Local or Remote |
| VS Code | Local or Remote |
| Cursor | Local or Remote |
| PyCharm | Local or Remote |
| Claude Code (CLI) | Local or Remote |
| Gemini CLI | Local or Remote |
Available Tools
Alpaca's MCP Server exposes 65 tools across the Trading and Market Data APIs.
Account & Portfolio
| Tool | Description |
|---|---|
get_account_info | Account balances, margin, and status |
get_account_config | Trading restrictions and margin settings |
update_account_config | Update account configuration |
get_portfolio_history | Equity and P/L over time |
get_account_activities | Fills, dividends, transfers |
get_account_activities_by_type | Activities filtered by type |
Orders
| Tool | Description |
|---|---|
place_stock_order | Stocks/ETFs; market, limit, stop, stop-limit, trailing stop, brackets |
place_crypto_order | Crypto; market, limit, stop-limit |
place_option_order | Options; single-leg or multi-leg strategies |
get_orders | Retrieve orders with filters |
get_order_by_id | Single order by ID |
get_order_by_client_id | Single order by client order ID |
replace_order_by_id | Replace an existing open order |
cancel_order_by_id | Cancel a specific order |
cancel_all_orders | Cancel all open orders |
Positions
| Tool | Description |
|---|---|
get_all_positions | All current positions |
get_open_position | Details for a specific position |
close_position | Close a specific position (full or partial) |
close_all_positions | Liquidate entire portfolio |
exercise_options_position | Exercise a held option contract |
do_not_exercise_options_position | Do-not-exercise instruction |
Watchlists
| Tool | Description |
|---|---|
create_watchlist | Create a new watchlist |
get_watchlists | List all watchlists |
get_watchlist_by_id | Get a specific watchlist |
update_watchlist_by_id | Update a watchlist |
delete_watchlist_by_id | Delete a watchlist |
add_asset_to_watchlist_by_id | Add an asset to a watchlist |
remove_asset_from_watchlist_by_id | Remove an asset from a watchlist |
Assets & Market Info
| Tool | Description |
|---|---|
get_all_assets | List assets with optional filtering |
get_asset | Detailed info for a specific asset |
get_option_contracts | Option contracts for underlying symbol(s) |
get_option_contract | Single option contract by symbol or ID |
get_calendar | Market calendar for a date range |
get_clock | Current market status and next open/close |
get_corporate_action_announcements | Corporate action announcements |
get_corporate_action_announcement | Single announcement by ID |
Stock Data
| Tool | Description |
|---|---|
get_stock_bars | Historical OHLCV bars |
get_stock_quotes | Historical bid/ask quotes |
get_stock_trades | Historical trades |
get_stock_latest_bar | Latest minute bar |
get_stock_latest_quote | Latest quote |
get_stock_latest_trade | Latest trade |
get_stock_snapshot | Comprehensive snapshot (quote, trade, bars) |
get_most_active_stocks | Most active by volume/trade count |
get_market_movers | Top gainers and losers |
Crypto Data
| Tool | Description |
|---|---|
get_crypto_bars | Historical OHLCV bars |
get_crypto_quotes | Historical quotes |
get_crypto_trades | Historical trades |
get_crypto_latest_bar | Latest minute bar |
get_crypto_latest_quote | Latest quote |
get_crypto_latest_trade | Latest trade |
get_crypto_snapshot | Comprehensive snapshot |
get_crypto_latest_orderbook | Latest orderbook with bid/ask depth |
Options Data
| Tool | Description |
|---|---|
get_option_bars | Historical OHLCV bars |
get_option_trades | Historical trades |
get_option_latest_trade | Latest trade |
get_option_latest_quote | Latest quote with bid/ask |
get_option_snapshot | Snapshot with Greeks and IV |
get_option_chain | Full option chain for an underlying |
get_option_exchange_codes | Exchange code to name mapping |
Fixed Income Data
| Tool | Description |
|---|---|
get_fixed_income_latest_quotes | Latest quotes for fixed income securities by ISIN |
Index Data
| Tool | Description |
|---|---|
get_index_latest_values | Latest values for market indices |
get_index_values | Historical values for market indices |
Corporate Actions & News
| Tool | Description |
|---|---|
get_corporate_actions | Corporate actions from market data API |
get_news | News 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=falsewith live API keys.
Important Considerations
- API key security: Never paste API keys into chat. Configure them only in your MCP client's
envblock 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=falsewith 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
- GitHub Repository
- V2 Launch Blog Post
- Cursor Directory
- Contributing & Development (AGENTS.md)
- Alpaca Support
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.