Skip to main content
Glama
ariadng

metatrader-mcp-server

PyPI version Python 3.10+ License: MIT

AI 어시스턴트가 자연어를 사용하여 대신 거래하도록 하세요

MetaTrader MCP 서버


📑 목차


Related MCP server: mt5-mcp

🌟 이것은 무엇인가요?

MetaTrader MCP 서버는 AI 어시스턴트(Claude, ChatGPT 등)를 MetaTrader 5 트레이딩 플랫폼에 연결하는 브리지입니다. 버튼을 클릭하는 대신 AI 어시스턴트에게 다음과 같이 말하기만 하면 됩니다:

"내 계좌 잔액을 보여줘" "EUR/USD 0.01랏 매수해" "수익 중인 모든 포지션을 종료해"

AI가 요청을 이해하고 MetaTrader 5에서 자동으로 실행합니다.

작동 방식

You → AI Assistant → MCP Server → MetaTrader 5 → Your Trades

✨ 기능

  • 🗣️ 자연어 트레이딩 - 평범한 언어로 AI와 대화하여 거래 실행

  • 🤖 멀티 AI 지원 - Claude Desktop, ChatGPT(Open WebUI 경유) 등과 호환

  • 📊 전체 시장 접근 - 실시간 가격, 과거 데이터 및 심볼 정보 확인

  • 💼 완전한 계좌 제어 - 잔액, 증거금, 마진 및 거래 통계 확인

  • ⚡ 주문 관리 - 간단한 명령으로 주문 생성, 수정 및 종료

  • 🔒 보안 - 모든 자격 증명은 사용자 기기에 안전하게 보관

  • 🌐 유연한 인터페이스 - MCP 서버, REST API 또는 WebSocket 스트림으로 사용 가능

  • 📖 상세한 문서 - 포괄적인 가이드 및 예시 제공

🎯 누구를 위한 것인가요?

  • 트레이더 - AI를 사용하여 트레이딩을 자동화하려는 분

  • 개발자 - 트레이딩 봇이나 분석 도구를 구축하는 분

  • 분석가 - 시장 데이터에 빠르게 접근해야 하는 분

  • 누구나 - AI와 금융 시장을 결합하는 데 관심이 있는 분

⚠️ 중요 면책 조항

주의 깊게 읽어주세요:

금융 상품 거래는 상당한 손실 위험을 수반합니다. 이 소프트웨어는 '있는 그대로' 제공되며, 개발자는 이 소프트웨어 사용으로 인한 거래 손실, 이익 또는 결과에 대해 어떠한 책임도 지지 않습니다.

이 소프트웨어를 사용함으로써 귀하는 다음 사항을 인정합니다:

  • 금융 거래의 위험을 이해함

  • 이 시스템을 통해 실행된 모든 거래에 대한 책임은 본인에게 있음

  • 개발자에게 어떠한 결과에 대해서도 책임을 묻지 않음

  • 본인의 위험 부담 하에 이 소프트웨어를 사용함

이는 금융 조언이 아닙니다. 항상 책임감 있게 거래하십시오.


📋 사전 요구 사항

시작하기 전에 다음 사항이 준비되어 있는지 확인하세요:

  1. Python 3.10 이상 - 여기서 다운로드

  2. MetaTrader 5 터미널 - 여기서 다운로드

  3. MT5 트레이딩 계좌 - 데모 또는 실계좌 자격 증명

    • 로그인 번호

    • 비밀번호

    • 서버 이름 (예: "MetaQuotes-Demo")

🚀 빠른 시작

1단계: 패키지 설치

터미널이나 명령 프롬프트를 열고 다음을 실행하세요:

pip install metatrader-mcp-server

2단계: 알고리즘 트레이딩 활성화

  1. MetaTrader 5 실행

  2. 도구(Tools)옵션(Options)으로 이동

  3. Expert Advisors 탭 클릭

  4. 알고리즘 트레이딩 허용(Allow algorithmic trading) 체크박스 선택

  5. 확인(OK) 클릭

3단계: 인터페이스 선택

사용하려는 방식에 따라 하나를 선택하세요:

옵션 A: Claude Desktop과 함께 사용 (로컬 STDIO)

  1. Claude Desktop 설정 파일 찾기:

    • Windows: %APPDATA%\Claude\claude_desktop_config.json

    • Mac: ~/Library/Application Support/Claude/claude_desktop_config.json

  2. 파일을 열고 다음 설정을 추가하세요:

{
  "mcpServers": {
    "metatrader": {
      "command": "metatrader-mcp-server",
      "args": [
        "--login",     "YOUR_MT5_LOGIN",
        "--password",  "YOUR_MT5_PASSWORD",
        "--server",    "YOUR_MT5_SERVER",
        "--transport", "stdio"
      ]
    }
  }
}

