home / mcp / alpaca mcp server

Alpaca MCP Server

Provides access to Alpaca’s market data, accounts, orders, and watchlists via MCP for LLM-driven trading workflows.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "jbkix06-alpaca_mcp_server": {
      "command": "<project_root>/venv/bin/python",
      "args": [
        "alpaca_mcp_server.py"
      ],
      "env": {
        "ALPACA_API_KEY": "your_alpaca_api_key_for_paper_account",
        "ALPACA_SECRET_KEY": "your_alpaca_secret_key_for_paper_account"
      }
    }
  }
}

You can run the Alpaca MCP Server to let large language models interact with Alpaca’s trading capabilities. This server exposes market data, orders, accounts, watchlists, and more through the MCP interface, enabling you to perform trading tasks and retrieve real-time data from natural language prompts using compatible MCP clients.

How to use

You connect an MCP client (such as Claude Desktop, Cursor, or VS Code) to the Alpaca MCP Server and issue natural language queries to perform trading actions or fetch data. Typical workflows include checking your account balances and buying power, viewing positions, placing or canceling stock or option orders, retrieving market quotes and charts, and exploring option contracts. The server presents clear, actionable results with structured data so you can review details before taking any action. When you ask for complex actions (like multi-leg option strategies), the server returns the exact steps, expected outcomes, and risk notes to help you proceed confidently.

How to install

Prerequisites: you need Python and a GitHub account to access the MCP server. You also require Alpaca API keys (paper or live) and a client that supports MCP (such as Claude Desktop, Cursor, or VS Code). Install steps:

git clone https://github.com/jbkix06/alpaca-mcp-server.git
cd alpaca-mcp-server

python3 -m venv venv
source venv/bin/activate

pip install -r requirements.txt

Additional setup notes

Create and edit a credentials file and configuration as described in the setup steps. The following is an example of the environment values you will configure in your working environment (these variables are used by the MCP server to authenticate with Alpaca):

ALPACA_API_KEY = "your_alpaca_api_key_for_paper_account"
ALPACA_SECRET_KEY = "your_alpaca_secret_key_for_paper_account"
ALPACA_PAPER_TRADE = True
TRADE_API_URL = None
TRADE_API_WSS = None
DATA_API_URL = None
STREAM_DATA_WSS = None

Configuration and how to run

You run the MCP server from the project directory. The server can be started using Python from your virtual environment. The base start command shown in typical client configurations is:

<project_root>/venv/bin/python alpaca_mcp_server.py

Security and usage notes

Treat API keys as sensitive credentials. Review actions suggested by the MCP client, especially for complex option strategies or live trading scenarios. Do not share keys and avoid exposing them in public places.

Troubleshooting and tips

If your MCP client cannot connect, verify that the server process is running in the expected virtual environment and that the environment variables (ALPACA_API_KEY and ALPACA_SECRET_KEY) are set. Ensure you are using the correct start command for your environment and that the client is configured to point to the local MCP server as described in your client’s setup. If you switch between paper and live trading, update ALPACA_PAPER_TRADE and related URLs accordingly.

Examples of common tasks

- Check your account balance and buying power, then place a market buy for 10 shares of AAPL.

- Retrieve the latest quote for MSFT and pull 1-minute bars for the last 60 minutes.

Available tools

get_account_info

Query account balances, buying power, margin, and status.

get_positions

List all currently held assets with details.

get_open_position

Retrieve detailed info for a specific holding.

close_position

Liquidate all or part of a position by share count or percentage.

close_all_positions

Liquidate entire portfolio or cancel pending orders.

get_stock_quote

Fetch real-time bid/ask for a stock.

get_stock_bars

Retrieve OHLCV historical bars for a symbol with customizable timeframe.

get_stock_snapshot

Get a comprehensive snapshot including quote, trade, and bars.

place_stock_order

Place stock orders of various types (market, limit, etc.).

cancel_order_by_id

Cancel a specific order by its ID.

place_option_market_order

Execute multi-leg or single-leg option strategies.

get_option_contracts

Fetch option contracts with rich filtering.

get_option_latest_quote

Retrieve latest quote for an option contract.

get_market_clock

Check current market open/close times.

get_market_calendar

Fetch trading holidays and sessions.

get_watchlists

Retrieve saved watchlists.

create_watchlist

Create a new watchlist with symbols.

update_watchlist

Modify an existing watchlist.

get_asset_info

Search for asset metadata.

get_all_assets

List tradable assets with filters.