home / mcp / alpaca mcp server

Alpaca MCP Server

Provides access to Alpaca account data, positions, market quotes, and orders through an MCP interface.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "jwaresolutions-alpaca-mcp-server": {
      "command": "python",
      "args": [
        "/path/to/alpaca-mcp-server/alpaca_mcp_server.py"
      ],
      "env": {
        "APCA_API_KEY_ID": "YOUR_API_KEY_ID",
        "APCA_API_BASE_URL": "https://paper-api.alpaca.markets",
        "APCA_API_SECRET_KEY": "YOUR_API_SECRET_KEY"
      }
    }
  }
}

This MCP server provides an integrated bridge to the Alpaca Trading API, letting you access account data, portfolio details, real-time market quotes, and order management from your AI assistants and development tools. It supports paper trading for safe testing and can be used with live trading when you’re ready to go live.

How to use

You run the server locally and connect your MCP client to it to access a set of tools that expose Alpaca data and actions. Start the server in your environment, then use your MCP client to request account details, positions, quotes, and orders. Use the paper trading mode first to develop and test your workflows, and switch to live trading by updating the base URL when you are ready.

How to install

pip install alpaca-trade-api

Clone the project directory and navigate into it.

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

Set your Alpaca API credentials as environment variables. Use the paper trading base URL for testing.

export APCA_API_KEY_ID="your_api_key_here"
export APCA_API_SECRET_KEY="your_secret_key_here"
export APCA_API_BASE_URL="https://paper-api.alpaca.markets"  # Paper trading
# export APCA_API_BASE_URL="https://api.alpaca.markets"      # Live trading

Run the MCP server so it starts listening for JSON-RPC calls.

python alpaca_mcp_server.py

Configuration and integration

Use the following MCP configuration to connect your development tools. The server runs locally via Python and reads the required API credentials from environment variables.

{
  "mcpServers": {
    "alpaca": {
      "command": "python",
      "args": ["/path/to/alpaca-mcp-server/alpaca_mcp_server.py"],
      "env": {
        "APCA_API_KEY_ID": "your_api_key_here",
        "APCA_API_SECRET_KEY": "your_secret_key_here",
        "APCA_API_BASE_URL": "https://paper-api.alpaca.markets"
      }
    }
  }
}

Troubleshooting and safety

Safety first: the server defaults to paper trading, so you won’t risk real money during development. To switch to live trading, update the base URL to the live endpoint and confirm you’re fully prepared to trade with real funds.

export APCA_API_BASE_URL="https://api.alpaca.markets"  # Live trading

Development notes

If you need a quick test, you can invoke the server with a simple JSON-RPC call to list available tools once it is running.

Available tools

get_account

Retrieve comprehensive account information including status, buying power, cash, and portfolio metrics.

get_positions

Fetch current stock positions with symbol, quantity, market value, P&L, and unrealized gains or losses.

get_quote

Obtain real-time market quotes for a symbol, including bid/ask prices and sizes, with a timestamp.

get_orders

List recent orders with details such as id, status, symbol, quantity, type, side, fill info, and timestamps.