alpacahq/alpaca-mcp-server

Alpaca’s official MCP Server lets you trade stocks, ETFs, crypto, and options, run data analysis, and build strategies in plain English directly from your favorite LLM tools and IDEs

alpaca‑mcp‑server – AI‑driven bridge to Alpaca’s Trading API

What it is

  • A Model Context Protocol (MCP) server that lets large‑language‑model assistants (Claude, Cursor, VS Code, etc.) call Alpaca’s stock/crypto/options trading and market‑data endpoints as if they were native tools.
  • Built in Python 3.10+ with FastMCP and an OpenAPI‑generated schema, so the LLM can discover the available functions automatically.

Why it matters

  • Turns natural‑language prompts like “Buy 10 shares of AAPL at market price” into real‑time trades, portfolio queries, or data look‑ups without writing any code.
  • Supports paper‑trading out‑of‑the‑box and can be switched to live trading with a single environment variable.
  • Provides fine‑grained tool‑set filtering (ALPACA_TOOLSETS) so you can expose only the capabilities you want the assistant to use.

Core capabilities (exposed as MCP tools)

Category Example tools
Account & portfolio get_account_info, get_portfolio_history, get_account_activities
Trading (orders) place_stock_order, place_crypto_order, place_option_order, cancel_all_orders
Positions get_all_positions, close_position, exercise_options_position
Market data get_stock_bars, get_stock_quotes, get_option_contracts, get_clock, get_news
Watchlists & assets create_watchlist, add_asset_to_watchlist_by_id, get_all_assets

How to run it

  1. Prerequisites – Python 3.10+, the uv package manager, and an Alpaca paper‑trading API key/secret.
  2. Installation – The server is distributed as a Python package; you can start it with uvx alpaca-mcp-server (or via Docker).
  3. Configuration – All settings are supplied via environment variables in the MCP client configuration:
    {
      "env": {
        "ALPACA_API_KEY": "<your key>",
        "ALPACA_SECRET_KEY": "<your secret>",
        "ALPACA_PAPER_TRADE": "true",   // set false for live trading
        "ALPACA_TOOLSETS": "stock-data,crypto-data" // optional filter
      }
    }
    
  4. Connect an LLM client – Add the server to Claude Desktop, Cursor, VS Code, PyCharm, Claude Code, Antigravity CLI, or any MCP‑compatible tool by pointing it to the uvx alpaca-mcp-server command (or the Docker image).

Typical workflow

  1. The assistant starts a chat and discovers the list of tools from the server’s OpenAPI spec.
  2. When the user asks for a trade or data, the model selects the appropriate tool, fills in the parameters, and the server forwards the request to Alpaca’s REST API.
  3. The server returns the API response (or a friendly summary) back to the model, which can then continue the conversation.

Example prompts you can try

  • “What’s my buying power?”get_account_info
  • “Buy 5 shares of AAPL at market price.”place_stock_order
  • “Show me the last 5 days of daily bars for TSLA.”get_stock_bars
  • “Create a watchlist called ‘Tech’ with AAPL, MSFT, NVDA.”create_watchlist

Upgrade note

  • Version 2 is a complete rewrite (FastMCP + OpenAPI). Tool names and schemas differ from v1, so existing client configs must be refreshed and any cached tool lists cleared.

Where to learn more

  • Official docs: https://docs.alpaca.markets
  • Deployment guide for remote use (Claude Mobile, ChatGPT connectors) is linked in the README.
  • Docker build instructions are provided for cloud hosting.

Bottom linealpaca-mcp-server is a production‑ready bridge that lets AI assistants act as fully‑featured trading bots, giving developers a way to embed natural‑language trading into their workflows while keeping the heavy lifting (authentication, rate‑limiting, schema validation) inside a maintained server.

Related

  • Project
  • Project
  • Project
  • Project
  • Project