Skip to main content
Glama
edkdev

MetaTrader5 MCP Server

by edkdev

MetaTrader5 MCP 서버

MetaTrader5(MT5) 플랫폼을 위한 거래 인터페이스를 제공하는 Model Context Protocol(MCP) 서버입니다.

기능

  • 계정 관리: 계정 정보, 잔고, 자산, 증거금 조회

  • 포지션 관리: 오픈 포지션 조회, 수정, 종료

  • 주문 작업: 시장가/지정가 주문, 주문 취소

  • 시장 데이터: 심볼 정보, 현재 가격(틱) 조회

  • 레이트/캔들: start_pos/count 또는 날짜 범위를 통한 OHLCV 데이터 가져오기

  • 지표: SMA, EMA, RSI, MACD, 볼린저 밴드, ATR, 스토캐스틱 계산

  • 번들 지표: 단일 호출로 여러 지표 동시 계산

  • 신호 도구: EMA 크로스오버 레짐 플래그 및 진입을 위한 컨플루언스 스코어링

Related MCP server: MetaTrader 5 MCP Server

설치

uv로 종속성 설치:

uv sync

설정

환경 변수는 이제 MCP 클라이언트 설정에서 직접 구성합니다(.env 파일 불필요).

Claude Desktop / Kiro

mcp.json 설정 파일에 추가:

{
  "mcpServers": {
    "mt5-trading": {
      "command": "uvx",
      "args": ["mt5-mcp"],
      "env": {
        "MT5_LOGIN": "your_account_number",
        "MT5_PASSWORD": "your_password",
        "MT5_SERVER": "your_broker_server",
        "MT5_PATH": "C:\\Program Files\\MetaTrader 5\\terminal64.exe",
        "MT5_TIMEOUT": "60000",
        "DEFAULT_DEVIATION": "20",
        "DEFAULT_MAGIC": "234000"
      }
    }
  }
}

필수 환경 변수:

  • MT5_LOGIN - 귀하의 MT5 계좌 번호

  • MT5_PASSWORD - 귀하의 MT5 계좌 비밀번호

  • MT5_SERVER - 귀하의 브로커 서버 이름

  • MT5_PATH - MT5 터미널 실행 파일 경로

선택적 환경 변수:

  • MT5_TIMEOUT - 연결 시간 제한(밀리초, 기본값: 60000)

  • DEFAULT_DEVIATION - 기본 가격 이탈(포인트, 기본값: 20)

  • DEFAULT_MAGIC - 주문의 기본 매직 넘버(기본값: 234000)

대안: 로컬 개발

로컬 개발의 경우 직접 실행할 수도 있습니다:

# Set environment variables and run
MT5_LOGIN=your_account MT5_PASSWORD=your_pass MT5_SERVER=your_server MT5_PATH="C:\Program Files\MetaTrader 5\terminal64.exe" uv run python mt5_mcp/server.py

또는 uv 디렉터리를 사용한 레거시 방법:

{
  "mcpServers": {
    "mt5-trading": {
      "command": "uv",
      "args": [
        "--directory",
        "D:\\path\\mt5-mcp",
        "run",
        "python",
        "mt5_mcp/server.py"
      ],
      "env": {
        "MT5_LOGIN": "your_account_number",
        "MT5_PASSWORD": "your_password",
        "MT5_SERVER": "your_broker_server",
        "MT5_PATH": "C:\\Program Files\\MetaTrader 5\\terminal64.exe"
      }
    }
  }
}

사용 가능한 도구

계정 정보

  • mt5_get_account_info - 계정 잔고, 자산, 증거금 등 조회

  • mt5_get_positions - 오픈 포지션 조회(전체 또는 심볼별 필터링)

  • mt5_get_orders - 대기 주문 조회

주문 작업

  • mt5_place_order - 시장가 또는 지정가 주문

    • 지원: buy, sell, buy_limit, sell_limit, buy_stop, sell_stop

    • 선택적 SL/TP

  • mt5_close_position - 티켓 번호로 오픈 포지션 종료

  • mt5_cancel_order - 대기 주문 취소

  • mt5_modify_position - 오픈 포지션의 SL/TP 수정

시장 데이터

  • mt5_get_symbol_info - 계약 사양 조회

  • mt5_get_tick - 현재 매수/매도 가격 조회

레이트 / 캔들

  • mt5_get_rates_from_pos - 위치(0=현재 봉)에서 시작하여 start_pos와 count로 OHLCV 조회

  • mt5_get_rates_range - ISO 날짜 범위 date_from → date_to 내 OHLCV 조회

지표

