mt4-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mt4-mcpshow my current account balance"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mt4-mcp
mt4-mcp is an MCP server so AI agents can inspect and trade against a MetaTrader 4 terminal — account, symbols, quotes, orders/positions, history — with a full offline mock for CI and demos.
Install (one command)
Grok — recommended
pip install "git+https://github.com/mergeos-bounties/mt4-mcp.git" && grok plugin install mergeos-bounties/mt4-mcp --trustThis installs the Python CLI (mt4-mcp) and the Grok plugin (skill + MCP server from .mcp.json).
Check:
mt4-mcp version
mt4-mcp doctor
mt4-mcp demo
grok plugin list
grok mcp listLocal clone:
git clone https://github.com/mergeos-bounties/mt4-mcp.git
cd mt4-mcp
pip install -e ".[dev]"
grok plugin install . --trustOther agents (stdio MCP)
After pip install "git+https://github.com/mergeos-bounties/mt4-mcp.git", point any MCP host at:
Field | Value |
command |
|
args |
|
env |
|
Claude Desktop — merge examples/claude_desktop_config.json into Claude MCP config.
Cursor — merge examples/cursor_mcp.json.
Grok config.toml (manual, without plugin):
[mcp_servers.mt4_mcp]
command = "mt4-mcp"
args = ["serve"]
env = { MT4_MCP_MODE = "mock" }
enabled = trueOne-liner via Grok CLI:
pip install "git+https://github.com/mergeos-bounties/mt4-mcp.git"
grok mcp add mt4-mcp -- mt4-mcp serveRelated MCP server: OpenTrading
Supported AI agents / hosts
Host | Support | Install |
Grok (CLI / TUI / Build) | Yes |
|
Claude Desktop | Yes | Copy examples/claude_desktop_config.json into Claude MCP settings |
Cursor | Yes | Merge examples/cursor_mcp.json into Cursor MCP config |
Claude Code | Yes | stdio MCP: same |
VS Code (MCP / Continue / Cline) | Yes | Generic stdio server config pointing at |
Windsurf / Cascade | Yes | stdio MCP entry with |
Codex CLI | Yes (stdio) | Register MCP server command |
ChatGPT Desktop | Partial | Only if host supports custom MCP stdio servers |
Gemini CLI | Partial | Only if MCP stdio plugins are enabled |
All packages speak MCP over stdio (mt4-mcp serve). Default mode is mock (offline, no simulator/terminal/GIMP required).
Modes
Mode | When | Behavior |
mock (default) | Windows / CI / no terminal | Seeded demo account, FX/CFD symbols, orders, history |
live | Host has a bridge configured | Optional file/HTTP bridge (see env vars); fails closed if unavailable |
Highlights
Capability | Description |
Offline demo |
|
MCP stdio serve | Plug into Cursor / Claude / Grok as an MCP server |
One-shot call |
|
Safety | Mock never talks to a real broker; live needs explicit env |
Quick start
cd mt4-mcp
python -m venv .venv
.\.venv\Scripts\activate
pip install -e ".[dev]"
mt4-mcp version
mt4-mcp status
mt4-mcp demo
mt4-mcp tools list
pytest -qMock mode needs no MetaTrader install. For a copy-pasteable offline trading walkthrough, see docs/MOCK_TRADING_DEMO.md.
CLI reference
Command | Purpose |
| Version + mode |
| Mode, balance, equity, and open order count |
| Offline smoke of core backend APIs |
| Backend health |
| MCP server over stdio |
| One-shot tool call |
| List MCP tools |
mt4-mcp serveMCP tools
Tool | Purpose |
| Get/set mock|live |
| Connectivity / account health |
| Reset mock account |
| Balance, equity, margin |
| Symbol list |
| Bid/ask for a symbol |
| Recent quote ticks for a symbol |
| Open orders |
| Market/pending OrderSend-style |
| SL/TP/price modify |
| Close by ticket |
| Closed order history |
Mock pending fills
In mock mode, pending orders are converted to market orders when quotes cross
their trigger price. The mock supports deterministic tests for buy_limit,
sell_limit, buy_stop, and sell_stop crossing behavior.
MCP host config
{
"mcpServers": {
"mt4-mcp": {
"command": "python",
"args": ["-m", "mt4_mcp"],
"env": {
"MT4_MCP_MODE": "mock"
}
}
}
}Also see examples/cursor_mcp.json.
Live bridge (optional)
Set env (never commit secrets):
Variable | Meaning |
|
|
| Optional HTTP bridge base URL |
| Optional request/response JSON file path |
Without a working bridge, live mode returns structured errors; demos stay on mock.
Safety
Rule | Detail |
Mock-only env | Copy |
No secrets in git | Add |
Max volume | Set |
Symbol allowlist | Restrict tradeable symbols via |
Development
pip install -e ".[dev]"
ruff check src tests
pytest -q
mt4-mcp demoLicense
This server cannot be deployed
Maintenance
Related MCP Connectors
- FensoryOAuthcom.fensory
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents
Hosted MCP server for MT4 and MT5: read accounts, prices and candles, and place or close orders.
MCP server exposing the Backtest360 engine API as tools for AI agents.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA standalone Model Context Protocol (MCP) server that enables AI assistants to interact with the cTrader trading platform.15-
- AlicenseNot gradedqualityDmaintenanceAn open-source AI trading agent for MetaTrader 5 with MCP support, connecting AI clients to MT5 for market data, analysis, and risk-gated trading.MIT
- AlicenseAqualityBmaintenanceAn 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.15157 PyPI6MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server for operating headless MetaTrader 5 terminals — over SSH, from your agent.MIT