Skip to main content

Secure, auditable MCP server foundation for MetaTrader 5

Project description

yugen-mt5-mcp

Secure, auditable MCP server for MetaTrader 5 — gives AI clients controlled access to market data, account state, and trade execution through a hardened gate with symbol allowlists, volume limits, and an append-only audit trail.

Quick Start (for users)

Prerequisites

  • Windows with MetaTrader 5 installed and logged into a demo account
  • uv installed

Run without installing

uvx yugen-mt5-mcp

Install persistently

uv tool install yugen-mt5-mcp
yugen-mt5-mcp

Validate your setup

yugen-mt5-mcp doctor

This runs all readiness checks (config, MT5 connection, audit path, transport) without starting the server.


Client Configuration

Claude Desktop

Add the following to your Claude Desktop config file.

  • Windows: C:\Users\YOUR_USERNAME\AppData\Roaming\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "yugen-mt5": {
      "command": "uvx",
      "args": ["yugen-mt5-mcp"],
      "env": {
        "YUGEN_MT5_ALLOWED_SYMBOLS": "EURUSD,XAUUSD",
        "YUGEN_MT5_ALLOW_LIVE_TRADING": "false",
        "YUGEN_MT5_ALLOW_REAL_ACCOUNTS": "false",
        "YUGEN_MT5_MAX_ORDER_VOLUME": "1.0",
        "YUGEN_MT5_MAX_SYMBOL_EXPOSURE": "1.0",
        "YUGEN_MT5_AUDIT_PATH": "C:\\Users\\YOUR_USERNAME\\AppData\\Local\\Yugen\\mt5-mcp\\audit.sqlite3"
      }
    }
  }
}

You can also generate this block automatically:

yugen-mt5-mcp config claude

Cursor

Add the following to ~/.cursor/mcp.json:

{
  "mcpServers": {
    "yugen-mt5": {
      "command": "uvx",
      "args": ["yugen-mt5-mcp"],
      "env": {
        "YUGEN_MT5_ALLOWED_SYMBOLS": "EURUSD,XAUUSD",
        "YUGEN_MT5_ALLOW_LIVE_TRADING": "false",
        "YUGEN_MT5_ALLOW_REAL_ACCOUNTS": "false",
        "YUGEN_MT5_MAX_ORDER_VOLUME": "1.0",
        "YUGEN_MT5_MAX_SYMBOL_EXPOSURE": "1.0"
      }
    }
  }
}
yugen-mt5-mcp config cursor

OpenCode

Add the following to ~/.config/opencode/config.json:

{
  "mcp": {
    "yugen-mt5": {
      "type": "local",
      "command": ["uvx", "yugen-mt5-mcp"],
      "environment": {
        "YUGEN_MT5_ALLOWED_SYMBOLS": "EURUSD,XAUUSD",
        "YUGEN_MT5_ALLOW_LIVE_TRADING": "false",
        "YUGEN_MT5_ALLOW_REAL_ACCOUNTS": "false",
        "YUGEN_MT5_MAX_ORDER_VOLUME": "1.0",
        "YUGEN_MT5_MAX_SYMBOL_EXPOSURE": "1.0"
      },
      "enabled": true
    }
  }
}
yugen-mt5-mcp config opencode

Configuration (Environment Variables)

All configuration is via YUGEN_MT5_* environment variables. You can generate an env block interactively:

