Official Alpaca trading for stocks, ETFs, crypto, options
## Alpaca Trading MCP Server: Stock Trading API The **Alpaca Trading MCP Server** integrates Alpaca's commission-free trading platform into Google Antigravity, enabling developers to build trading applications and automate stock trading through AI-assisted financial workflows. ### Why Alpaca Trading MCP? - **Commission-Free**: Zero commission on stock and ETF trades - **Paper Trading**: Test strategies without real money - **Real-Time Data**: Live market data and streaming - **Fractional Shares**: Buy partial shares of expensive stocks - **Modern API**: REST and WebSocket APIs ### Key Features #### 1. Trading Operations ```javascript // Place market order const order = await alpaca.createOrder({ symbol: "AAPL", qty: 10, side: "buy", type: "market", time_in_force: "day" }); // Place limit order const limitOrder = await alpaca.createOrder({ symbol: "TSLA", qty: 5, side: "buy", type: "limit", limit_price: 200.00, time_in_force: "gtc" }); // Get positions const positions = await alpaca.getPositions(); // Close position await alpaca.closePosition({ symbol: "AAPL" }); ``` #### 2. Account and Market Data ```javascript // Get account info const account = await alpaca.getAccount(); console.log("Buying power:", account.buying_power); console.log("Portfolio value:", account.portfolio_value); // Get market data const bars = await alpaca.getBars({ symbols: ["AAPL", "GOOGL", "MSFT"], timeframe: "1Day", start: "2024-12-01", end: "2024-12-15" }); // Stream real-time quotes alpaca.streamQuotes(["AAPL"], (quote) => { console.log("Bid:", quote.bid_price, "Ask:", quote.ask_price); }); ``` ### Configuration ```json { "mcpServers": { "alpaca": { "command": "npx", "args": ["-y", "@anthropic/mcp-alpaca"], "env": { "ALPACA_API_KEY": "your-api-key", "ALPACA_SECRET_KEY": "your-secret-key", "ALPACA_PAPER": "true" } } } } ``` ### Use Cases **Algorithmic Trading**: Build automated trading strategies. **Portfolio Management**: Manage investment portfolios programmatically. **Trading Bots**: Create AI-powered trading assistants. The Alpaca Trading MCP Server brings stock trading automation to your workflow.
{
"mcpServers": {
"alpaca": {
"mcpServers": {
"alpaca": {
"env": {
"ALPACA_API_KEY": "YOUR_API_KEY",
"ALPACA_API_SECRET": "YOUR_SECRET"
},
"args": [
"-y",
"@alpacahq/alpaca-mcp-server"
],
"command": "npx"
}
}
}
}
}