by alpacahq
Enables large language models to trade stocks and options, retrieve real‑time and historical market data, and manage portfolios using plain English commands through a local or remote MCP server.
Alpaca MCP Server provides a bridge between LLMs (such as Claude Desktop, Cursor, or VS Code) and Alpaca's Trading API, allowing natural‑language interaction for stock and options trading, account management, market data retrieval, and watchlist handling.
.env file with your Alpaca API credentials (paper or live).python alpaca_mcp_server.pypython alpaca_mcp_server.py --transport http --host 0.0.0.0 --port 8000ALPACA_PAPER_TRADE=False in the .env file and provide live API keys.stdio (default), http, and deprecated sse. Use --transport flag to select.ghcr.io/chand1012/alpaca-mcp-server:latest or build locally.--port <PORT> when starting the server.stdio transport runs locally without network exposure.
You need the following prerequisites to configure and run the Alpaca MCP Server.
python3 --version in Terminal)uv can be installed either through a package manager (like Homebrew) or directly using curl | sh.Note: Using an MCP server requires installation and configuration of both the MCP server and MCP client.
Note: These steps assume all Prerequisites have been installed.
uvx or install.py → see Claude Desktop Configurationinstall.py to set up and auto-configure Cursor → see Cursor Configurationuvx → see VS Code Configurationuvx → see PyCharm Configurationuvx or Docker → see Claude Code Configurationuvx → see Gemini CLI ConfigurationNote: How to show hidden files
ls -aTo enable live trading with real funds or switch between different accounts, update API credentials in two places:
.env file (used by MCP server)Important: The MCP client configuration overrides the .env file. When using an MCP client, the credentials in the client's JSON config take precedence.
Method 1: Run the init command again to update your .env file
# Follow the prompts to update your keys and toggle paper/live trading
uvx alpaca-mcp-server init
Method 2: Manually Update
ALPACA_API_KEY = "your_alpaca_api_key_for_live_account"
ALPACA_SECRET_KEY = "your_alpaca_secret_key_for_live_account"
ALPACA_PAPER_TRADE = False
TRADE_API_URL = None
TRADE_API_WSS = None
DATA_API_URL = None
STREAM_DATA_WSS = None
Step 2-1: Edit your MCP client configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json (Mac) or %APPDATA%\Claude\claude_desktop_config.json (Windows)~/.cursor/mcp.json.vscode/mcp.json (workspace) or user settings.jsonStep 2-2: Update the API keys in the env section:
For uvx installations:
{
"mcpServers": {
"alpaca": {
"command": "uvx",
"args": ["alpaca-mcp-server", "serve"],
"env": {
"ALPACA_API_KEY": "your_alpaca_api_key_for_live_account",
"ALPACA_SECRET_KEY": "your_alpaca_secret_key_for_live_account"
}
}
}
}
Then, restart your MCP client (Claude Desktop, Cursor, etc.)
Note: Using an MCP server requires installation and configuration of both the MCP server and MCP client.
# Install and configure
uvx alpaca-mcp-server init
Note: If you don't have uv yet, install it first and then restart your terminal so uv/uvx are recognized. See the official guide: https://docs.astral.sh/uv/getting-started/installation/
Then add to your MCP client config :
Config file locations:
~/Library/Application Support/Claude/claude_desktop_config.json (Mac) or %APPDATA%\Claude\claude_desktop_config.json (Windows)~/.cursor/mcp.json (Mac/Linux) or %USERPROFILE%\.cursor\mcp.json (Windows){
"mcpServers": {
"alpaca": {
"command": "uvx",
"args": ["alpaca-mcp-server", "serve"],
"env": {
"ALPACA_API_KEY": "your_alpaca_api_key",
"ALPACA_SECRET_KEY": "your_alpaca_secret_key"
}
}
}
}
Clone the repository and navigate to the directory:
git clone https://github.com/alpacahq/alpaca-mcp-server.git
cd alpaca-mcp-server
Execute the following commands in your terminal:
cd alpaca-mcp-server
python3 install.py
Note: These steps assume all Prerequisites have been installed. Cursor users can install Alpaca's MCP Server directly from the Cursor Directory in just a few clicks.
1. Find Alpaca in the Cursor Directory
2. Click "Add to Cursor" to launch Cursor on your computer
3. Enter your API Key and Secret Key
4. You’re all set to start using it
# Clone and build
git clone https://github.com/alpacahq/alpaca-mcp-server.git
cd alpaca-mcp-server
docker build -t mcp/alpaca:latest .
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"alpaca-docker": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-e", "ALPACA_API_KEY=your_key",
"-e", "ALPACA_SECRET_KEY=your_secret",
"-e", "ALPACA_PAPER_TRADE=True",
"mcp/alpaca:latest"
]
}
}
}
After installing/cloning and activating the virtual environment, your directory structure should look like this:
alpaca-mcp-server/ ← This is the workspace folder (= project root)
├── src/ ← Source code package
│ └── alpaca_mcp_server/ ← Main package directory
│ ├── __init__.py
│ ├── cli.py ← Command-line interface
│ ├── config.py ← Configuration management
│ ├── helper.py ← Helper function management
│ └── server.py ← MCP server implementation
├── .github/ ← GitHub settings
│ ├── core/ ← Core utility modules
│ └── workflows/ ← GitHub Actions workflows
├── .vscode/ ← VS Code settings (for VS Code users)
│ └── mcp.json
├── .venv/ ← Virtual environment folder
│ └── bin/python
├── charts/ ← Kubernetes deployment configurations
│ └── alpaca-mcp-server/ ← Helm chart for GKE deployment
├── .env.example ← Environment template (use this to create `.env` file)
├── .gitignore
├── Dockerfile ← Docker configuration (for Docker use)
├── .dockerignore ← Docker ignore (for Docker use)
├── pyproject.toml ← Package configuration
├── requirements.txt ← Python dependencies
├── install.py ← Installation script
└── README.md
To access the latest 15-minute data, you need to subscribe to the Algo Trader Plus Plan.
At this moment, you can only view and update trading watchlists created via Alpaca’s Trading API through the API itself
The MCP server provides detailed, well-formatted responses for various trading queries. Here are some examples:
Query: "What are the option Greeks for TSLA250620P00500000?"
Response: Option Details:
Greeks:
Key Insights:
Query: "Place a bull call spread using AAPL June 6th options: one with a 190.00 strike and the other with a 200.00 strike."
Response: Order Details:
Spread Legs:
Long Leg (BUY):
Short Leg (SELL):
Strategy Summary:
These examples demonstrate the server's ability to provide:
get_account_info() – View balance, margin, and account statusget_all_positions() – List all held assetsget_open_position(symbol) – Detailed info on a specific positionget_asset(symbol) – Search asset metadataget_all_assets(status=None, asset_class=None, exchange=None, attributes=None) – List all tradable instruments with filtering optionsget_corporate_actions(ca_types=None, start=None, end=None, symbols=None, cusips=None, ids=None, limit=1000, sort="asc") – Historical and future corporate actions (e.g., earnings, dividends, splits)get_portfolio_history(timeframe=None, period=None, start=None, end=None, date_end=None, intraday_reporting=None, pnl_reset=None, extended_hours=None, cashflow_types=None) – Retrieve account portfolio history with equity and P/L over timecreate_watchlist(name, symbols) – Create a new listget_watchlists() – Retrieve all saved watchlistsupdate_watchlist_by_id(watchlist_id, name=None, symbols=None) – Modify an existing listget_watchlist_by_id(watchlist_id) – Get a specific watchlist by its IDadd_asset_to_watchlist_by_id(watchlist_id, symbol) – Add an asset to a watchlistremove_asset_from_watchlist_by_id(watchlist_id, symbol) – Remove an asset from a watchlistdelete_watchlist_by_id(watchlist_id) – Delete a specific watchlistget_calendar(start_date, end_date) – Holidays and trading daysget_clock() – Market open/close schedule and current statusget_stock_bars(symbol, days=5, hours=0, minutes=15, timeframe="1Day", limit=1000, start=None, end=None, sort=Sort.ASC, feed=None, currency=None, asof=None) – OHLCV historical bars with flexible timeframes (1Min, 5Min, 1Hour, 1Day, etc.)get_stock_quotes(symbol, days=1, hours=0, minutes=15, limit=1000, sort=Sort.ASC, feed=None, currency=None, asof=None) – Historical quote data (level 1 bid/ask) for a stockget_stock_trades(symbol, days=1, minutes=15, hours=0, limit=1000, sort=Sort.ASC, feed=None, currency=None, asof=None) – Trade-level historyget_stock_latest_bar(symbol, feed=None, currency=None) – Most recent OHLC barget_stock_latest_quote(symbol_or_symbols, feed=None, currency=None) – Real-time bid/ask quote for one or more symbolsget_stock_latest_trade(symbol, feed=None, currency=None) – Latest market trade priceget_stock_snapshot(symbol_or_symbols, feed=None, currency=None) – Comprehensive snapshot with latest quote, trade, minute bar, daily bar, and previous daily barget_crypto_bars(symbol_or_symbols, days=1, timeframe="1Hour", limit=None, start=None, end=None, feed=CryptoFeed.US) – Historical price bars for cryptocurrency with configurable timeframeget_crypto_quotes(symbol_or_symbols, days=3, limit=None, start=None, end=None, feed=CryptoFeed.US) – Historical quote data (bid/ask) for cryptoget_crypto_trades(symbol_or_symbols, days=1, limit=None, start=None, end=None, sort=None, feed=CryptoFeed.US) – Historical trade prints for cryptocurrencyget_crypto_latest_quote(symbol_or_symbols, feed=CryptoFeed.US) – Latest quote for one or more crypto symbolsget_crypto_latest_bar(symbol_or_symbols, feed=CryptoFeed.US) – Latest minute bar for cryptoget_crypto_latest_trade(symbol_or_symbols, feed=CryptoFeed.US) – Latest trade for cryptoget_crypto_snapshot(symbol_or_symbols, feed=CryptoFeed.US) – Comprehensive crypto snapshot including latest trade, quote, minute bar, daily and previous daily barsget_crypto_latest_orderbook(symbol_or_symbols, feed=CryptoFeed.US) – Latest orderbook for cryptoget_option_contracts(underlying_symbol, expiration_date=None, expiration_date_gte=None, expiration_date_lte=None, expiration_expression=None, strike_price_gte=None, strike_price_lte=None, type=None, status=None, root_symbol=None, limit=None) – Get option contracts with flexible filteringget_option_latest_quote(option_symbol, feed=None) – Latest bid/ask on contractget_option_snapshot(symbol_or_symbols, feed=None) – Get Greeks and underlyingget_orders(status=None, limit=None, after=None, until=None, direction=None, nested=None, side=None, symbols=None) – Retrieve all or filtered ordersplace_stock_order(symbol, side, quantity, order_type="market", limit_price=None, stop_price=None, trail_price=None, trail_percent=None, time_in_force="day", extended_hours=False, client_order_id=None) – Place a stock order of any type (market, limit, stop, stop_limit, trailing_stop)place_crypto_order(symbol, side, order_type="market", time_in_force="gtc", qty=None, notional=None, limit_price=None, stop_price=None, client_order_id=None) – Place a crypto order supporting market, limit, and stop_limit types with GTC/IOC time in forceplace_option_market_order(legs, order_class=None, quantity=1, time_in_force="day", extended_hours=False) – Execute option strategy (single or multi-leg)cancel_all_orders() – Cancel all open orderscancel_order_by_id(order_id) – Cancel a specific orderclose_position(symbol, qty=None, percentage=None) – Close part or all of a positionclose_all_positions(cancel_orders=False) – Liquidate entire portfolioexercise_options_position(symbol_or_contract_id) – Exercise a held option contract, converting it into the underlying assetBelow you'll find step-by-step guides for connecting the Alpaca MCP server to various MCP clients. Choose the section that matches your preferred development environment or AI assistant.
Note: These steps assume all Prerequisites have been installed.
Simple and modern approach:
Install and configure the server:
uvx alpaca-mcp-server init
Open Claude Desktop → Settings → Developer → Edit Config
Add this configuration:
{
"mcpServers": {
"alpaca": {
"type": "stdio",
"command": "uvx",
"args": ["alpaca-mcp-server", "serve"],
"env": {
"ALPACA_API_KEY": "your_alpaca_api_key",
"ALPACA_SECRET_KEY": "your_alpaca_secret_key"
}
}
}
}
Restart Claude Desktop and start trading!
git clone https://github.com/alpacahq/alpaca-mcp-server.git
cd alpaca-mcp-server
python3 install.py
Choose claude when prompted. The installer sets up .venv, writes .env, and updates claude_desktop_config.json. Restart Claude Desktop.
Note: These steps assume all Prerequisites have been installed.
As of Nov 20, 2025, Alpaca does not provide a hosted Remote MCP Server. To use Alpaca's MCP Server on the Claude mobile app, you need to host it remotely on a cloud service, then connect it as a Connector on Claude desktop to access it from the mobile app. For more information, visit "Connecting Claude to a tool" or our learn article “How to Deploy Alpaca’s MCP Server Remotely on Claude Mobile App”.
Below is an example overview showing one approach to set up a remote Alpaca MCP Server using Docker and connect it to the Claude mobile app. Other deployment methods are also possible.
Start by installing Alpaca’s MCP Server on your local machine. Open Terminal (macOS/Linux) or Command Prompt/PowerShell (Windows), then enter the following commands:
git clone https://github.com/alpacahq/alpaca-mcp-server.git
cd alpaca-mcp-server
Before proceeding, install Docker (or Docker Desktop for a GUI). After installation, run the following command to verify Docker is installed on your computer:
docker version
docker info
Then, log in to Docker Hub through CLI. You’ll be prompted for your Docker Hub username and password. This is required for pushing Docker images to Docker hub later.
docker login
Once you log in to your Docker account, use your Docker username and a custom image name (e.g., alpaca-mcp-server) to build and push the Docker image to Docker Hub. We use the tag v0.1 in this example.
# Build for most cloud platforms
docker buildx build -t username/custom-docker-image-name:v0.1 --platform=linux/amd64,linux/arm64
# Push to Docker Hub
docker push username/custom-docker-image-name:v0.1
You can do a sanity check locally by running the following command in terminal:
docker run --rm -p 8000:8000 -e PORT=8000 username/custom-docker-image-name:v0.1 python -m alpaca_mcp_server.server --transport streamable-http --host 0.0.0.0 --port 8000
Now that we've pushed the Docker image (containerized Alpaca's MCP Server) to Docker Hub, we can host it as a web service using a cloud platform such as AWS, Azure, or GCP. You can use any cloud platform you prefer.
For a simpler approach, visit our learn article “How to Deploy Alpaca’s MCP Server Remotely on Claude Mobile App” where we demonstrate using Render instead.
We also provide a Helm chart under alpaca-mcp-server/charts/alpaca-mcp-server for deploying the Alpaca's MCP Server to Kubernetes (Google Kubernetes Engine) as an example.
Step 1: Deploy to GKE Required Configuration Updates:
Before deploying with Helm, you must update the following values in charts/alpaca-mcp-server/values.yaml:
Docker Image Configuration:
image:
repository: username/custom-docker-image-name # Your Docker Hub repository
tag: "v0.1" # Your image tag
env:
secrets:
ALPACA_API_KEY: "your-actual-api-key"
ALPACA_SECRET_KEY: "your-actual-secret-key"
ALPACA_BASE_URL: "https://paper-api.alpaca.markets" # or https://api.alpaca.markets for live
ingress:
hosts:
- host: your-domain.com # Replace with your domain
tls:
- secretName: cert-your-domain # Replace with your cert secret name
hosts:
- your-domain.com # Replace with your domain**Deploy with Helm:**
Once you've updated values.yaml, deploy with:
helm upgrade --install alpaca-mcp-server ./charts/alpaca-mcp-server --create-namespace
Step 2: Connect with Claude Web
Once deploy Alpaca's MCP Server, it will be accessible at https://your-domain.com. Go to Claude Webpage.
From a chat:
https://your-domain.com/mcp in "Remote MCP Server URL" (ensure it ends with /mcp)Step 3. Use Alpaca’s MCP Server on Claude Mobile App Once you successfully connect Alpaca's MCP Server to Claude web, it will also be available as a connector in the Claude mobile app.
Note: These steps assume all Prerequisites have been installed.
As of Nov 20, 2025, Alpaca does not provide a hosted Remote MCP Server. To use Alpaca's MCP Server on the ChatGPT app, you need to host it remotely on a cloud service, then connect it as a Connector on ChatGPT web or mobile app to access it. For more information, visit "Connectors in ChatGPT" or our learn article “How to Deploy Alpaca’s MCP Server Remotely on Claude Mobile App” as a reference.
Below is an example overview showing one approach to set up a remote Alpaca MCP Server using Docker and connect it to the ChatGPT. Other deployment methods are also possible.
For more information, refer to Claude Mobile Configuration above or visit our learn article "How to Deploy Alpaca's MCP Server Remotely on Claude Mobile App" as a reference.
Note: These steps assume all Prerequisites have been installed.
The official Cursor MCP setup document is available here: https://docs.cursor.com/context/mcp
For Cursor users, you can quickly install Alpaca from the Cursor Directory in just a few clicks.
1. Find Alpaca in the Cursor Directory
2. Click "Add to Cursor" to launch Cursor on your computer
3. Enter your API Key and Secret Key
4. You’re all set to start using it
git clone https://github.com/alpacahq/alpaca-mcp-server.git
cd alpaca-mcp-server
python3 install.py
During the prompts, choose cursor and enter your API keys. The installer creates a .venv, writes a .env, and auto-updates ~/.cursor/mcp.json. Restart Cursor to load the config.
Note: If uv is not installed, the installer can help you install it. You may need to restart your terminal after installing uv so uv/uvx are recognized.
If you want to confirm your configuration or change the API keys, open and edit ~/.cursor/mcp.json (macOS/Linux) or %USERPROFILE%\.cursor\mcp.json (Windows):
{
"mcpServers": {
"alpaca": {
"type": "stdio",
"command": "uvx",
"args": ["alpaca-mcp-server", "serve"],
"env": {
"ALPACA_API_KEY": "your_alpaca_api_key",
"ALPACA_SECRET_KEY": "your_alpaca_secret_key"
}
}
}
}
To use Alpaca MCP Server with VS Code, please follow the steps below.
VS Code supports MCP servers through GitHub Copilot's agent mode. The official VS Code setup document is available here: https://code.visualstudio.com/docs/copilot/chat/mcp-servers
Note: These steps assume all Prerequisites have been installed.
Recommendation: Use workspace-specific configuration (.vscode/mcp.json) instead of user-wide configuration. This allows different projects to use different API keys (multiple paper accounts or live trading) and keeps trading tools isolated from other development work.
For workspace-specific settings:
Create .vscode/mcp.json in your project root.
Add the Alpaca MCP server configuration manually to the mcp.json file:
{
"mcp": {
"servers": {
"alpaca": {
"type": "stdio",
"command": "uvx",
"args": ["alpaca-mcp-server", "serve"],
"env": {
"ALPACA_API_KEY": "your_alpaca_api_key",
"ALPACA_SECRET_KEY": "your_alpaca_secret_key"
}
}
}
}
}
Note: Replace ${workspaceFolder} with your actual project path. For example:
/Users/username/Documents/alpaca-mcp-serverC:\\Users\\username\\Documents\\alpaca-mcp-serverFor user-wide settings:
To configure an MCP server for all your workspaces, you can add the server configuration to your user settings.json file. This allows you to reuse the same server configuration across multiple projects.
Specify the server in the mcp VS Code user settings (settings.json) to enable the MCP server across all workspaces.
{
"mcp": {
"servers": {
"alpaca": {
"type": "stdio",
"command": "bash",
"args": ["-c", "cd ${workspaceFolder} && source ./.venv/bin/activate && alpaca-mcp-server serve"],
"env": {
"ALPACA_API_KEY": "your_alpaca_api_key",
"ALPACA_SECRET_KEY": "your_alpaca_secret_key"
}
}
}
}
}
Note: These steps assume all Prerequisites have been installed.
To use the Alpaca MCP Server with PyCharm, please follow the steps below. The official setup guide for configuring the MCP Server in PyCharm is available here: https://www.jetbrains.com/help/ai-assistant/configure-an-mcp-server.html
PyCharm supports MCP servers through its integrated MCP client functionality. This configuration ensures proper logging behavior and prevents common startup issues.
File → SettingsTools → Model Context Protocol (MCP) (or similar location depending on PyCharm version)Add or + to create a new server configuration. You can also import the settings from Claude by clicking the corresponding button.Add the following environment variables in the Environment Variables parameter:
ALPACA_API_KEY="your_alpaca_api_key"
ALPACA_SECRET_KEY="your_alpaca_secret_key"
MCP_CLIENT=pycharm
Note: These steps assume all Prerequisites have been installed.
.env):uvx alpaca-mcp-server init
claude mcp add alpaca --scope user --transport stdio uvx alpaca-mcp-server serve \
--env ALPACA_API_KEY=your_alpaca_api_key \
--env ALPACA_SECRET_KEY=your_alpaca_secret_key
--scope user adds the server globally (available in all projects)--scope user to add it only to the current projectRequires Docker installed and the image built locally (see Docker Configuration).
claude mcp add alpaca-docker --scope user --transport stdio \
--env ALPACA_API_KEY=your_alpaca_api_key \
--env ALPACA_SECRET_KEY=your_alpaca_secret_key \
--env ALPACA_PAPER_TRADE=True \
-- docker run -i --rm \
-e ALPACA_API_KEY \
-e ALPACA_SECRET_KEY \
-e ALPACA_PAPER_TRADE \
mcp/alpaca:latest
--scope user adds the server globally (available in all projects)--scope user to add it only to the current projectclaude/mcp and confirm the alpaca server and tools are listedclaude mcp list to review registered serversNote: These steps assume all Prerequisites have been installed. Also, Gemini CLI requires Node.js version 20 or higher.
Install and Initialize the server (creates a local .env):
uvx alpaca-mcp-server init
Configure MCP servers in settings.json using the mcpServers object for specific server definitions and the mcp object for global settings. Gemini CLI uses this configuration to locate and connect to servers, supporting multiple servers with different transport mechanisms.
{
"mcpServers": {
"alpaca": {
"type": "stdio",
"command": "uvx",
"args": ["alpaca-mcp-server", "serve"],
"env": {
"ALPACA_API_KEY": "your_alpaca_api_key",
"ALPACA_SECRET_KEY": "your_alpaca_secret_key"
}
}
}
}
For more information, visit the How to set up your MCP server in Gemini CLI.
Note: These steps assume all Prerequisites have been installed. For more practical instruction, visit
Build the image:
git clone https://github.com/alpacahq/alpaca-mcp-server.git
cd alpaca-mcp-server
docker build -t mcp/alpaca:latest .
Add to Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"alpaca-docker": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-e", "ALPACA_API_KEY=your_alpaca_api_key",
"-e", "ALPACA_SECRET_KEY=your_alpaca_secret_key",
"-e", "ALPACA_PAPER_TRADE=True",
"mcp/alpaca:latest"
]
}
}
}
Replace your_alpaca_api_key and your_alpaca_secret_key with your actual Alpaca credentials, then restart Claude Desktop.
The Alpaca MCP Server supports OAuth 2.0 bearer token authentication for hosted deployments where LLM chatbots need to authenticate on behalf of end users. This is particularly useful for multi-tenant scenarios where different users access the same MCP server instance.
When the MCP server receives an HTTP request with an Authorization header:
This is a passthrough authentication mechanism - the MCP server simply forwards the Authorization header from your LLM chatbot to Alpaca's API.
Your LLM chatbot should include the Authorization header with each HTTP request to the MCP server:
Authorization: Bearer <access-token>
Example using cURL:
curl -X POST https://your-mcp-server.com/mcp \
-H "Authorization: Bearer YOUR_OAUTH_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "get_account_info"}}'
No special configuration required! The MCP server automatically:
Authorization header in incoming HTTP requests (when using --transport streamable-http)To get OAuth tokens for your users, follow Alpaca's OAuth 2.0 flow:
Example token exchange:
curl -X POST https://api.alpaca.markets/oauth/token \
-d "grant_type=authorization_code" \
-d "code=67f74f5a-a2cc-4ebd-88b4-22453fe07994" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET" \
-d "redirect_uri=YOUR_REDIRECT_URI"
# Your LLM chatbot making authenticated requests to the MCP server
import requests
# Token obtained from Alpaca OAuth flow for this specific user
user_oauth_token = "79500537-5796-4230-9661-7f7108877c60"
response = requests.post(
"https://your-mcp-server.com/mcp",
headers={
"Authorization": f"Bearer {user_oauth_token}",
"Content-Type": "application/json"
},
json={
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "get_account_info",
"arguments": {}
}
}
)
print(response.json())
Note: You typically don't need to manually start the server for local usage. MCP clients like Claude Desktop and Cursor will automatically start the server when configured. Use this section only for remote access setups.
For users who need to run the MCP server on a remote machine (e.g., Ubuntu server) and connect from a different machine (e.g., Windows Claude Desktop), use HTTP transport:
# Start server with HTTP transport (default: 127.0.0.1:8000)
alpaca-mcp-server serve --transport http
# Start server with custom host/port for remote access
alpaca-mcp-server serve --transport http --host 0.0.0.0 --port 9000
# For systemd service (example from GitHub issue #6)
# Update your start script to use HTTP transport
#!/bin/bash
cd /root/alpaca-mcp-server
source .venv/bin/activate
exec alpaca-mcp-server serve --transport http --host 0.0.0.0 --port 8000
Remote Access Options:
--host 0.0.0.0 to bind to all interfaces for direct remote accessssh -L 8000:localhost:8000 user@your-server for secure access (recommended for localhost binding)Update your Claude Desktop configuration to use HTTP:
{
"mcpServers": {
"alpaca": {
"type": "http",
"url": "http://your-server-ip:8000/mcp",
"env": {
"ALPACA_API_KEY": "your_alpaca_api_key",
"ALPACA_SECRET_KEY": "your_alpaca_secret_key"
}
}
}
}
--transport http--host 0.0.0.0 for direct access, or SSH tunneling for localhost binding--port <PORT> to specify a different port if default is busyAvailable transport options:
--transport stdio (default): Standard input/output for local client connections (automatically used by MCP clients)--transport http: HTTP transport for remote client connections (default: 127.0.0.1:8000)--transport sse: Server-Sent Events transport for remote connections (deprecated)--host HOST: Host to bind the server to for HTTP/SSE transport (default: 127.0.0.1)--port PORT: Port to bind the server to for HTTP/SSE transport (default: 8000)Note: For more information about MCP transport methods, see the official MCP transport documentation.
uv/uvx are on PATH..env not applied: Ensure the server starts in the same directory as .env. Remember MCP client env overrides .env.ALPACA_API_KEY and ALPACA_SECRET_KEY in .env or in the client's env block. Paper mode default is ALPACA_PAPER_TRADE = True.--transport http, change --port to a free port.Insights generated by our MCP server and connected AI agents are for educational and informational purposes only and should not be taken as investment advice. Alpaca does not recommend any specific securities or investment strategies.Please conduct your own due diligence before making any decisions. All firms mentioned operate independently and are not liable for one another.
Options trading is not suitable for all investors due to its inherent high risk, which can potentially result in significant losses. Please read Characteristics and Risks of Standardized Options (Options Disclosure Document) before investing in options.
Alpaca does not prepare, edit, endorse, or approve Third Party Content. Alpaca does not guarantee the accuracy, timeliness, completeness or usefulness of Third Party Content, and is not responsible or liable for any content, advertising, products, or other materials on or available from third party sites.
All investments involve risk, and the past performance of a security, or financial product does not guarantee future results or returns. There is no guarantee that any investment strategy will achieve its objectives. Please note that diversification does not ensure a profit, or protect against loss. There is always the potential of losing money when you invest in securities, or other financial products. Investors should consider their investment objectives and risks carefully before investing.
The algorithm’s calculations are based on historical and real-time market data but may not account for all market factors, including sudden price moves, liquidity constraints, or execution delays. Model assumptions, such as volatility estimates and dividend treatments, can impact performance and accuracy. Trades generated by the algorithm are subject to brokerage execution processes, market liquidity, order priority, and timing delays. These factors may cause deviations from expected trade execution prices or times. Users are responsible for monitoring algorithmic activity and understanding the risks involved. Alpaca is not liable for any losses incurred through the use of this system.
Past hypothetical backtest results do not guarantee future returns, and actual results may vary from the analysis.
The Paper Trading API is offered by AlpacaDB, Inc. and does not require real money or permit a user to transact in real securities in the market. Providing use of the Paper Trading API is not an offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, given or in any manner endorsed by AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate and the information made available through the Paper Trading API is not an offer or solicitation of any kind in any jurisdiction where AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate (collectively, “Alpaca”) is not authorized to do business.
Securities brokerage services are provided by Alpaca Securities LLC ("Alpaca Securities"), member FINRA/SIPC, a wholly-owned subsidiary of AlpacaDB, Inc. Technology and services are offered by AlpacaDB, Inc.
Cryptocurrency services are provided by Alpaca Crypto LLC ("Alpaca Crypto"), a FinCEN registered money services business (NMLS # 2160858), and a wholly-owned subsidiary of AlpacaDB, Inc. Alpaca Crypto is not a member of SIPC or FINRA. Cryptocurrencies are not stocks and your cryptocurrency investments are not protected by either FDIC or SIPC. Cryptocurrency assets are highly volatile and speculative, involving substantial risk of loss, and are not insured by the FDIC or any government agency. Customers should be aware of the various risks prior to engaging these services, including potential loss of principal, cybersecurity considerations, regulatory developments, and the evolving nature of digital asset technology. For additional information on the risks of cryptocurrency, please click here.
This is not an offer, solicitation of an offer, or advice to buy or sell securities or cryptocurrencies or open a brokerage account or cryptocurrency account in any jurisdiction where Alpaca Securities or Alpaca Crypto, respectively, are not registered or licensed, as applicable.
This server can place real trades and access your portfolio. Treat your API keys as sensitive credentials. Review all actions proposed by the LLM carefully, especially for complex options strategies or multi-leg trades.
HTTP Transport Security: When using HTTP transport, the server defaults to localhost (127.0.0.1:8000) for security. For remote access, you can bind to all interfaces with --host 0.0.0.0, use SSH tunneling (ssh -L 8000:localhost:8000 user@server), or set up a reverse proxy with authentication for secure access.
The user agent for API calls defaults to 'ALPACA-MCP-SERVER' to help Alpaca identify MCP server usage and improve user experience. You can opt out by modifying the 'USER_AGENT' constant in '.github/core/user_agent_mixin.py' or by removing the 'UserAgentMixin' from the client class definitions in 'src/alpaca_mcp_server/server.py' — though we kindly hope you'll keep it enabled to support ongoing improvements.
mcp-name: io.github.alpacahq/alpaca-mcp-server
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by stripe
Provides SDKs and tools to integrate Stripe's billing and API services with large language models, agent frameworks, and token‑metering for AI‑powered products and businesses.
by goat-sdk
Enables AI agents to send and receive payments, purchase goods and services, execute investment strategies, tokenize assets, and obtain financial insights by leveraging blockchains, stablecoins, and wallets.
by financial-datasets
Provides access to income statements, balance sheets, cash flow statements, stock prices, market news, and cryptocurrency data through MCP tools for AI assistants.
by stefanoamorelli
Provides an MCP server that connects AI models to SEC EDGAR filings, enabling real‑time retrieval of company filings, financial statements, and insider‑trading data with exact XBRL precision and verifiable filing references.
by ariadng
Enables AI LLMs to execute trades on the MetaTrader 5 platform through the Model Context Protocol.
by XeroAPI
Provides a bridge between the Model Context Protocol and Xero's API, enabling standardized access to Xero accounting and business features.
by kukapay
Provides a comprehensive set of cryptocurrency technical analysis indicators and ready‑to‑use trading strategies through an MCP interface, enabling AI agents and applications to generate buy, hold, or sell signals.
by kukapay
Integrates the Freqtrade cryptocurrency trading bot with MCP, exposing its REST API as tools for AI agents to perform automated trading operations.
by calvernaz
Provides access to Alpha Vantage stock market data via an MCP server, supporting stdio and HTTP streaming modes with optional OAuth 2.1 authentication.
{
"mcpServers": {
"alpaca": {
"command": "python",
"args": [
"alpaca_mcp_server.py"
],
"env": {
"ALPACA_API_KEY": "<YOUR_API_KEY>",
"ALPACA_SECRET_KEY": "<YOUR_SECRET_KEY>",
"ALPACA_PAPER_TRADE": "True"
}
}
}
}claude mcp add alpaca python alpaca_mcp_server.py