alpaka-mcp
이것은 무엇인가요?
alpaka-mcp는 AI 어시스턴트(Claude Desktop, Cursor, VS Code Copilot)와 터미널을 Alpaca Trading API에 직접 연결하는 프로덕션 준비 완료 MCP 서버 + CLI입니다. 자연어로 — 또는 명령줄에서 — 주식, ETF, 암호화폐를 거래하세요.
alpaca-py와 MCP Python SDK 기반입니다.
기본적으로 페이퍼 트레이딩 — 실제 시장 데이터, 모의 자금, 실제 돈은 전혀 위험하지 않습니다.
Related MCP server: FinClaw
빠른 시작
1. Alpaca API 키 받기 (무료)
**alpaca.markets**에서 가입 → Paper Trading → API Keys
2. 설치
git clone https://github.com/vikrambtech2025-png/alpaka-mcp.git
cd alpaka-mcp
uv sync3. 구성
cp .env.example .env
# Add your API keys to .env4. 실행
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 InspectorAI 어시스턴트에 연결
%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"
}
}
}
}프로젝트 루트의 .cursor/mcp.json에 추가:
{
"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"
}
}
}
}.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 도구 (16)
도구 | 설명 |
| 잔고, 순자산, 매수 여력, 데이 트레이드 |
| 손익이 포함된 모든 미결제 포지션 |
도구 | 설명 |
| 매수 주문 (시장가/지정가/스톱/스톱리밋) |
| 매도 주문 (시장가/지정가) |
| 상태와 심볼별 주문 목록 |
| 특정 주문 취소 |
| 모든 미체결 주문 취소 |
도구 | 설명 |
| 단일 포지션 세부 정보 |
| 청산 (전체 또는 부분) |
도구 | 설명 |
| 최신 매수/매도 호가 |
| 과거 OHLCV 봉 |
| 전체 스냅샷 (체결, 호가, 일봉, 1분봉) |
도구 | 설명 |
| 최신 암호화폐 매수/매도 호가 |
| 과거 암호화폐 OHLCV 봉 |
도구 | 설명 |
| 이름 또는 심볼로 주식/ETF/암호화폐 검색 |
| 시장 개장/마감 상태 |
CLI 명령어 (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 assets모든 명령어는 기계 판독 가능한 출력을 위한 --json을 지원합니다:
$ 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"
}프로덕션 기능
기능 | 작동 방식 |
탄력적 클라이언트 | 투명 프록시가 모든 API 호출을 속도 제한 + 재시도로 래핑 |
속도 제한 | 3개의 독립적인 토큰 버킷 (각각 분당 200회) — 거래, 주식 데이터, 암호화폐 |
재시도 + 백오프 | 429, 500, 연결 오류 시 1초/2초/4초 지수 백오프로 3회 시도 |
비차단 비동기 | MCP 도구는 |
구조화된 로깅 | JSON 감사 추적: |
입력 검증 | API 호출 전 심볼, 수량, 가격, 주문 유형 검증 |
실거래 가드 | 실제 자금 거래에는 |
구성 검증 | 명확한 설정 안내와 함께 플레이스홀더 API 키 거부 |
스레드 안전성 |
|
CLI 오류 처리 | 모든 명령어 래핑 — 깔끔한 오류, 역추적 없음 |
아키텍처
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 portfolio로그는 Docker 볼륨의 /app/logs에 저장됩니다.
환경 변수
변수 | 기본값 | 설명 |
| (필수) | Alpaca API 키 |
| (필수) | Alpaca 시크릿 키 |
|
| 페이퍼 트레이딩 모드 |
|
| 실거래에는 |
|
| 로그 파일 디렉터리 |
|
| 로깅 상세 수준 |
테스트
# 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 -v안전
기본적으로 페이퍼 트레이딩 — 실제 자금은 명시적 동의 필요
실거래에는
ALPACA_PAPER=false와ALPACA_LIVE_CONFIRM=true가 모두 필요합니다실거래 시작 시 5초 카운트다운
모든 오류는 깔끔하게 포맷 — LLM에 역추적이 전송되지 않음
속도 제한으로 우발적인 API 남용 방지
모든 거래에 대한 구조화된 감사 추적
라이선스
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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.4542ISC
- AlicenseNot gradedqualityDmaintenanceMCP server that provides AI agents with financial tools including real-time quotes, backtesting, technical analysis, and multi-exchange data via a simple CLI interface.1MIT
- 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
- AlicenseAqualityAmaintenanceThis 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.3765Apache 2.0
Related MCP Connectors
MCP server for Gainium — manage trading bots, deals, and balances via AI assistants
MCP server exposing the Backtest360 engine API as tools for AI agents.
Alpaca MCP — real-time US stock market data via the Alpaca Market Data API
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/vikrambtech2025-png/alpaka-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server