Get the FREE Ultimate OpenClaw Setup Guide →

alpaca

Model Context Protocol (MCP) server for Alpaca trading API

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio tedlikeskix-alpaca-mcp-server python /path/to/alpaca_mcp_server.py \
  --env API_KEY_ID="your_alpaca_api_key" \
  --env API_SECRET_KEY="your_alpaca_secret_key"

How to use

The Alpaca MCP Server exposes a set of natural-language friendly tools that let Claude or other MCP clients interact with the Alpaca trading API. It supports retrieving real-time market data, viewing account information, inspecting and managing positions, and placing or canceling orders. With commands like get_stock_quote(symbol) and get_stock_bars(symbol, days), you can fetch quotes and historical prices. You can also query get_account_info() and get_positions() to understand your trading status, and use place_market_order(...) or place_limit_order(...) to execute trades through natural language. For operations that affect your portfolio, such as cancel_all_orders() or close_all_positions(cancel_orders), you can manage risk and keep your account organized directly from the MCP interface.

How to install

Prerequisites:

  • Python 3.10+
  • Alpaca API keys (API_KEY_ID and API_SECRET_KEY)
  • Claude for Desktop or another MCP client

Installation steps:

# 1. Clone the repository
git clone https://github.com/YOUR_USERNAME/alpaca-mcp.git
cd alpaca-mcp

# 2. Install required Python packages
pip install mcp alpaca-py python-dotenv

# 3. Create a .env file with your Alpaca credentials (alternatively supply via MCP env vars)
# API_KEY_ID=your_alpaca_api_key
# API_SECRET_KEY=your_alpaca_secret_key

Configure the MCP server for your environment:

# Example: Run the server directly (adjust path as needed)
python alpaca_mcp_server.py

If you plan to connect via Claude Desktop, ensure the server is reachable and add the appropriate configuration in claude_desktop_config.json as shown in the README. You can also disable paper trading by adjusting your Alpaca client settings in the server code if needed.

Additional notes

Environment variables:

  • API_KEY_ID: Your Alpaca API key ID
  • API_SECRET_KEY: Your Alpaca API secret key
  • Optional: set paper=True/False in your TradingClient initialization if you modify the server code to control live vs. paper trading

Common issues:

  • Mismatched API keys or missing.env file can cause authentication errors. Ensure the keys are correct and loaded in the environment when the server starts.
  • If Claude cannot reach the server, verify network accessibility and that the Python process is running without errors.
  • By default, the server uses Alpaca's paper trading environment. Change settings in the server as needed to work with live trading, and be mindful of risks.

Security:

  • The MCP server can perform real trades if configured with live keys. Keep credentials secure and restrict access to trusted clients.

Related MCP Servers

Sponsor this space

Reach thousands of developers