alpaka-mcp
Was ist das?
alpaka-mcp ist ein produktionsreifer MCP-Server + CLI, der KI-Assistenten (Claude Desktop, Cursor, VS Code Copilot) und Ihr Terminal direkt mit der Alpaca Trading API verbindet. Handeln Sie Aktien, ETFs und Krypto mit natürlicher Sprache – oder über die Befehlszeile.
Basiert auf alpaca-py und dem MCP Python SDK.
Standardmäßig Paper-Trading – echte Marktdaten, simulierte Gelder, kein echtes Geld auf dem Spiel.
Related MCP server: alpaca-mcp-server
Schnellstart
1. Alpaca-API-Schlüssel erhalten (kostenlos)
Registrieren Sie sich bei alpaca.markets → Paper Trading → API Keys
2. Installieren
git clone https://github.com/vikrambtech2025-png/alpaka-mcp.git
cd alpaka-mcp
uv sync3. Konfigurieren
cp .env.example .env
# Add your API keys to .env4. Ausführen
uv run alpaka-mcp # MCP server (stdio for Claude/Cursor)
uv run alpaka account # CLI — check account
uv run mcp dev src/alpaka_mcp/server.py # MCP InspectorVerbindung zu KI-Assistenten
Hinzufügen zu %AppData%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"alpaka": {
"command": "uv",
"args": ["--directory", "C:\\path\\to\\alpaka-mcp", "run", "alpaka-mcp"],
"env": {
"ALPACA_API_KEY": "your_key",
"ALPACA_SECRET_KEY": "your_secret",
"ALPACA_PAPER": "true"
}
}
}
}Hinzufügen zu .cursor/mcp.json im Projektstamm:
{
"mcpServers": {
"alpaka": {
"command": "uv",
"args": ["--directory", "/path/to/alpaka-mcp", "run", "alpaka-mcp"],
"env": {
"ALPACA_API_KEY": "your_key",
"ALPACA_SECRET_KEY": "your_secret",
"ALPACA_PAPER": "true"
}
}
}
}Hinzufügen zu .vscode/mcp.json:
{
"servers": {
"alpaka": {
"command": "uv",
"args": ["--directory", "/path/to/alpaka-mcp", "run", "alpaka-mcp"],
"env": {
"ALPACA_API_KEY": "your_key",
"ALPACA_SECRET_KEY": "your_secret",
"ALPACA_PAPER": "true"
}
}
}
}MCP-Tools (16)
Tool | Beschreibung |
| Saldo, Eigenkapital, Kaufkraft, Day-Trades |
| Alle offenen Positionen mit Gewinn/Verlust |
Tool | Beschreibung |
| Kaufauftrag platzieren (Market/Limit/Stop/Stop-Limit) |
| Verkaufsauftrag platzieren (Market/Limit) |
| Aufträge nach Status und Symbolen auflisten |
| Einen bestimmten Auftrag stornieren |
| Alle offenen Aufträge stornieren |
Tool | Beschreibung |
| Details einer einzelnen Position |
| Liquidieren (vollständig oder teilweise) |
Tool | Beschreibung |
| Aktueller Geld-/Briefkurs |
| Historische OHLCV-Balken |
| Vollständiger Schnappschuss (Handel, Kurs, täglich, 1-Minute) |
Tool | Beschreibung |
| Aktueller Krypto-Geld-/Briefkurs |
| Historische Krypto-OHLCV-Balken |
Tool | Beschreibung |
| Aktien/ETFs/Krypto nach Name oder Symbol suchen |
| Status der Marktöffnung/-schließung |
CLI-Befehle (12)
alpaka account # Account balance & buying power
alpaka portfolio # Open positions with color-coded P&L
alpaka quote AAPL # Bid/ask quote (stocks or crypto)
alpaka buy AAPL --qty 10 # Buy 10 shares
alpaka buy BTC/USD -n 500 # Buy $500 of Bitcoin
alpaka sell AAPL --qty 5 # Sell 5 shares
alpaka orders # List open orders
alpaka orders --status closed # List filled orders
alpaka cancel <order-id> # Cancel specific order
alpaka cancel-all # Cancel everything open
alpaka bars AAPL --tf 1Day # Historical bars
alpaka clock # Is the market open?
alpaka search apple # Find tradeable assetsAlle Befehle unterstützen --json für maschinenlesbare Ausgabe:
$ uv run alpaka account --json
{
"status": "ACTIVE",
"equity": "100000.00",
"buying_power": "200000.00",
"cash": "100000.00",
"portfolio_value": "100000.00",
"daytrade_count": 0,
"pattern_day_trader": false,
"mode": "paper"
}Produktionsfunktionen
Funktion | Funktionsweise |
Robuster Client | Transparenter Proxy umhüllt jeden API-Aufruf mit Ratenbegrenzung + Wiederholung |
Ratenbegrenzung | 3 unabhängige Token-Buckets (je 200 Anfragen/Minute) – Handel, Aktiendaten, Krypto |
Wiederholung + Backoff | 3 Versuche mit exponentiellem Backoff von 1s/2s/4s bei 429, 500, Verbindungsfehlern |
Nicht blockierendes Async | MCP-Tools verwenden |
Strukturierte Protokollierung | JSON-Prüfpfad: |
Eingabevalidierung | Symbole, Mengen, Preise, Auftragstypen werden vor API-Aufrufen validiert |
Live-Handels-Schutz | Erfordert |
Konfigurationsvalidierung | Lehnt Platzhalter-API-Schlüssel mit klaren Einrichtungsanweisungen ab |
Thread-Sicherheit |
|
CLI-Fehlerbehandlung | Jeder Befehl umhüllt – saubere Fehler, keine Tracebacks |
Architektur
src/alpaka_mcp/
├── server.py # MCP server entry point (stdio)
├── cli.py # 12 Typer commands + JSON output
├── config.py # pydantic-settings + credential validation
├── clients.py # ResilientClient proxy (rate limit + retry + async)
├── utils.py # Response formatting
├── logging.py # Structured JSON logging
├── rate_limiter.py # Token bucket rate limiters (sync + async)
├── retry.py # Exponential backoff (sync + async)
├── validation.py # Input validation
└── tools/ # 16 MCP tools
├── account.py # get_account, get_portfolio
├── trading.py # buy, sell, get_orders, cancel_order, cancel_all
├── positions.py # get_position, close_position
├── stock_data.py # get_stock_quote, get_stock_bars, get_stock_snapshot
├── crypto_data.py # get_crypto_quote, get_crypto_bars
└── discovery.py # search_assets, get_market_clockDocker
# MCP server
docker compose up alpaka-mcp
# CLI via docker
docker compose run --rm alpaka-cli account
docker compose run --rm alpaka-cli portfolioProtokolle werden in einem Docker-Volume unter /app/logs gespeichert.
Umgebungsvariablen
Variable | Standard | Beschreibung |
| (erforderlich) | Ihr Alpaca-API-Schlüssel |
| (erforderlich) | Ihr Alpaca-Geheimschlüssel |
|
| Paper-Trading-Modus |
|
| Muss für Live-Handel |
|
| Protokolldatei-Verzeichnis |
|
| Protokollierungsgrad |
Testen
# Unit tests (no API keys needed)
uv run pytest tests/ --ignore=tests/test_integration.py -v
# Integration tests (needs real paper API keys)
ALPACA_API_KEY=pk_xxx ALPACA_SECRET_KEY=sk_xxx uv run pytest tests/test_integration.py -vSicherheit
Paper-Trading standardmäßig – echtes Geld erfordert ausdrückliche Zustimmung
Live-Handel erfordert sowohl
ALPACA_PAPER=falseals auchALPACA_LIVE_CONFIRM=true5-Sekunden-Countdown beim Start des Live-Handels
Alle Fehler sauber formatiert – keine Tracebacks an LLMs gesendet
Ratenbegrenzung verhindert versehentlichen API-Missbrauch
Strukturierter Prüfpfad für jeden Handel
Lizenz
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
MCP server for Gainium — manage trading bots, deals, and balances via AI assistants
MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents
Trade Papertrade BTC and ETH perps from Claude, ChatGPT, Codex, Cursor and any MCP client.
Related MCP Servers
- AlicenseDqualityDmaintenanceMCP server that exposes Alpaca Market Data & Broker API as tools, enabling access to financial data like stock bars, assets, market days, and news through the Message Control Protocol.42ISC

alpaca-mcp-serverofficial
AlicenseBqualityBmaintenanceAlpaca’s official MCP Server lets you trade stocks, ETFs, crypto, and options, run data analysis, and build strategies in plain English directly from your favorite LLM tools and IDEs7212,182 PyPI1,104MIT- AlicenseNot gradedqualityDmaintenanceAn MCP server implementation for Alpaca's Trading API that enables LLMs to interact with Alpaca's trading infrastructure using natural language, supporting stock, options, and crypto trading, portfolio management, watchlists, and market data.4MIT
- AlicenseAqualityBmaintenanceThis MCP server connects AI assistants to a Public.com brokerage account, enabling natural language trading of stocks, options, and crypto, along with portfolio management, quotes, and orders.46914 PyPI67Apache 2.0