Alpaca Official MCP Server

Created By
alpacahq9 months ago
This is a Model Context Protocol (MCP) server implementation for Alpaca's Trading API. It enables large language models (LLMs) on Claude Desktop, Cursor, or VScode to interact with Alpaca's trading infrastructure using natural language (English). This server supports stock trading, options trading, portfolio management, watchlist handling, and real-time market data access.
Overview

Installation

0. Prerequisites

1. Installation

  1. Clone the repository and navigate to the directory:

    git clone https://github.com/alpacahq/alpaca-mcp-server.git
    cd alpaca-mcp-server
    
  2. Create and activate a virtual environment and Install the required packages:

    Option A: Using pip (traditional)

    python3 -m venv myvenv
    source myvenv/bin/activate  # On Windows: myvenv\Scripts\activate
    pip install -r requirements.txt
    

    Option B: Using uv (modern, faster)

    To use uv, you'll first need to install it. See the official uv installation guide for detailed installation instructions for your platform.

    uv venv myvenv
    source myvenv/bin/activate # On Windows: myvenv\Scripts\activate
    uv pip install -r requirements.txt
    

    Note: The virtual environment will use the Python version that was used to create it. If you run the command with Python 3.10 or newer, your virtual environment will also use Python 3.10+. If you want to confirm the version, you can run python3 --version after activating the virtual environment.

Project Structure

After cloning and activating the virtual environment, your directory structure should look like this:

alpaca-mcp-server/          ← This is the workspace folder (= project root)
├── alpaca_mcp_server.py    ← Script is directly in workspace root
├── .github/                ← VS Code settings (for VS Code users)
│ ├── core/                 ← Core utility modules
│ └── workflows/            ← GitHub Actions workflows
├── .vscode/                ← VS Code settings (for VS Code users)
│   └── mcp.json
├── venv/                   ← Virtual environment folder
│   └── bin/python
├── .env.example            ← Environment template (use this to create `.env` file)
├── .gitignore              
├── Dockerfile              ← Docker configuration (for Docker use)
├── .dockerignore           ← Docker ignore (for Docker use)
├── requirements.txt           
└── README.md

2. Create and edit a .env file for your credentials in the project directory

  1. Copy the example environment file in the project root by running this command:

    cp .env.example .env
    
  2. Replace the credentials (e.g. API keys) in the .env file:

    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
    TRDE_API_WSS = None
    DATA_API_URL = None
    STREAM_DATA_WSS = None
    

3. Start the MCP Server

Open a terminal in the project root directory and run the following command:

For local usage (default - stdio transport):

python alpaca_mcp_server.py

For remote usage (HTTP transport):

python alpaca_mcp_server.py --transport http

Available transport options:

  • --transport stdio (default): Standard input/output for local client connections
  • --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.

Server Config

{
  "mcpServers": {
    "alpaca": {
      "command": "<project_root>/venv/bin/python",
      "args": [
        "/path/to/alpaca-mcp-server/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"
      }
    }
  }
}
Project Info
Created At
9 months ago
Updated At
9 months ago
Author Name
alpacahq
Star
-
Language
-
License
-
Category
Tags

Recommend Servers

View All
Bring your real authenticated browser session to AI coding agents. Local-first MCP server + Chrome MV3 extension. No cloud. No telemetry.
@Cubenest

peek records the user's actual logged-in browser (DOM via rrweb, console events, network metadata, optional response bodies via opt-in Deep capture) through a Chrome MV3 extension. The extension ships events through a native-messaging stdio bridge to a local MCP server (peek-mcp), which persists them to a SQLite database at ~/.peek/sessions.db. AI coding agents (Claude Code, Cursor, Cline, Windsurf) read sessions from the database via 10 MCP tools: Tool What it does list_recent_sessions List recently recorded sessions (id, origin, ts, event count). get_session_summary LLM-readable narrative summary of a session. get_session_console_errors Console errors recorded in a session. get_session_network_errors Failed/notable network requests in a session. get_user_action_before_error Last N user actions before a console error. generate_playwright_repro Generate a runnable Playwright test from a session. get_dom_snapshot Reconstruct the DOM at a given timestamp. query_dom_history Timeline of attribute/text changes for a selector. request_authorization Side-panel consent for write actions (Level 3). execute_action Dispatch a UI action (gated by permission level + destructive blocklist). Why local-first matters Every other "browser session for AI" tool ships to a vendor cloud. peek's SQLite + extension live on the user's machine — no remote endpoints, no telemetry. The privacy policy (docs/peek/PRIVACY_POLICY.md) is the source of truth. Install # 1. Add the MCP server to Claude Code claude mcp add peek -- npx -y @peekdev/mcp # 2. Install the Chrome extension from the Chrome Web Store # (link added once the CWS listing is approved)

a day ago