선택 사항: 사용자 지정 MT5 터미널 경로 지정

MT5 터미널이 표준 경로가 아닌 곳에 설치된 경우 --path 인수를 추가하세요:

{
  "mcpServers": {
    "metatrader": {
      "command": "metatrader-mcp-server",
      "args": [
        "--login",     "YOUR_MT5_LOGIN",
        "--password",  "YOUR_MT5_PASSWORD",
        "--server",    "YOUR_MT5_SERVER",
        "--transport", "stdio",
        "--path",      "C:\\Program Files\\MetaTrader 5\\terminal64.exe"
      ]
    }
  }
}
  1. YOUR_MT5_LOGIN, YOUR_MT5_PASSWORD, YOUR_MT5_SERVER를 실제 자격 증명으로 교체하세요

  2. Claude Desktop 재시작

  3. 대화 시작! 다음을 시도해보세요: "내 계좌 잔액이 얼마야?"

옵션 B: Open WebUI와 함께 사용 (ChatGPT 및 기타 LLM용)

  1. HTTP 서버 시작:

metatrader-http-server --login YOUR_LOGIN --password YOUR_PASSWORD --server YOUR_SERVER --host 0.0.0.0 --port 8000

선택 사항: 사용자 지정 MT5 터미널 경로 지정

MT5 터미널이 표준 경로가 아닌 곳에 설치된 경우 --path 인수를 추가하세요:

metatrader-http-server --login YOUR_LOGIN --password YOUR_PASSWORD --server YOUR_SERVER --path "C:\Program Files\MetaTrader 5\terminal64.exe" --host 0.0.0.0 --port 8000
  1. 브라우저에서 http://localhost:8000/docs로 접속하여 API 문서 확인

  2. Open WebUI에서:

    • 설정(Settings)**도구(Tools)**로 이동

    • 도구 서버 추가(Add Tool Server) 클릭

    • http://localhost:8000 입력

    • 저장

  3. 이제 Open WebUI 채팅에서 트레이딩 도구를 사용할 수 있습니다!

옵션 C: WebSocket을 통한 실시간 시세

대시보드, 봇 또는 모니터링을 위해 WebSocket을 통해 실시간 틱 데이터(매수, 매도, 스프레드, 거래량)를 스트리밍하세요:

metatrader-quote-server --login YOUR_LOGIN --password YOUR_PASSWORD --server YOUR_SERVER

모든 WebSocket 클라이언트로 연결:

websocat ws://localhost:8765

connected 메시지를 받은 후 JSON 형식으로 지속적인 틱 업데이트를 받게 됩니다. 자세한 내용은 WebSocket 시세 서버를 참조하세요.

옵션 D: 원격 MCP 서버 (SSE)

Windows VPS(MT5가 설치된 곳)에서 MCP 서버를 실행하고 로컬 컴퓨터의 Claude Desktop이나 Claude Code에서 원격으로 연결하세요.

서버 측 (Windows VPS에서):

metatrader-mcp-server --login YOUR_LOGIN --password YOUR_PASSWORD --server YOUR_SERVER

기본적으로 0.0.0.0:8080에서 SSE 서버가 시작됩니다. --host--port로 사용자 지정 가능:

metatrader-mcp-server --login YOUR_LOGIN --password YOUR_PASSWORD --server YOUR_SERVER --host 127.0.0.1 --port 9000

클라이언트 측 (로컬 컴퓨터의 Claude Desktop 설정):

{
  "mcpServers": {
    "metatrader": {
      "url": "http://VPS_IP:8080/sse"
    }
  }
}

VPS_IP를 서버의 IP 주소로 교체하세요.

보안 경고: MCP 프로토콜에는 인증이 포함되어 있지 않습니다. 네트워크를 통해 SSE 서버를 노출할 때는 방화벽을 사용하여 IP별로 접근을 제한하거나, 인증이 포함된 리버스 프록시 뒤에 배치하거나, SSH 터널을 사용하세요.


🤖 트레이딩 어시스턴트 스킬 (Claude Code / Claude Desktop)

claude-skill/ 디렉토리에 사전 구축된 트레이딩 터미널 어시스턴트 스킬이 포함되어 있습니다. 이 스킬은 Claude에게 32개의 모든 트레이딩 도구, 출력 형식 및 MetaTrader 5 도메인 전문 지식에 대한 구조화된 정보를 제공합니다.

Claude Code용 설치

옵션 1: 심볼릭 링크 (권장)

표준 Claude Code 스킬 디렉토리에서 claude-skill/로 심볼릭 링크 생성:

cd metatrader-mcp-server
mkdir -p .claude
ln -s ../claude-skill .claude/skills

