Claude with MetaTrader 5: a safe, read-first setup
There are two routes: MetaTrader 5's own AI and MCP support, where Anthropic is a selectable provider, or Claude writing Python for the MetaTrader5 package. Either way, start on demo, read before you trade and confirm every order yourself.
Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.
Steps
MT5 has MCP and AI built in
Build 6060 (23 Jul 2026) added MCP support so external AI agents can use MetaTrader 5 as a market data and trading source, plus AI Assistants in the terminal and MetaEditor. Anthropic is one of the selectable providers alongside MQL5 Lite, OpenAI, Gemini, DeepSeek and Ollama.
metatrader5.comchecked
Set AI trading to confirm or off
MetaQuotes says you can allow or prohibit AI initiated trading operations, or require manual confirmation. Pick prohibit while you learn, then manual confirmation.
metatrader5.comchecked
Log in to a demo account
The MetaTrader5 Python package uses whichever account the running terminal is logged in to, so log the terminal in to demo. It needs Windows.
pypi.orgchecked
Ask Claude for read-only code
Ask Claude for a script that calls initialize(), reads account_info() and positions, and never calls order_send. Credentials stay in the terminal or in environment variables, never in the chat.
mql5.comchecked
Keep a human in the loop
The MCP specification says there should always be a human in the loop who can deny tool calls, and clients should show tool inputs before calling a server. Approve each tool call in Claude rather than allowing all.
modelcontextprotocol.iochecked
Community MCP server trades by default
The community metatrader-mcp-server connects Claude Desktop to MT5, takes LOGIN, PASSWORD and SERVER as arguments or environment variables, and enables its trading tools once configured. It is listed in our AI and MCP guide, not tested or endorsed; use it on demo only.
github.comchecked
Check success codes
If you later add orders, success is result.retcode equal to TRADE_RETCODE_DONE (10009); anything else is a failure to read, not retry blindly. Our MT5 error pages list the codes.
mql5.comchecked