Alpaca MCP Server — Bot de Trading Crypto
dtony47/alpaca-mcp-server
Trading crypto multi-leg com gates de risco e routines LLM via Claude
Ver no GitHubMCP server com 22 ferramentas para trading de criptomoedas em múltiplas pernas (CEX via Alpaca e DEX via Solana). Oferece análise de dados de mercado, execução de operações em papel/live com gates de risco, estratégias híbridas (SMA/RSI/sentiment) e integração nativa com Claude para rotinas LLM automáticas.
Instalação
npx convez-ai dtony47/alpaca-mcp-server1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.
Métricas
Casos de uso
- Automação de trading de criptomoedas com análise técnica e sentiment
- Monitoramento de mercado e execução de ordens via Claude em tempo real
- Backtest e paper trading de estratégias híbridas (CEX + DEX + on-chain)
Veredito

Projeto ambicioso em fase inicial (Plan 2/6) com core sólido e CI configurado, mas ainda com legs críticas (memecoin/always-on) pendentes. Recomendado apenas para desenvolvedores confortáveis com crypto, Python e risco — não para production com real money ainda.
README
A tradução para o português deste README ainda está na fila.
Crypto Trading Bot
Multi-leg crypto trading bot:
- Majors leg — BTC/ETH/SOL/DOGE/AVAX/LINK/UNI on Alpaca (CEX, paper or live).
- Memecoin leg — Solana on-chain via Jupiter aggregator.
Architecture: hybrid scheduled + always-on monitor. Memory in git. Risk gates enforced before every order.
Spec:
docs/superpowers/specs/2026-05-03-crypto-trading-bot-design.mdFoundation plan:docs/superpowers/plans/2026-05-03-foundation.md
Status (foundation, Plan 1)
- ✅
core/library: types, sizing, risk gates, kill switch, notifications, audit - ✅ Memory model (
memory/*.md) - ✅ CLAUDE.md agent rulebook
- ✅ CI (ruff + mypy + pytest with coverage gates)
- ⏳ Plan 2: Majors leg on Alpaca paper
- ⏳ Plan 3: Memecoin leg on Solana
- ⏳ Plan 4: Always-on monitor on Fly.io
- ⏳ Plan 5: LLM routines (Claude Code cloud)
- ⏳ Plan 6: Phase 1 ops + go-live gate
Status (majors leg, Plan 2)
- ✅ Alpaca CEX paper-trading leg shipped: scanner, executor, EOD, trail manager
- ✅ Universe: BTC/USD, ETH/USD, SOL/USD, DOGE/USD, AVAX/USD, LINK/USD, UNI/USD
- ✅ Hourly scanner + daily EOD via GitHub Actions
- ✅ Daily LLM routines wired (
routines/) - 🟡 Phase:
paper. No real money. - 🟡 Plan 3 (memecoin leg) and Plan 4 (always-on monitor + live rollout) pending.
Run locally
# scan once
python -m majors.scanner
# write today's EOD
python -m majors.eod
Required GitHub Secrets
Set these in repo Settings → Secrets and variables → Actions:
ALPACA_API_KEY,ALPACA_SECRET_KEYTELEGRAM_BOT_TOKEN,TELEGRAM_CHAT_ID- Plan 3:
HELIUS_API_KEY,BIRDEYE_API_KEY,GOPLUS_API_KEY
Quickstart (development)
cd Alpaca
cp env.template .env # then fill in
pip install -e ".[dev]"
pytest
See CLAUDE.md for the full agent rulebook.
Existing toolkit (preserved, integrated in Plan 2/3)
Alpaca Trading Toolkit
Python toolkit for paper trading with Alpaca, enriched with Polygon market data, news sentiment, and DEX/Web3 token analysis.
This repository supports two main workflows:
- CLI commands for account views, analysis, and paper orders
- MCP server tools so an LLM can call market/trading functions in chat
Features
- Alpaca paper account dashboard (account, positions, orders, risk)
- Real-time stock/crypto quotes and historical bars
- Polygon snapshot, options flow, large-trade, and ticker detail utilities
- Combined stock/crypto strategy:
- SMA crossover trend scoring
- RSI filter
- Headline sentiment
- Options flow weighting (stocks)
- DEX strategy for Web3 tokens using DexScreener + CoinGecko
- Trade execution helpers with risk sizing and dry-run support
Project Structure
main.py- CLI entrypointmcp_server.py- MCP server exposing project tools over stdiostrategy.py- Combined MA/RSI/sentiment/options signal logicdex_strategy.py- DEX token scoring logictrader.py- Buy/sell/close order helpersrisk.py- Position sizing and risk reportaccount.py- Account, positions, and order display helpersmarket_data.py- Alpaca stock/crypto quote and bar retrievalpolygon_data.py- Polygon market/news/options integrationssentiment.py- Keyword-based news sentiment scoringdex_data.py- DexScreener/CoinGecko data adaptersconfig.py- Env loading and risk constants
Requirements
- Python 3.10+ recommended
- Alpaca paper trading credentials
- Polygon API key for Polygon-powered endpoints
Install dependencies:
pip install -r requirements.txt
Configuration
Create a .env file in the project root:
ALPACA_API_KEY=your_key
ALPACA_API_SECRET=your_secret
ALPACA_BASE_URL=https://paper-api.alpaca.markets
POLYGON_API_KEY=your_polygon_key
# LLM-driven execution controls (used by MCP execution tools)
LLM_TRADING_ENABLED=false
LLM_TRADING_MODE=paper
LLM_ALLOWED_ASSET_CLASSES=crypto
LLM_ALLOWED_SYMBOLS=BTC/USD,ETH/USD
LLM_MAX_NOTIONAL_USD=500
LLM_MAX_TRADES_PER_DAY=10
LLM_MIN_SECONDS_BETWEEN_TRADES=30
LLM_REQUIRE_LIVE_TOKEN=true
LLM_LIVE_TOKEN=choose_a_long_random_string
Notes:
- The code is configured for paper trading.
config.pyassertspaper-apiis inALPACA_BASE_URL. - Keep secrets out of source control.
CLI Usage
Run the default dashboard:
python main.py
Common commands:
python main.py account
python main.py positions
python main.py orders
python main.py risk
python main.py quote AAPL
python main.py quote BTC/USD
python main.py snapshot AAPL
python main.py sentiment AAPL
python main.py flow AAPL
python main.py analyze AAPL
python main.py scan AAPL MSFT BTC/USD
python main.py trade AAPL
python main.py trade AAPL --live
python main.py buy AAPL 500
python main.py sell AAPL 500
python main.py close AAPL
python main.py closeall
python main.py dex PEPE
Execution behavior:
tradedefaults to dry-run unless--liveis providedcloseallprompts for confirmation
MCP Server Usage
Start server:
python3 mcp_server.py
Example MCP config snippet:
{
"mcpServers": {
"alpaca-market": {
"command": "python3",
"args": ["/absolute/path/to/Alpaca/mcp_server.py"]
}
}
}
Exposed MCP tools include:
get_quoteget_snapshotget_sentimentget_options_flowget_large_tradesget_ticker_detailsget_accountget_positionsrun_strategyscan_watchlistsearch_dex_tokenget_dex_tokenrun_dex_strategyget_execution_policyplace_orderclose_positionclose_all_positionsdecide_and_tradebacktest_strategylist_strategy_templatesdescribe_strategy_templaterun_strategy_template
Strategy Overview
Combined stock/crypto signal (strategy.py)
Composite score is built from:
- MA crossover/trend score
- RSI regime score
- News sentiment score
- Options flow score (stocks only)
Decision thresholds:
- BUY if score >=
1.5 - SELL if score <=
-1.5 - HOLD otherwise
DEX signal (dex_strategy.py)
DEX scoring combines:
- 24h and 1h momentum
- Buy vs sell pressure
- Volume/liquidity activity ratio
- Liquidity health
- CoinGecko community sentiment
It also emits risk flags (for example low liquidity, heavy selling, pump/crash conditions).
Risk Controls
Risk parameters are defined in config.py:
MAX_POSITION_PCTMAX_TRADE_USDSTOP_LOSS_PCT
Position sizing is calculated in risk.py and used by order helpers in trader.py.
Known Gaps
- No formal test suite is included yet
- No CI/CD pipeline is configured
- No container/deployment manifests are included
Disclaimer
This project is for educational and tooling purposes. Market data and strategy outputs are not financial advice. Use only with paper trading unless you fully understand and accept the risks.