스킬이 자동으로 검색되어 /trading으로 사용할 수 있게 됩니다.

옵션 2: 복사

스킬 파일을 Claude Code 스킬 디렉토리로 복사:

cd metatrader-mcp-server
mkdir -p .claude/skills
cp -r claude-skill/trading .claude/skills/trading

Claude Desktop용 설치

Claude Desktop의 경우, 스킬을 전역 Claude 스킬 디렉토리로 복사하세요:

# macOS
mkdir -p ~/Library/Application\ Support/Claude/skills
cp -r claude-skill/trading ~/Library/Application\ Support/Claude/skills/trading

# Windows
mkdir "%APPDATA%\Claude\skills"
xcopy /E claude-skill\trading "%APPDATA%\Claude\skills\trading\"

스킬의 기능

  • 직접 실행: 요청 시 추가 확인 없이 즉시 거래 실행

  • 워크플로우: 복잡한 작업을 위해 도구를 연결하는 방법(예: 시장가 주문 후 SL/TP 설정)을 알고 있음

  • 형식 지정: 계좌 데이터, 포지션, 주문 및 가격을 깔끔한 터미널 스타일 표로 표시

  • 도메인 지식: MT5 주문 유형, 타임프레임, 심볼 형식 및 체결 모드 이해

사용법

설치 후 /trading을 호출하거나 자연스럽게 트레이딩 관련 질문을 하세요:

/trading
> Show me my account dashboard
> Buy 0.1 lots of EURUSD with SL at 1.0800
> Close all profitable positions
> Show me GBPUSD H4 candles

📡 WebSocket 시세 서버

WebSocket 시세 서버는 MetaTrader 5에서 실시간 틱 데이터를 모든 WebSocket 클라이언트로 스트리밍합니다. 라이브 대시보드, 알고리즘 트레이딩 프론트엔드 및 실시간 모니터링에 이상적입니다.

서버 시작

metatrader-quote-server --login YOUR_LOGIN --password YOUR_PASSWORD --server YOUR_SERVER

서버는 기본적으로 ws://0.0.0.0:8765에서 시작됩니다.

사용자 지정

metatrader-quote-server \
  --login YOUR_LOGIN \
  --password YOUR_PASSWORD \
  --server YOUR_SERVER \
  --host 127.0.0.1 \
  --port 9000 \
  --symbols "EURUSD,GBPUSD,XAUUSD" \
  --poll-interval 200

설정

플래그

환경 변수

기본값

설명

--host

QUOTE_HOST

0.0.0.0

바인딩할 호스트

--port

QUOTE_PORT

8765

바인딩할 포트

--symbols

QUOTE_SYMBOLS

XAUUSD,USOIL,GBPUSD,USDJPY,EURUSD,BTCUSD

스트리밍할 심볼 (쉼표로 구분)

--poll-interval

QUOTE_POLL_INTERVAL_MS

100

틱 폴링 간격 (밀리초)

CLI 플래그가 환경 변수보다 우선하며, 환경 변수는 기본값보다 우선합니다.

메시지 형식

연결 시 — 서버가 심볼 목록과 함께 connected 메시지를 보내고, 캐시된 틱을 전송합니다:

{"type": "connected", "symbols": ["XAUUSD", "EURUSD", "GBPUSD"], "poll_interval_ms": 100}

틱 업데이트 — 매수, 매도 또는 거래량이 변경될 때마다 전송:

{"type": "tick", "symbol": "XAUUSD", "bid": 2345.67, "ask": 2345.89, "spread": 0.22, "volume": 1234, "time": "2026-03-14T10:30:45+00:00"}

오류 — 심볼을 가져올 수 없는 경우 전송:

{"type": "error", "symbol": "INVALID", "message": "Symbol not found or data unavailable"}

예시: Python으로 연결

import asyncio
import json
from websockets.asyncio.client import connect

async def main():
    async with connect("ws://localhost:8765") as ws:
        async for message in ws:
            tick = json.loads(message)
            if tick["type"] == "tick":
                print(f"{tick['symbol']}: {tick['bid']}/{tick['ask']} (spread: {tick['spread']})")

asyncio.run(main())

설계 참고 사항

  • 변경 감지: 매수, 매도 또는 거래량이 실제로 변경될 때만 브로드캐스팅하여 불필요한 트래픽을 줄입니다.

  • 지연 참여자: 새로운 클라이언트는 연결 즉시 캐시된 틱을 받으므로 다음 변경까지 기다릴 필요가 없습니다.

  • MT5 스레드 안전성: 모든 MT5 SDK 호출은 동시 접근 문제를 방지하기 위해 단일 스레드 실행기를 통해 직렬화됩니다.

  • 다중 클라이언트: 여러 WebSocket 클라이언트가 동시에 연결할 수 있습니다.


