/ Directory / Playground / Alpaca
● Official alpacahq 🔑 Needs your key

Alpaca

by alpacahq · alpacahq/alpaca-mcp-server

Let Claude research, backtest, and place trades on stocks, ETFs, options, and crypto via Alpaca — paper-first so you won't blow up your account.

Alpaca's official MCP wraps the Alpaca Trading and Market Data APIs. Pull quotes, bars, fundamentals, and positions; place/modify/cancel orders. Defaults to paper trading, which is exactly how you should learn this. Flip to live only once a strategy is proven.

Why use it

Key features

Live Demo

What it looks like in practice

alpaca.replay ▶ ready
0/0

Install

Pick your client

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": [
        "alpaca-mcp-server"
      ]
    }
  }
}

Open Claude Desktop → Settings → Developer → Edit Config. Restart after saving.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": [
        "alpaca-mcp-server"
      ]
    }
  }
}

Cursor uses the same mcpServers schema as Claude Desktop. Project config wins over global.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": [
        "alpaca-mcp-server"
      ]
    }
  }
}

Click the MCP Servers icon in the Cline sidebar, then "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "alpaca": {
      "command": "uvx",
      "args": [
        "alpaca-mcp-server"
      ]
    }
  }
}

Same shape as Claude Desktop. Restart Windsurf to pick up changes.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "alpaca",
      "command": "uvx",
      "args": [
        "alpaca-mcp-server"
      ]
    }
  ]
}

Continue uses an array of server objects rather than a map.

~/.config/zed/settings.json
{
  "context_servers": {
    "alpaca": {
      "command": {
        "path": "uvx",
        "args": [
          "alpaca-mcp-server"
        ]
      }
    }
  }
}

Add to context_servers. Zed hot-reloads on save.

claude mcp add alpaca -- uvx alpaca-mcp-server

One-liner. Verify with claude mcp list. Remove with claude mcp remove.

Use Cases

Real-world ways to use Alpaca

Generate a daily pre-market brief for your watchlist

👤 Active retail traders ⏱ ~10 min beginner

When to use: You want a 30-second morning check on your 20 tickers before the open — overnight moves, earnings, obvious news.

Prerequisites
  • Alpaca account (free paper) — alpaca.markets → sign up → API keys on the dashboard
  • Watchlist of symbols — Plain list like [AAPL, MSFT, NVDA, ...]
Flow
  1. Pull overnight bar data
    For my watchlist [symbols], get yesterday's close and the latest pre-market quote. Compute % gap.✓ Copied
    → Table: symbol, prev_close, pre_open, gap_pct
  2. Flag outliers
    Which tickers are gapping more than 2% in either direction? Rank by gap magnitude.✓ Copied
    → Short 'needs attention' list
  3. Add context
    For each outlier, pull the latest news headlines from Alpaca news endpoint.✓ Copied
    → Per-ticker bullet with likely cause

Outcome: A 1-screen daily pre-market brief, same shape every day, no manual clicking.

Pitfalls
  • Free market data is IEX-only and lags; quotes may not match your broker — Fine for overnight/EOD analysis; if you need SIP feed, upgrade to Alpaca's paid data plan
Combine with: notion

Paper-trade a simple rules-based strategy

👤 Algo-trading beginners ⏱ ~30 min intermediate

When to use: You have a rule like 'buy SPY when 5-day return < -3%, sell after +2% or 5 trading days' and want to run it live on paper money.

Prerequisites
  • Paper account keys configured — Use APCA_API_BASE_URL=https://paper-api.alpaca.markets
  • A written rule — Entry, exit, position size, max loss — all explicit before coding anything
Flow
  1. Check account and positions
    Show my paper account equity, buying power, and current open positions.✓ Copied
    → Clean account snapshot
  2. Evaluate entry condition today
    Get SPY's last 5 daily bars. Compute 5-day return. If it's < -3% and I don't already hold SPY, place a market buy for $5000 notional. Otherwise do nothing.✓ Copied
    → Either an order id or an explicit 'no action'
  3. Log today's decision
    Append a row to /trades/journal.csv: date, condition_met, action, order_id, fill_price.✓ Copied
    → Journal row written

Outcome: An auditable daily run of a simple strategy against paper money, with a journal you can review.

Pitfalls
  • Accidentally running against live keys during testing — Keep a very obvious check at the start: confirm the account number matches your paper account before placing any order
  • Claude forgets yesterday's position and double-buys — Always fetch current positions before evaluating entry; never rely on memory
Combine with: filesystem

Rebalance a portfolio to target allocations

👤 DIY investors with a target allocation ⏱ ~20 min intermediate

When to use: Quarterly: bring 60/30/10 (US/INTL/bonds) back to target without manually computing share counts.

Prerequisites
  • Target allocation defined — e.g. VTI 60%, VXUS 30%, BND 10%
