Skip to main content
Glama

이것은 무엇인가요?

alpaka-mcp는 AI 어시스턴트(Claude Desktop, Cursor, VS Code Copilot)와 터미널을 Alpaca Trading API에 직접 연결하는 프로덕션 준비 완료 MCP 서버 + CLI입니다. 자연어로 — 또는 명령줄에서 — 주식, ETF, 암호화폐를 거래하세요.

alpaca-pyMCP 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 sync

3. 구성

cp .env.example .env
# Add your API keys to .env

4. 실행

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 Inspector

AI 어시스턴트에 연결

%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)

도구

설명

get_account

잔고, 순자산, 매수 여력, 데이 트레이드

get_portfolio

손익이 포함된 모든 미결제 포지션

도구

설명

buy

매수 주문 (시장가/지정가/스톱/스톱리밋)

sell

매도 주문 (시장가/지정가)

get_orders

상태와 심볼별 주문 목록

cancel_order

특정 주문 취소

cancel_all_orders

모든 미체결 주문 취소

도구

설명

get_position

단일 포지션 세부 정보

close_position

청산 (전체 또는 부분)

도구

설명

get_stock_quote

최신 매수/매도 호가

get_stock_bars

과거 OHLCV 봉

get_stock_snapshot

전체 스냅샷 (체결, 호가, 일봉, 1분봉)

도구

설명

get_crypto_quote

최신 암호화폐 매수/매도 호가

get_crypto_bars

과거 암호화폐 OHLCV 봉

도구

설명

search_assets

이름 또는 심볼로 주식/ETF/암호화폐 검색

get_market_clock

시장 개장/마감 상태


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 도구는 asyncio.to_thread()를 사용 — 이벤트 루프가 절대 차단되지 않음

구조화된 로깅

JSON 감사 추적: logs/trades.jsonl + logs/errors.jsonl

입력 검증

API 호출 전 심볼, 수량, 가격, 주문 유형 검증

실거래 가드

실제 자금 거래에는 ALPACA_LIVE_CONFIRM=true + 5초 카운트다운 필요

구성 검증

명확한 설정 안내와 함께 플레이스홀더 API 키 거부

스레드 안전성

lru_cache 클라이언트 초기화, 변경 가능한 전역 상태 없음

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_clock

Docker

# 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_KEY

(필수)

Alpaca API 키

ALPACA_SECRET_KEY

(필수)

Alpaca 시크릿 키

ALPACA_PAPER

true

페이퍼 트레이딩 모드

ALPACA_LIVE_CONFIRM

false

실거래에는 true여야 합니다

ALPACA_LOG_DIR

logs

로그 파일 디렉터리

ALPACA_LOG_LEVEL

INFO

로깅 상세 수준


테스트

# 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=falseALPACA_LIVE_CONFIRM=true가 모두 필요합니다

  • 실거래 시작 시 5초 카운트다운

  • 모든 오류는 깔끔하게 포맷 — LLM에 역추적이 전송되지 않음

  • 속도 제한으로 우발적인 API 남용 방지

  • 모든 거래에 대한 구조화된 감사 추적


라이선스

MIT


F
license - not found
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

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

  • A
    license
    D
    quality
    D
    maintenance
    MCP 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.
    4
    54
    2
    ISC
  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP server that provides AI agents with financial tools including real-time quotes, backtesting, technical analysis, and multi-exchange data via a simple CLI interface.
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    An 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.
    4
    MIT
  • A
    license
    A
    quality
    A
    maintenance
    This 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.
    37
    65
    Apache 2.0

View all related MCP servers

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

View all MCP Connectors

Latest Blog Posts

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