모든 지표 도구는 직접 데이터(closes/candles)를 사용하거나 symbol + timeframe과 date_from/date_to 또는 start_pos/count를 통해 자동으로 데이터를 가져올 수 있습니다. return_last_only=true로 설정하면 최신 값만 반환합니다.

  • mt5_calc_sma - 단순 이동 평균

    • 매개변수: period (기본값 20)

  • mt5_calc_ema - 지수 이동 평균

    • 매개변수: period (기본값 20)

  • mt5_calc_rsi - 상대 강도 지수

    • 매개변수: period (기본값 14)

  • mt5_calc_macd - MACD 선, 신호선, 히스토그램

    • 매개변수: fast (12), slow (26), signal (9)

  • mt5_calc_bbands - 볼린저 밴드(상단/중간/하단)

    • 매개변수: period (20), stddev (2.0)

  • mt5_calc_atr - 평균 실제 범위(캔들 필요)

    • 매개변수: period (14)

  • mt5_calc_stochastic - 스토캐스틱 오실레이터 %K/%D(캔들 필요)

    • 매개변수: k_period (14), d_period (3), smooth_k (1)

번들 지표

  • mt5_calc_bundle - 동일하게 가져온 캔들을 사용하여 단일 호출로 여러 지표 계산

    • 인수:

      • indicators: ["sma","ema","rsi","macd","bbands","atr","stochastic"] 중 이름 배열

      • 선택적 params 객체로 지표별 재정의(예: { "sma": {"period": 50}, "bbands": {"stddev": 2.5} })

      • symbol/timeframe과 범위/개수 또는 직접 candles/closes 지원

      • return_last_only: true이면 최신 값만 반환

신호 도구

  • mt5_signal_crossover - EMA 크로스오버 및 레짐 플래그

    • 매개변수: fast (기본값 50), slow (200), lookback_bars (200)

    • 반환 값: state (above/below/equal), crosssed_up, crossed_down, age_bars, slope_fast, slope_slow, spread, spread_pct, price_above_both, price_below_both, price

  • mt5_signal_confuence - 진입을 위한 컨플루엔스 스코어링

    • 지 기본 매개변수: ema_fast (50), ema_slow (200), ema_near (20), rsi_period (14), macd_fast (12), macd_slow (26), macd_signal (9), bb_period (20), bb_stddev (2.0), atr_period (14)

    • 임계값: near_k_atr (0.5), atr_expansion_ratio (1.0), score_threshold (3)

    • 제어: direction (auto|long|short), 선택적 weights (트렌드/모멘텀/변동성/위치/트리거)

    • 반환: 롱/숏의 구성 플래그와 점수, 제안된 방향

사용 예시

# In Claude Desktop, you can now ask:

"What's my MT5 account balance?"
"Show me my open positions on EURUSD"
"Place a buy order for 0.1 lot EURUSD at market"
"Close position with ticket 12345"
"Get current price for XAUUSD"

# Indicators (auto-fetch candles)
"Compute RSI(14) on EURUSD H1 using the last 300 bars (latest value only)"
"Compute MACD and Bollinger Bands on EURUSD H4 for September"

# Bundle
"Compute RSI+MACD+BBands (latest values) on EURUSD H1 using last 300 bars"

# Signals
"Give me EMA(50/200) crossover regime info on EURUSD H1"
"Compute confluence score on EURUSD H1 (defaults) and tell me if entry is ready"

시스템 요구 사항

  • Windows OS (MT5는 Windows에서만 실행 가능)

  • MetaTrader5 미널 설치 및 실행 중

  • Python >=3.11

  • 활성 MT5 거래 계좌

아키텍처

mt5-mcp/
├── mt5_mcp/
│   ├── __init__.py          # Package init
│   ├── server.py            # MCP server with tool definitions
│   ├── mt5_service.py       # MT5 SDK wrapper
│   └── indicators.py        # Pure-Python technical indicators
├── pyproject.toml           # Project dependencies (uv)
├── .env.example             # Environment template
└── README.md

개발

개발 모드로 실콴:

uv run python mt5_mcp/server.py

라이선스

MIT

참고 사항

  • 소프트웨어는 현상태 그대로 제공되며, 소프트웨어 작자는 거래로 인한 어떤 손실에도 책임을 지지 않습니다. 외환 거래는 매우 변동성이 크고 위험하므로 극히 조심히 진행하시기 바랍니다.

  • 이 MCP를 사용할 때는 MT5 터미널이 실행 중이어야 합니다.

  • 귀하 계좌에 거래 권한이 활성화되어 있는지 확하시기 바랍니다.

  • 실전 사용 전에 반드시 모의 계좌에서 먼저 테스트하시기 바랍니다.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables access to MetaTrader5 market data and trading functionality, including real-time quotes, historical OHLCV data, tick data, symbol information, and technical indicators for forex and other trading instruments.
    22
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables AI assistants to connect to MetaTrader 5 for trading, market data access, and account management through the Model Context Protocol.
    90 PyPI
    231
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI applications to interact with MetaTrader 5 terminals via WebSocket MCP protocol for trading operations and account management.
    4
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables interaction with MetaTrader 5 for market data, technical analysis, Fibonacci calculations, and trading via MCP clients such as Claude.
    MIT