Flow
  1. Measure drift
    Get my positions and current prices. Compute current weight per symbol vs target [paste targets]. Show drift in $ and %.✓ Copied
    → Per-symbol drift table
  2. Propose trades
    Propose the minimum set of buys/sells to bring weights within 1% of target. Show expected commissions (likely $0) and estimated slippage.✓ Copied
    → Order plan
  3. Execute with confirmation
    Before placing: summarize the plan in 3 lines and wait for my 'yes'. On yes, submit as market-on-open orders.✓ Copied
    → Orders placed with ids; equity matches target within 1%

Outcome: A clean quarterly rebalance with a written record of why each trade happened.

Pitfalls
  • Taxable account: every rebalance triggers gains/losses — Prefer new-contribution rebalancing or tax-lot-aware exits; run only in IRA if unsure
Combine with: filesystem

Scan an options chain for short-dated put premium

👤 Option income traders (cash-secured puts / covered calls) ⏱ ~25 min advanced

When to use: You want to find the best cash-secured put to sell on tickers you'd be happy to own, weekly.

Prerequisites
  • Options-enabled Alpaca account — Enable in account settings; paper works for learning
Flow
  1. Fetch chain + greeks
    Get the options chain for [ticker] expiring next Friday, puts only, strikes within 5% of spot. Include bid, ask, mid, delta, IV.✓ Copied
    → Chain table
  2. Rank by annualized yield
    Compute annualized return-on-cash for each strike assuming assignment. Filter delta between -0.15 and -0.30. Rank top 5.✓ Copied
    → Ranked short list
  3. Place sell-to-open with a limit at mid
    Place a sell-to-open limit order for 1 contract of the #1 strike at the mid. GTC, day-only.✓ Copied
    → Order id returned

Outcome: A repeatable weekly income routine with a conservative risk screen.

Pitfalls
  • Selling puts on companies you wouldn't want to own — Hard rule: only trade this strategy on 10 tickers you've pre-approved as long-term holds
  • Illiquid strikes with huge bid-ask — fills never happen at mid — Filter for open_interest > 500 and spread < 5% of mid before ranking
Combine with: notion

Combinations

Pair with other MCPs for X10 leverage

alpaca + notion

Daily pre-market brief delivered to a Notion page

Run my pre-market scan for watchlist and create a Notion page in 'Trading / Daily' with the results.✓ Copied
alpaca + filesystem

Trade journal: append every order and reason to a local CSV

After any place_order, append {ts, symbol, side, qty, reason} to /trading/journal.csv.✓ Copied
alpaca + postgres

Store daily equity curve for backtesting strategies

Every evening, INSERT today's account equity into the equity_curve table.✓ Copied

Tools

What this MCP exposes

ToolInputsWhen to callCost
get_account First call in any session — confirm you're on paper vs live free
get_positions Check current holdings before any entry logic free
get_bars symbol, timeframe, start, end, limit? Historical OHLCV for analysis and signals free (IEX) or paid (SIP)
get_latest_quote symbol Real-time price before placing an order free
place_order symbol, qty|notional, side, type, time_in_force, limit_price? Submit a new order (always paper-first) free (commission-free)
cancel_order order_id Cancel an open order before it fills free
get_options_chain underlying, expiration, side? Scan strikes for an options strategy free on Alpaca

Cost & Limits

What this costs to run

API quota
200 req/min on data API (free tier); trading API is effectively unthrottled at retail scale
Tokens per call
Account/positions: 200–500 tokens. Bars: scales with limit.
Monetary
Alpaca is commission-free. Paid market data plan ~$9/mo for SIP feed; free IEX feed is fine for most retail use.
Tip
Paper-trade every new strategy for at least 4 weeks before touching live money. It's free.

Security

Permissions, secrets, blast radius

Minimum scopes: Account API key + secret — Alpaca doesn't have sub-scopes
Credential storage: APCA_API_KEY_ID, APCA_API_SECRET_KEY, and APCA_API_BASE_URL in env vars
Data egress: All calls to api.alpaca.markets or paper-api.alpaca.markets
Never grant: Sharing live keys with any third-party service, including code hosts

Troubleshooting

Common errors and fixes

403 forbidden.insufficient-permissions

Your keys are for the wrong environment (live vs paper). Match APCA_API_BASE_URL to the key pair.

Verify: curl -H 'APCA-API-KEY-ID: ...' -H 'APCA-API-SECRET-KEY: ...' $APCA_API_BASE_URL/v2/account
422 buying_power insufficient

Your paper account reset, or you sized the trade beyond cash. Call get_account and recompute position size.

Bars return empty for recent timestamp

IEX feed has ~15-min delay on free tier, and doesn't serve every symbol. Use SIP or wait.

Order rejected: market closed

Default TIF is day; market-closed orders need time_in_force='opg' or 'cls' or switch to extended hours with extended_hours=true on limit orders.

Alternatives

Alpaca vs others

AlternativeWhen to use it insteadTradeoff
Interactive Brokers MCPYou need international markets or futuresMore complex auth (gateway app required); learning curve
Polygon.io MCPYou only need market data, no tradingNo order execution; paid for full coverage

More

Resources

📖 Read the official README on GitHub

🐙 Browse open issues

🔍 Browse all 400+ MCP servers and Skills