by psyb0t
Run MetaTrader 5 inside a real Windows VM and expose REST and MCP endpoints for programmatic trading, market data retrieval, and server‑side technical‑analysis calculations without relying on Wine or other compatibility layers.
MT5 Httpapi provides a self‑hosted environment where the official MetaTrader 5 terminal runs in a genuine Windows virtual machine (Docker + QEMU/KVM). It adds thin REST and MCP layers that let external agents interact with the terminal – fetching market data, placing orders, managing positions, running Strategy‑Tester jobs, and obtaining server‑side technical indicators such as RSI, MACD, Bollinger Bands, ADX, VWAP, Ichimoku, Order Blocks, and FVGs.
git clone https://github.com/psyb0t/mt5-httpapi.git
cd mt5-httpapi
cp config/config.yaml.example config/config.yaml
openssl rand -hex 32) and fill in your broker credentials, login, password, and the exact broker key name.mt5installers/ following the naming convention (mt5setup-<broker-key>.exe).make up # boots the Windows VM and Docker services
make status # blocks until the Python API inside the VM is healthy
export MT5_API_TOKEN=your-token
export MT5_API_URL=http://localhost:8888/<broker>/<account>
curl -H "Authorization: Bearer $MT5_API_TOKEN" $MT5_API_URL/ping
Additional endpoints are documented in docs/rest-api.md.http://localhost:8888/<broker>/<account>/…).wickworks sidecar, delivering enriched OHLC bars with common indicators..ex5 without launching MetaEditor.clients/go/) for strongly‑typed request generation.config.yaml is required for every request.vms.yaml; the system will spin up separate containers per VM.http://localhost:8006 while the VM boots.MetaTrader 5 running inside a real Windows VM (Docker + QEMU/KVM) with REST and MCP APIs slapped on top. No Wine bullshit, no janky compatibility hacks — the real Windows MT5 terminal in portable mode, controllable without clicking through that fucking GUI all day.
Run multiple brokers, accounts, and cloned terminal instances at the same time. Each one gets its own Python API process inside the VM, while nginx puts the whole mess behind one port at http://localhost:8888/<broker>/<account>/....
[!WARNING] This thing can trade real money. If your algo buys the top and detonates your account, that shit is on you. Start with demo accounts and test the fucker properly.
/dev/kvmMT5 hoards loaded chart history like a greedy little bastard and does not give the memory back. Deep history scraping can blow each terminal up to several gigabytes, so read the actual sizing details before hammering it.
git clone https://github.com/psyb0t/mt5-httpapi.git
cd mt5-httpapi
cp config/config.yaml.example config/config.yaml
# Generate a bearer token, then edit config/config.yaml with it, your broker
# login, server, password, and ONE terminal you actually intend to run.
openssl rand -hex 32
# This filename is not decoration: "mybroker" MUST exactly match the
# broker: field of the terminal you configured below.
cp ~/Downloads/mt5setup.exe mt5installers/mt5setup-mybroker.exe
# Start the stack. This starts the VM; it does not mean MT5 is ready yet.
make up
# Wait until this passes before hitting the API.
make status
Before make up, replace the template's sample accounts: and terminals:
blocks — they contain placeholder FTMO and RoboForex entries and will not
magically start your broker. Keep the other template settings, but the three
names below must line up exactly, or Windows installs one terminal and the API
tries to launch another fucking thing:
# config/config.yaml
accounts:
mybroker: # 1. broker key
main: # 2. account key
login: 12345678 # your real account login
server: "Broker-MT5" # your broker's exact MT5 server name
password: "your-password"
terminals:
- broker: mybroker # 1. same broker key
account: main # 2. same account key
port: 5001 # unique per terminal; stays inside Docker
utc_offset: "0" # set this to the broker server's UTC offset
The installer must therefore be named mt5installers/mt5setup-mybroker.exe
(mybroker is 3. the same broker key). Get that executable from the broker;
this repo cannot download it for you. Remove the unused example accounts and
terminals, or configure an installer for every one of them.
The first run downloads tiny11 and installs Windows, Python, and MT5, so give
the fucker roughly ten minutes. make up returning only means Docker and the
VM booted; make status passing means the configured terminal API is actually
alive. Watch the installation through noVNC at http://localhost:8006; the
API lands at http://localhost:8888/mybroker/main/ for the config above.
client
├─ REST: /<broker>/<account>[/<instance>]/...
└─ MCP: /mcp or /<broker>/<account>/mcp
│
nginx :8888
│
Windows VM(s) ── one MT5 terminal + Python API process per configured terminal
│
wickworks sidecar for requested technical-analysis calculations
config/config.yaml controls the accounts, terminals, ports, auth, broker UTC offsets, and whether a terminal is for live trading or backtests. Add a real vms.yaml when one Windows VM is not enough; leave it out and the normal single-VM setup keeps working.
The old README became a massive wall of API shit, so the details now live in separate files where you can actually find them:
| You need | Read this |
|---|---|
| Get Windows + MT5 running, size the host, and configure accounts | Installation and configuration |
| Figure out routing, auth, health, terminal state, accounts, and broker time | REST API overview |
| Pull symbols, ticks, bars, and server-side TA | Market data API |
| Place/close shit and inspect orders, positions, and history | Trading and history API |
| Run Strategy Tester jobs and get the artifacts back | Backtesting |
| Throw giant parameter sweeps at the Strategy Tester | Backtest optimization |
Turn MQL5 source into an .ex5 without touching MetaEditor |
Compiling MQL5 |
| Wire the MCP endpoints into your agent of choice | MCP and agent integrations |
| Copy working curl and Go examples instead of guessing | Clients and examples |
| Operate the bastard: Make targets, ports, remote access, concurrency, and logs | Operations |
| Split terminals across several Windows VMs or NUMA nodes | Multi-VM setup |
| Deploy EAs onto charts over HTTP instead of clicking through the Navigator | Chart Deployments |
Every configured terminal gets one of these routes:
http://localhost:8888/<broker>/<account>/...
http://localhost:8888/<broker>/<account>/<instance>/...
Set api_token in config/config.yaml, shove it into a bearer header, and start poking the thing:
export MT5_API_TOKEN="your-token-here"
export MT5_API_URL="http://localhost:8888/mybroker/main"
curl -H "Authorization: Bearer $MT5_API_TOKEN" "$MT5_API_URL/ping"
curl -H "Authorization: Bearer $MT5_API_TOKEN" "$MT5_API_URL/account"
curl -H "Authorization: Bearer $MT5_API_TOKEN" \
"$MT5_API_URL/symbols/EURUSD/rates?timeframe=H1&count=100"
That is just the hello-world shit. The REST API docs link to every endpoint and response shape.
make status # see whether the whole contraption is alive
make test # run all the tests, including integration + Go race
make lint # lint the PowerShell and shell shit
make format # format the shell scripts
make verify-binaries # check every vendored executable against the manifest
make logs # watch the logs scream
make down # stop only this project's stack
Run make help when you forget the rest. The operations guide explains what the targets actually do.
Every executable tracked in this repo is declared in
assets/binaries.lock.json with its SHA-256, size,
upstream URL and the state of its code signature. make verify-binaries — which
make test runs first, so CI enforces it on every pull request — fails the
build on an undeclared binary, on one whose bytes changed, or on a signature
that degrades.
Nobody can read a binary. A reviewer skims thousands of lines of source and
waves through the .exe beside it because there is nothing to skim, and that is
the shape every serious supply-chain compromise has taken. If you need to add
one: verify the download yourself against the vendor's published hash, then
record it in the manifest with where it came from. If it cannot be verified, say
so in its note — the gate will keep warning about it on every run, which is
the point.
config/ config and templates for the whole contraption
mt5api/ Python REST + MCP server running beside each terminal
mcpunifier/ one MCP endpoint that fronts every configured terminal
clients/go/ typed Go client so you do not have to hand-roll requests
scripts/ Windows bootstrap and host-side glue
tests/ unit, contract, integration, and race-test shit
docs/ all the details that no longer clog up this README
WTFPL. See CHANGELOG.md for release notes.
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by stripe
Provides SDKs and tools to integrate Stripe's billing and API services with large language models, agent frameworks, and token‑metering for AI‑powered products and businesses.
by goat-sdk
Enables AI agents to send and receive payments, purchase goods and services, execute investment strategies, tokenize assets, and obtain financial insights by leveraging blockchains, stablecoins, and wallets.
by financial-datasets
Provides access to income statements, balance sheets, cash flow statements, stock prices, market news, and cryptocurrency data through MCP tools for AI assistants.
by openaccountants
Provides open‑source, accountant‑reviewed tax guides that AI models can cite when answering tax‑related queries, ensuring answers are backed by current jurisdictional rules and credited experts.
by alpacahq
Enables large language models to trade stocks and options, retrieve real‑time and historical market data, and manage portfolios using plain English commands through a local or remote MCP server.
by stefanoamorelli
Provides an MCP server that connects AI models to SEC EDGAR filings, enabling real‑time retrieval of company filings, financial statements, and insider‑trading data with exact XBRL precision and verifiable filing references.
by imbenrabi
Provides AI assistants with direct access to Financial Modeling Prep data, including real‑time stock quotes, company fundamentals, financial statements, market indexes, news, and alternative data sets via the Model Context Protocol.
by ariadng
Enables AI LLMs to execute trades on the MetaTrader 5 platform through the Model Context Protocol.
by XeroAPI
Provides a bridge between the Model Context Protocol and Xero's API, enabling standardized access to Xero accounting and business features.