Loading...
Loading...
Use Alpaca's MCP server to trade stocks, ETFs, crypto, and options through natural language in your IDE or AI assistant.
npx skill4agent add aradotso/mcp-skills alpaca-mcp-server-tradingSkill by ara.so — MCP Skills collection.
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\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"
}
}
}
}~/.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"
}
}
}
}.vscode/mcp.json{
"mcp": {
"servers": {
"alpaca": {
"type": "stdio",
"command": "uvx",
"args": ["alpaca-mcp-server"],
"env": {
"ALPACA_API_KEY": "your_alpaca_api_key",
"ALPACA_SECRET_KEY": "your_alpaca_secret_key"
}
}
}
}
}uvxalpaca-mcp-serverALPACA_API_KEY=your_alpaca_api_key
ALPACA_SECRET_KEY=your_alpaca_secret_keygit clone https://github.com/alpacahq/alpaca-mcp-server.git
cd alpaca-mcp-server
docker build -t mcp/alpaca:latest .{
"mcpServers": {
"alpaca": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-e", "ALPACA_API_KEY",
"-e", "ALPACA_SECRET_KEY",
"-e", "ALPACA_PAPER_TRADE=true",
"mcp/alpaca:latest"
]
}
}
}| Variable | Required | Default | Description |
|---|---|---|---|
| Yes | — | Alpaca API key |
| Yes | — | Alpaca secret key |
| No | | Set to |
| No | all | Comma-separated toolsets to enable |
{
"env": {
"ALPACA_API_KEY": "your_live_api_key",
"ALPACA_SECRET_KEY": "your_live_secret_key",
"ALPACA_PAPER_TRADE": "false"
}
}ALPACA_TOOLSETS{
"env": {
"ALPACA_API_KEY": "your_alpaca_api_key",
"ALPACA_SECRET_KEY": "your_alpaca_secret_key",
"ALPACA_TOOLSETS": "stock-data,trading,account"
}
}accounttradingwatchlistsassetsstock-datacrypto-dataoptions-datacorporate-actionsnewsget_account_infoget_portfolio_historyBuy 10 shares of AAPL at market priceBuy 5 shares of TSLA with a limit price of $250Sell 3 shares of NVDA with a stop price of $800Buy 10 shares of GOOGL at market with a take-profit at $150 and stop-loss at $140Buy 0.1 BTC at market pricePlace a limit order to buy 1 ETH at $3000Show me call options for SPY expiring next Friday with strikes near $450Buy 1 call option for AAPL with strike $180 expiring in 30 daysCreate an iron condor for SPY with the following legs: buy 1 put at $440, sell 1 put at $445, sell 1 call at $455, buy 1 call at $460, all expiring next FridayGet the current price of AAPLShow me daily price bars for TSLA for the last monthGet a snapshot of NVDA including latest quote, trade, and daily barShow me the option chain for SPY expiring in 7 daysCreate a watchlist called "Tech Stocks" with AAPL, MSFT, GOOGLShow me all my watchlistsAdd TSLA to my "Tech Stocks" watchlistfrom alpaca.trading.client import TradingClient
from alpaca.trading.requests import MarketOrderRequest
from alpaca.trading.enums import OrderSide, TimeInForce
import os
# Initialize client
client = TradingClient(
api_key=os.environ["ALPACA_API_KEY"],
secret_key=os.environ["ALPACA_SECRET_KEY"],
paper=True # Use paper trading
)
# Get account info
account = client.get_account()
print(f"Buying power: ${account.buying_power}")
# Place market order
order_data = MarketOrderRequest(
symbol="AAPL",
qty=10,
side=OrderSide.BUY,
time_in_force=TimeInForce.DAY
)
order = client.submit_order(order_data)
print(f"Order submitted: {order.id}")
# Get all positions
positions = client.get_all_positions()
for position in positions:
print(f"{position.symbol}: {position.qty} shares @ ${position.avg_entry_price}")
# Cancel all orders
client.cancel_orders()from alpaca.data.historical import StockHistoricalDataClient
from alpaca.data.requests import StockBarsRequest
from alpaca.data.timeframe import TimeFrame
from datetime import datetime, timedelta
# Initialize data client (no auth needed for free data)
data_client = StockHistoricalDataClient(
api_key=os.environ["ALPACA_API_KEY"],
secret_key=os.environ["ALPACA_SECRET_KEY"]
)
# Get historical bars
request_params = StockBarsRequest(
symbol_or_symbols=["AAPL", "TSLA"],
timeframe=TimeFrame.Day,
start=datetime.now() - timedelta(days=30),
end=datetime.now()
)
bars = data_client.get_stock_bars(request_params)
for symbol, bar_set in bars.items():
print(f"\n{symbol}:")
for bar in bar_set:
print(f" {bar.timestamp}: O=${bar.open} H=${bar.high} L=${bar.low} C=${bar.close}")uvx alpaca-mcp-server --helpError: Invalid API credentialsALPACA_API_KEYALPACA_SECRET_KEYALPACA_PAPER_TRADE=truefalseError: This endpoint is not available for paper tradingALPACA_PAPER_TRADE=falseALPACA_TOOLSETS{
"env": {
"ALPACA_TOOLSETS": "account,trading,stock-data,options-data"
}
}Error: Insufficient buying powerError: Symbol not foundError: Rate limit exceeded.envinituvx alpaca-mcp-server==1.x.x serveError: Cannot connect to Docker daemondocker psList all available Alpaca tools