Real-time global intelligence dashboard. AI-powered news aggregation, geopolitical monitoring, and infrastructure tracking in a unified situational awareness interface
MCP server for MetaTrader 5 market data and trades
This repo provides an MCP server that sits between an agent and the MetaTrader 5 terminal. Through the server, the agent can connect to MT5, read symbols and price data, place and check orders, and inspect positions and trading history.
Builders who want their agent to read MetaTrader 5 data and manage trades.
You can let an agent query market data, place orders, and analyze trading history without leaving your MCP client.
What it does
Terminal connection and login
Tools to initialize the MT5 terminal, log in to an account, and shut the connection down.
Market data access
Tools for symbols, symbol info, ticks, rates, and tick or bar ranges by position or date.
Trading actions
Tools for sending and checking orders, plus reading open positions and active orders.
Trading history access
Tools to pull historical orders and deals by symbol, ticket, position, or date range.
Agent guidance resources
Built-in `mt5://` resources and prompts for getting started, market data, trading, and history analysis.
MCP client setup examples
Installation examples for Claude Desktop, Claude Code, Cursor, and Gemini CLI using FastMCP or `uvx`.
How to get it
- 1Run
uvx --from mcp-metatrader5-server mt5mcp
- 2Run
git clone https://github.com/Qoyyuum/mcp-metatrader5-server.git cd mcp-metatrader5-server uv sync uv run mt5mcp
- 3The server runs in stdio mode by default for MCP clients like Claude Desktop
uv run mt5mcp
- 4Then run
uv run mt5mcp
- 5Run
git clone https://github.com/Qoyyuum/mcp-metatrader5-server cd mcp-metatrader5-server
- 6For MCP JSON format
uv run fastmcp install mcp-json src/mcp_mt5/main.py
README
MetaTrader 5 MCP Server
A Model Context Protocol (MCP) server for MetaTrader 5, allowing AI assistants to interact with the MetaTrader 5 platform for trading and market data analysis. Documentation
Features
- Connect to MetaTrader 5 terminal
- Access market data (symbols, rates, ticks)
- Place and manage trades
- Analyze trading history
- Integrate with AI assistants through the Model Context Protocol
Installation
From PyPI
uvx --from mcp-metatrader5-server mt5mcp
From Source
git clone https://github.com/Qoyyuum/mcp-metatrader5-server.git
cd mcp-metatrader5-server
uv sync
uv run mt5mcp
Requirements
- uv (recommended) or pip
- Python 3.11 or higher
- MetaTrader 5 terminal installed on Windows
- MetaTrader 5 account (demo or real)
Usage
Quick Start
The server runs in stdio mode by default for MCP clients like Claude Desktop:
uv run mt5mcp
Development Mode (HTTP)
For testing with HTTP transport, create a .env file:
MT5_MCP_TRANSPORT=http
MT5_MCP_HOST=127.0.0.1
MT5_MCP_PORT=8000
Then run:
uv run mt5mcp
The server will start at http://127.0.0.1:8000
Installing for MCP Clients
Method 1: Using uvx (Simplest - No Installation Required) ⭐
Add this configuration to your MCP client's config file:
For Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"mcp-metatrader5-server": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/Qoyyuum/mcp-metatrader5-server",
"mt5mcp"
]
}
}
}
Method 2: Using FastMCP Install (Recommended)
git clone https://github.com/Qoyyuum/mcp-metatrader5-server
cd mcp-metatrader5-server
After git cloning the repo, run the following commands:
For MCP JSON format
uv run fastmcp install mcp-json src/mcp_mt5/main.py
For Claude Desktop
uv run fastmcp install claude-desktop src/mcp_mt5/main.py
For Claude Code
uv run fastmcp install claude-code src/mcp_mt5/main.py
For Cursor
uv run fastmcp install cursor src/mcp_mt5/main.py
For Gemini CLI
uv run fastmcp install gemini-cli src/mcp_mt5/main.py
Method 3: Manual Configuration
Add this to your claude_desktop_config.json or whatever LLM config file:
{
"mcpServers": {
"mcp-metatrader5-server": {
"command": "uvx",
"args": [
"--from",
"mcp-metatrader5-server",
"mt5mcp"
]
}
}
}
API Reference
Connection Management
initialize(): Initialize the MT5 terminallogin(account, password, server): Log in to a trading accountshutdown(): Close the connection to the MT5 terminal
Market Data Functions
get_symbols(): Get all available symbolsget_symbols_by_group(group): Get symbols by groupget_symbol_info(symbol): Get information about a specific symbolget_symbol_info_tick(symbol): Get the latest tick for a symbolcopy_rates_from_pos(symbol, timeframe, start_pos, count): Get bars from a specific positioncopy_rates_from_date(symbol, timeframe, date_from, count): Get bars from a specific datecopy_rates_range(symbol, timeframe, date_from, date_to): Get bars within a date rangecopy_ticks_from_pos(symbol, start_pos, count): Get ticks from a specific positioncopy_ticks_from_date(symbol, date_from, count): Get ticks from a specific datecopy_ticks_range(symbol, date_from, date_to): Get ticks within a date range
Trading Functions
order_send(request): Send an order to the trade serverorder_check(request): Check if an order can be placed with the specified parameterspositions_get(symbol, group): Get open positionspositions_get_by_ticket(ticket): Get an open position by its ticketorders_get(symbol, group): Get active ordersorders_get_by_ticket(ticket): Get an active order by its tickethistory_orders_get(symbol, group, ticket, position, from_date, to_date): Get orders from historyhistory_deals_get(symbol, group, ticket, position, from_date, to_date): Get deals from history
Example Workflows
Connecting and Getting Market Data
# Initialize MT5
initialize()
# Log in to your trading account
login(account=123456, password="your_password", server="your_server")
# Get available symbols
symbols = get_symbols()
# Get recent price data for EURUSD
rates = copy_rates_from_pos(symbol="EURUSD", timeframe=15, start_pos=0, count=100)
# Shut down the connection
shutdown()
Placing a Trade
# Initialize and log in
initialize()
login(account=123456, password="your_password", server="your_server")
# Create an order request
request = OrderRequest(
action=mt5.TRADE_ACTION_DEAL,
symbol="EURUSD",
volume=0.1,
type=mt5.ORDER_TYPE_BUY,
price=mt5.symbol_info_tick("EURUSD").ask,
deviation=20,
magic=123456,
comment="Buy order",
type_time=mt5.ORDER_TIME_GTC,
type_filling=mt5.ORDER_FILLING_IOC
)
# Send the order
result = order_send(request)
# Shut down the connection
shutdown()
Resources
The server provides the following resources to help AI assistants understand how to use the MetaTrader 5 API:
mt5://getting_started: Basic workflow for using the MetaTrader 5 APImt5://trading_guide: Guide for placing and managing tradesmt5://market_data_guide: Guide for accessing and analyzing market datamt5://order_types: Information about order typesmt5://order_filling_types: Information about order filling typesmt5://order_time_types: Information about order time typesmt5://trade_actions: Information about trade request actions
Prompts
The server provides the following prompts to help AI assistants interact with users:
connect_to_mt5(account, password, server): Connect to MetaTrader 5 and log inanalyze_market_data(symbol, timeframe): Analyze market data for a specific symbolplace_trade(symbol, order_type, volume): Place a trade for a specific symbolmanage_positions(): Manage open positionsanalyze_trading_history(days): Analyze trading history
Development
Project Structure
mcp-metatrader5-server/
├── src/
│ └── mcp_mt5/
│ ├── __init__.py # Entry point with main()
│ ├── main.py # FastMCP server with all tools
│ └── test_client.py # Test client for development
├── docs/
│ ├── getting_started.md
│ ├── market_data_guide.md
│ ├── trading_guide.md
│ └── publishing.md
├── .env # Environment configuration (create from .env.example)
├── README.md
├── pyproject.toml # Project metadata (using hatchling)
└── uv.lock # Dependency lock file
Building the Package
Using uv (recommended):
uv build
This will create wheel and source distributions in the dist/ directory.
Publishing to PyPI
Using uv:
# Build first
uv build
# Publish to PyPI
uv publish
# Or publish to TestPyPI first
uv publish --publish-url https://test.pypi.org/legacy/
License
MIT
Acknowledgements
- MetaQuotes for the MetaTrader 5 platform
- FastMCP for the MCP server implementation
Files in the repo
- .github
- docs
- examples
- src
- tests
- .coverage
- .env.example
- .gitignore
- .python-version
- .readthedocs.yaml
- CONTRIBUTING.md
- fastmcp.json
- pyproject.toml
- README.md
- ruff.toml
- uv.lock
Discussion (0)
Ask about usage, or say what you built with itSign in to join the discussion.
No comments yet. Be the first to say what this is good for.
More connectors
High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

Universal provider proxy for OpenAI Codex & Claude Code — use any LLM (Claude, Gemini, Grok, DeepSeek, Ollama…) with Codex CLI, App, SDK, and Claude Code
Git-native persistent memory for AI coding agents. Implements Google OKF v0.2 with sub-300µs in-memory BM25 search, embedded MCP server, and progressive disclosure. Slashes token bloat by 80% with zero external databases or dependencies. Built in pure Go.
Stop your AI from making things up — it proposes, deterministic tools decide, every claim checked against ground truth with evidence. Grounded facts and context survive resets. Reverse engineering is the proving ground. MCP server + CLI.
20 MB lightweight cross-platform database client for 90+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 90+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP Server。
