home / mcp / alpaca mcp server
Provides access to Alpaca’s market data, accounts, orders, and watchlists via MCP for LLM-driven trading workflows.
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.
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.
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.txtCreate 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 = NoneYou 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.pyTreat 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.
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.
- 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.
Query account balances, buying power, margin, and status.
List all currently held assets with details.
Retrieve detailed info for a specific holding.
Liquidate all or part of a position by share count or percentage.
Liquidate entire portfolio or cancel pending orders.
Fetch real-time bid/ask for a stock.
Retrieve OHLCV historical bars for a symbol with customizable timeframe.
Get a comprehensive snapshot including quote, trade, and bars.
Place stock orders of various types (market, limit, etc.).
Cancel a specific order by its ID.
Execute multi-leg or single-leg option strategies.
Fetch option contracts with rich filtering.
Retrieve latest quote for an option contract.
Check current market open/close times.
Fetch trading holidays and sessions.
Retrieve saved watchlists.
Create a new watchlist with symbols.
Modify an existing watchlist.
Search for asset metadata.
List tradable assets with filters.