yugen-mt5-mcp init
Variable Required Default Description
YUGEN_MT5_ALLOWED_SYMBOLS Yes Comma-separated symbol allowlist, or * for all. Wildcard prints a startup warning but does not relax any trading gate.
YUGEN_MT5_ALLOW_LIVE_TRADING No false Set true to enable order execution. When false the server is read-only.
YUGEN_MT5_ALLOW_REAL_ACCOUNTS No false Set true to permit real (non-demo) account operations. Demo accounts do not need this.
YUGEN_MT5_MAX_ORDER_VOLUME No 1.0 Max lot volume per single exposure-creating order. Does not apply to closing or modifying. Set unlimited to disable (startup warning).
YUGEN_MT5_MAX_SYMBOL_EXPOSURE No 1.0 Max cumulative open volume per symbol. Checked only on open. Set unlimited to disable (startup warning).
YUGEN_MT5_AUDIT_PATH No var/audit.sqlite3 Path to the SQLite audit database. Use an absolute path with desktop clients.
YUGEN_MT5_REAL_ACCOUNT_CONSENT No Explicit consent token for real-account operations. Resets on every restart.
YUGEN_MT5_REMOTE_ENABLED No false Set true to start the HTTP remote transport. Requires [remote] extra.
YUGEN_MT5_REMOTE_HOST No 127.0.0.1 Bind host for remote transport. Use 0.0.0.0 for LAN/VPS (requires TLS termination).
YUGEN_MT5_REMOTE_PORT No 8765 Port for remote transport.
YUGEN_MT5_REMOTE_BEARER_TOKEN No Bearer token for remote transport auth. Required when YUGEN_MT5_REMOTE_ENABLED=true.

Trading safety model

Control Behavior
Real-account acknowledgement Session-scoped. Clears on every server restart.
Allowed symbols / account modes Enforced before MT5 calls.
Volume / exposure limits Applied to opening orders only. Closing and modifying are never capped.
Audit trail SQLite append-only log with token and secret redaction.

Remote Transport (WSL / Mac to Windows MT5)

When your AI client runs in WSL, macOS, or a VPS and MetaTrader 5 is on a Windows host, use the HTTP remote transport:

# On the Windows host:
$env:YUGEN_MT5_REMOTE_ENABLED="true"
$env:YUGEN_MT5_REMOTE_BEARER_TOKEN="your-secret-token"
yugen-mt5-mcp run --transport remote

# Generate a client config block pointing at the Windows host:
yugen-mt5-mcp config remote --host 192.168.1.100 --port 8765 --token your-secret-token

Install the remote extra first:

uv tool install "yugen-mt5-mcp[remote]"

See docs/remote-transport.md for the full deployment guide, security model, and TLS setup.


For Contributors

Clone and install in editable mode

git clone https://github.com/YugenLabsTI/yugen-mt5-mcp.git
cd yugen-mt5-mcp
python -m pip install -e ".[dev]"

Run the test suite

pytest

MT5-dependent tests are automatically skipped on non-Windows platforms.

Run linting and type checks

ruff check src tests
mypy

Start the server locally

$env:YUGEN_MT5_ALLOWED_SYMBOLS="EURUSD,XAUUSD"
yugen-mt5-mcp run

For all CLI options see docs/cli.md. For installation variants see docs/install.md.


License

Apache-2.0 — see LICENSE.md. Copyright Yugen Labs S.A.S.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yugen_mt5_mcp-1.0.0.tar.gz (158.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yugen_mt5_mcp-1.0.0-py3-none-any.whl (75.3 kB view details)

Uploaded Python 3

File details

Details for the file yugen_mt5_mcp-1.0.0.tar.gz.

File metadata

  • Download URL: yugen_mt5_mcp-1.0.0.tar.gz
  • Upload date:
  • Size: 158.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yugen_mt5_mcp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 dcc2f3d0282d405b764f594808613324221ead19e0123c6ab92c84c29d98d8b3
MD5 32498bfd074c67a70f74b6f2ca61975c
BLAKE2b-256 452a6e3ba041536576d3e2c78a418f868abf24159d393f6e12bca9887e6fcd8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for yugen_mt5_mcp-1.0.0.tar.gz:

Publisher: publish.yml on YugenLabsTI/yugen-mt5-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yugen_mt5_mcp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: yugen_mt5_mcp-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 75.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yugen_mt5_mcp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1536ff624af3b91b0935fd9e4f80d5ee0f5f4b6b172a324784cd56a87c5f269
MD5 83ea1fc53f9392e20495357d71cd7a75
BLAKE2b-256 5b4ebf32fc304fe4943aece86dcd9af8e66e77bc573c5bba1efe7b30fc144201

See more details on using hashes here.

Provenance

The following attestation bundles were made for yugen_mt5_mcp-1.0.0-py3-none-any.whl:

Publisher: publish.yml on YugenLabsTI/yugen-mt5-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page