Install
$ agentstack add mcp-p7ac1d-mt5-mcp ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ● Environment & secrets Used
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
MCP Server for MetaTrader 5
[](LICENSE) [](https://www.python.org/downloads/) [](https://modelcontextprotocol.io/)
A Python-based Model Context Protocol (MCP) server that provides AI assistants like Claude with access to the MetaTrader 5 trading platform for market analysis and trade management.
Features
- Market Data Access: Real-time prices, OHLC bars, tick data, and symbol information
- Account Management: Account balance, equity, margin status
- Position Tracking: View open positions and pending orders
- Trade Execution: Place, modify, and close trades (with safety annotations)
- Historical Data: Access trade history and deal records
- MCP Resources: Passive polling endpoints for account, positions, and market data
Requirements
- Python 3.10+
- MetaTrader 5 terminal installed (Windows only - MT5 API limitation)
- MT5 account credentials
Installation
Using uv (recommended)
# Clone the repository
git clone https://github.com/P7AC1D/mt5-mcp.git
cd mt5-mcp
# Install with uv
uv sync
Using pip
pip install -e .
Configuration
- Copy
.env.exampleto.env:
``bash cp .env.example .env ``
- Edit
.envwith your MT5 credentials:
``env MT5_LOGIN=12345678 MT5_PASSWORD=your_password MT5_SERVER=MetaQuotes-Demo ``
Usage
Running the Server (Local - STDIO)
# Default: STDIO transport for local use
mcp-server-mt5
# Or using Python module
python -m mcp_server_mt5
# Or using uv
uv run mcp-server-mt5
Running the Server (Remote - HTTP)
For remote access over the network (e.g., from another machine):
# Start HTTP server on all interfaces, port 8000
mcp-server-mt5 --transport http --port 8000
# Or specify a different host/port
mcp-server-mt5 --transport http --host 0.0.0.0 --port 9000
Windows Firewall: Allow the port through Windows Firewall:
netsh advfirewall firewall add rule name="MCP MT5" dir=in action=allow protocol=tcp localport=8000
Clients connect to: http://:8000/sse
Claude Desktop Configuration (Local)
Add to your claude_desktop_config.json:
{
"mcpServers": {
"mt5": {
"command": "uv",
"args": [
"--directory",
"C:/Code/mt5-mcp",
"run",
"mcp-server-mt5"
],
"env": {
"MT5_LOGIN": "12345678",
"MT5_PASSWORD": "your_password",
"MT5_SERVER": "MetaQuotes-Demo"
}
}
}
}
VS Code MCP Configuration (Local)
Add to .vscode/mcp.json in your workspace:
{
"servers": {
"mt5": {
"command": "uv",
"args": ["--directory", "C:/Code/mt5-mcp", "run", "mcp-server-mt5"],
"env": {
"MT5_LOGIN": "${env:MT5_LOGIN}",
"MT5_PASSWORD": "${env:MT5_PASSWORD}",
"MT5_SERVER": "${env:MT5_SERVER}"
}
}
}
}
Remote Access from Another Machine
When the server is running with --transport http, clients on other machines can connect:
Python MCP Client:
from mcp.client.sse import sse_client
from mcp.client.session import ClientSession
async with sse_client("http://:8000/sse") as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await session.list_tools()
# Call tools...
MCP Inspector (for testing):
npx @modelcontextprotocol/inspector http://:8000/sse
Available Tools
Account
get_account_info- Get account balance, equity, margin, and trading conditions
Market Data
get_symbols- List available trading symbolsget_symbol_info- Get detailed symbol specificationget_symbol_tick- Get current bid/ask pricesget_ohlc_bars- Get OHLC candlestick dataget_ohlc_bars_range- Get OHLC data for a date rangeget_ticks_range- Get tick data for a date range
Positions
get_positions- Get all open positionsget_positions_count- Get number of open positions
Orders
get_pending_orders- Get all pending orderscalculate_margin- Calculate required margin for an ordercalculate_profit- Calculate potential profit/losscheck_order- Validate an order before sendingsend_order- Execute a trade order ⚠️ (requires confirmation)
History
get_history_orders- Get historical ordersget_history_deals- Get historical deals/trades
Available Resources
Resources provide passive data access for polling:
mt5://account/info- Account informationmt5://symbols- List of trading symbolsmt5://symbols/{symbol}/tick- Current price tick for a symbolmt5://symbols/{symbol}/info- Symbol specificationmt5://positions- Open positionsmt5://orders- Pending orders
Safety Considerations
- Trade execution tools (
send_order) are marked withdestructiveHint=Trueto prompt for user confirmation - Always use a demo account for testing
- The server logs all trading operations for audit purposes
- Consider implementing additional safeguards (position limits, daily loss limits) for production use
Development
# Install dev dependencies
uv sync --extra dev
# Run tests
pytest
# Run with MCP Inspector for debugging
npx @modelcontextprotocol/inspector uv run mcp-server-mt5
Contributing
Contributions are welcome! Please read the [Contributing Guide](CONTRIBUTING.md) before submitting a pull request.
Security
For security concerns, please see [SECURITY.md](SECURITY.md). Never commit real credentials — use .env files with the provided .env.example as a template.
License
MIT License — see [LICENSE](LICENSE) for details.
Source & license
This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: P7AC1D
- Source: P7AC1D/mt5-mcp
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.