mt5-mcp

Connect Claude to MetaTrader 5 on your Mac.

An open-source MCP server for the official MT5 macOS app. Your agent reads prices, history and positions straight from the terminal you already use. It can only trade if you switch trading on.

get_rates(symbol="EURUSD", timeframe="H1", count=48) bid 1.11928 ask 1.11939
Real EURUSD hourly bars returned by this server from a Pepperstone demo account on 13 October 2026. Times are in UTC; the gap is the weekend.

How it reaches the terminal

MetaQuotes' Python package only runs on Windows, so the server puts a small bridge inside the Wine environment that the MT5 app ships with. You never start it yourself: the server launches it on the first request.

Your agent

Claude Code, Claude Desktop or any MCP client

mt5-mcp

The MCP server, running natively on macOS

mt5-bridge

Windows Python with the official MetaTrader5 package

MetaTrader 5

The terminal you are logged into

Install in three steps

You need the MetaTrader 5 app from metatrader5.com, open and logged into a broker account, and uv.

  1. Get the code

    Clone the repository and move into it.

    git clone https://github.com/CodeWithBehnam/meta-trader-5-mcp.git
    cd meta-trader-5-mcp
  2. Install the bridge

    This adds uv, Python 3.12 and the MetaTrader5 package to C:\mt5-bridge inside the MT5 Wine environment. Nothing else in MT5 changes, and it is safe to run again.

    scripts/install-bridge.sh
    uv sync
  3. Add it to Claude Code

    Run this from the repository folder, then start a new Claude Code session and ask for the MT5 terminal status.

    claude mcp add --transport stdio --scope user mt5 -- uv --directory "$PWD" run mt5-mcp

What your agent can do

Inputs and outputs use UTC. The server works out your broker's clock offset and converts for you.

Always available, read-only

terminal_status
Connection, Algo Trading state and broker clock offset
get_account_info
Balance, equity, margin and leverage
list_symbols
Symbols matching a pattern such as *USD*
get_symbol_info
Contract size, digits, spread and trading rules
get_tick
Latest bid and ask
get_rates
OHLC bars by count or date range
get_ticks
Tick history from a start time
get_positions
Open positions
get_orders
Pending orders
get_history_deals
Filled deals, last 7 days by default
get_history_orders
Past orders
calc_margin
Margin the broker would require
calc_profit
Profit between two prices
check_order
Dry run of an order. Nothing is sent.

Trading, off by default

These tools do not exist for the agent until you set MT5_ENABLE_TRADING=1.

place_order
Market, limit, stop and stop-limit orders
modify_position_sltp
Change stop loss and take profit
modify_pending_order
Change price, levels or expiry
close_position
Close all or part of a position
cancel_order
Remove a pending order

What happens when the agent places an order

Every order takes the same path. A failure at any step stops it.

  1. Check your limits

    Symbol allowlist, maximum lots and maximum slippage.

  2. Ask MT5 first

    order_check must pass before anything is sent.

  3. Write the intent

    If the audit log cannot be written, the order is not sent.

  4. Send once

    Never retried, so a dropped connection cannot double a trade.

  5. Record the outcome

    Fills, rejections and unknown outcomes go to the audit log.

MT5's Algo Trading button must also be on for orders to go through. It applies to the whole terminal, including any Expert Advisors on your charts. Start on a demo account.

Built for the official app

Works with the MetaTrader 5 app from MetaQuotes and the Wine it bundles. No CrossOver, Parallels or Docker.

Stays on your Mac

The bridge only listens on 127.0.0.1 and refuses requests without the token created on first run.

Open source

MIT licensed Python, managed with uv and covered by more than 300 tests. Read the code.