Get the FREE Ultimate OpenClaw Setup Guide →

alpaca

Repository created by GitHub Project Operator

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio metachain-org-alpaca-mcp-server python alpaca_mcp_server.py \
  --env DATA_API_URL="<optional_data_api_url>" \
  --env TRADE_API_URL="<optional_trade_api_url_if_needed>" \
  --env TRADE_API_WSS="<optional_trade_api_wss_url>" \
  --env ALPACA_API_KEY="<your_alpaca_api_key_for_paper_or_live_account>" \
  --env STREAM_DATA_WSS="<optional_stream_data_wss_url>" \
  --env ALPACA_SECRET_KEY="<your_alpaca_secret_key_for_paper_or_live_account>" \
  --env ALPACA_PAPER_TRADE="True"

How to use

Alpaca MCP Server exposes a full MCP interface to interact with Alpaca's trading infrastructure. It supports market data retrieval, account and position management, order placement (stocks, options, and crypto), watchlist handling, and asset search. When connected from an MCP client (for example Claude Desktop or another compatible tool), you can query real-time quotes, execute orders, inspect balances and positions, and manage watchlists using natural-language prompts or structured MCP actions. The server is designed to work with both paper trading and live trading modes, depending on your API key configuration. The included environment variables allow you to switch between paper and live trading and configure the Alpaca endpoints as needed. The server translates MCP requests into Alpaca API calls and returns structured responses suitable for LLMs to reason about and present to users.

How to install

Prerequisites:\n- Python 3.8+ (recommended by the project)\n- Git for cloning the repository\n- Optional: virtual environment tools (venv)\n\nStep-by-step installation:\n1) Clone the repository and navigate to the project directory:\nbash\ngit clone https://github.com/alpacahq/alpaca-mcp-server.git\ncd alpaca-mcp-server\n\n2) Create and activate a virtual environment, then install dependencies:\nbash\npython3 -m venv venv\n# On macOS/Linux\nsource venv/bin/activate\n# On Windows\nvenv\Scripts\activate\npip install -r requirements.txt\n\n3) Configure environment variables:\n- Copy the example env file if provided and edit it, or create a new .env with keys like:\nbash\nALPACA_API_KEY=your_alpaca_api_key\nALPACA_SECRET_KEY=your_alpaca_secret_key\nALPACA_PAPER_TRADE=True\nTRADE_API_URL=None\nTRADE_API_WSS=None\nDATA_API_URL=None\nSTREAM_DATA_WSS=None\n\n4) Start the MCP server:\nbash\npython alpaca_mcp_server.py\n\nFor remote usage (HTTP transport) add the transport flag as described in the README.\n

Additional notes

Tips and caveats:\n- Ensure your Alpaca API keys have the appropriate permissions for the mode you intend (paper vs live).\n- If using a virtual environment, be mindful of the Python version used to create it; the server will use the Python from the active environment.\n- When integrating with Claude Desktop or other MCP clients, update the client configuration to point at the server transport you choose (stdio, http, or sse).\n- If you encounter connection issues with HTTP transport, verify host/port bindings and firewall rules.\n- For live trading, thoroughly test with paper trading first and confirm that ALPACA_PAPER_TRADE is set to True in your environment.\n- Monitor logs for Alpaca API rate limits or authentication errors and rotate keys if needed.\n

Related MCP Servers

Sponsor this space

Reach thousands of developers