💡 사용 예시

Claude Desktop 사용 시

설정 후 자연스럽게 대화할 수 있습니다:

계좌 확인:

사용자: "내 계좌 정보 보여줘"

Claude: 잔액, 증거금, 마진, 레버리지 등을 반환

시장 데이터 가져오기:

사용자: "EUR/USD 현재 가격이 얼마야?"

Claude: 매수, 매도 및 스프레드 표시

거래 실행:

사용자: "GBP/USD 0.01랏 매수해, 손절가는 1.2500, 익절가는 1.2700으로 설정"

Claude: 거래 실행 및 확인

포지션 관리:

사용자: "손실 중인 모든 포지션 종료해"

Claude: 포지션 종료 및 결과 보고

기록 분석:

사용자: "지난주 EUR/USD 거래 내역을 모두 보여줘"

Claude: 거래 내역을 표로 반환

HTTP API 사용 시

# Get account info
curl http://localhost:8000/api/v1/account/info

# Get current price
curl "http://localhost:8000/api/v1/market/price?symbol_name=EURUSD"

# Place a market order
curl -X POST http://localhost:8000/api/v1/order/market \
  -H "Content-Type: application/json" \
  -d '{
    "symbol": "EURUSD",
    "volume": 0.01,
    "type": "BUY",
    "stop_loss": 1.0990,
    "take_profit": 1.1010
  }'

# Get all open positions
curl http://localhost:8000/api/v1/positions

# Close a specific position
curl -X DELETE http://localhost:8000/api/v1/positions/12345

Python 라이브러리로 사용 시

from metatrader_client import MT5Client

# Connect to MT5
config = {
    "login": 12345678,
    "password": "your_password",
    "server": "MetaQuotes-Demo"
}
client = MT5Client(config)
client.connect()

# Get account statistics
stats = client.account.get_trade_statistics()
print(f"Balance: ${stats['balance']}")
print(f"Equity: ${stats['equity']}")

# Get current price
price = client.market.get_symbol_price("EURUSD")
print(f"EUR/USD Bid: {price['bid']}, Ask: {price['ask']}")

# Place a market order
result = client.order.place_market_order(
    type="BUY",
    symbol="EURUSD",
    volume=0.01,
    stop_loss=1.0990,
    take_profit=1.1010
)
print(result['message'])

# Close all positions
client.order.close_all_positions()

# Disconnect
client.disconnect()

📚 사용 가능한 작업

계좌 관리

  • get_account_info - 잔액, 증거금, 수익, 마진 레벨, 레버리지, 통화 정보 가져오기

시장 데이터

  • get_symbols - 사용 가능한 모든 거래 심볼 목록

  • get_symbol_price - 심볼의 현재 매수/매도 가격 가져오기

  • get_candles_latest - 최근 가격 캔들(OHLCV 데이터) 가져오기

  • get_candles_by_date - 날짜 범위에 따른 과거 캔들 가져오기

  • get_symbol_info - 상세 심볼 정보 가져오기

주문 실행

  • place_market_order - 즉시 매수/매도 주문 실행

  • place_pending_order - 향후 실행을 위한 지정가/역지정가 주문 배치

  • modify_position - 손절가 또는 익절가 업데이트

  • modify_pending_order - 대기 주문 매개변수 수정

포지션 관리

  • get_all_positions - 모든 오픈 포지션 보기

  • get_positions_by_symbol - 거래 쌍별로 포지션 필터링

  • get_positions_by_id - 특정 포지션 상세 정보 가져오기

  • close_position - 특정 포지션 종료

  • close_all_positions - 모든 오픈 포지션 종료

  • close_all_positions_by_symbol - 특정 심볼의 모든 포지션 종료

  • close_all_profitable_positions -

A
license - permissive license
Not graded
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity
Issues opened vs closed

Related MCP Servers

  • 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
    A
    quality
    A
    maintenance
    An MCP server that lets an AI agent read your MetaTrader 5 account and place trades over the Model Context Protocol, with a configurable human approval gate.
    15
    4
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol (MCP) server that provides AI assistants like Claude with direct access to MetaAPI trading platform. Trade forex, stocks, and commodities through natural language conversations.
    1
  • F
    license
    Not graded
    quality
    B
    maintenance
    Universal MCP server that enables AI assistants to control MetaTrader 5 directly, executing trades, managing data, and automating MT5 operations through natural language.
    2

View all related MCP servers

Related MCP Connectors

  • MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents

  • MCP server for Gainium — manage trading bots, deals, and balances via AI assistants

  • HiveCapital MCP Server — autonomous investment layer for AI agents

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/ariadng/metatrader-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server