MetaTrader 5 MCP Server
Qoyyuum
README
MetaTrader 5 MCP Server
A Model Context Protocol (MCP) server for interacting with the MetaTrader 5 trading platform. This server provides AI assistants with tools and resources to access market data, perform trading operations, and analyze trading history.
Features
- Market Data Access: Fetch historical price data, ticks, and symbol information
- Trading Operations: Place orders, manage positions, and track trading history
- Account Management: Access account information and terminal status
- AI-Friendly Prompts: Pre-defined conversation templates for common trading tasks
- Comprehensive Documentation: Detailed guides for using the MetaTrader 5 API
Prerequisites
- Python 3.8 or higher
- MetaTrader 5 terminal installed
- MetaTrader 5 account (demo or real)
Installation
- Install the required dependencies:
pip install -r requirements.txt
- Make sure the MetaTrader 5 terminal is installed and running.
Usage
Running the Server in Development Mode
To run the server in development mode with hot reloading:
fastmcp dev main.py
This will start the MCP server and provide an inspector interface for testing the tools and resources.
Installing the Server for Claude Desktop
To install the server for use with Claude Desktop:
fastmcp install main.py
Using the Server with AI Assistants
Once the server is running, AI assistants can use the following tools and resources:
Connection Management
initialize()
: Initialize the MetaTrader 5 terminallogin(account, password, server)
: Log in to a trading accountshutdown()
: Shut down the connection to the terminal
Market Data Access
get_symbols()
: Get all available symbolsget_symbol_info(symbol)
: Get information about a specific symbolcopy_rates_from_pos(symbol, timeframe, start_pos, count)
: Get historical price datacopy_ticks_from_pos(symbol, start_pos, count, flags)
: Get historical tick data
Trading Operations
order_send(request)
: Send a trading orderpositions_get(symbol, group)
: Get open positionsorders_get(symbol, group)
: Get active ordershistory_orders_get(...)
: Get historical ordershistory_deals_get(...)
: Get historical deals
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=1.1,
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://timeframes
: Information about available timeframesmt5://tick_flags
: Information about tick flagsmt5://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
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
- MetaQuotes for the MetaTrader 5 platform
- FastMCP for the MCP server implementation
Recommended Servers
Crypto Price & Market Analysis MCP Server
A Model Context Protocol (MCP) server that provides comprehensive cryptocurrency analysis using the CoinCap API. This server offers real-time price data, market analysis, and historical trends through an easy-to-use interface.
MCP PubMed Search
Server to search PubMed (PubMed is a free, online database that allows users to search for biomedical and life sciences literature). I have created on a day MCP came out but was on vacation, I saw someone post similar server in your DB, but figured to post mine.
dbt Semantic Layer MCP Server
A server that enables querying the dbt Semantic Layer through natural language conversations with Claude Desktop and other AI assistants, allowing users to discover metrics, create queries, analyze data, and visualize results.
mixpanel
Connect to your Mixpanel data. Query events, retention, and funnel data from Mixpanel analytics.

Sequential Thinking MCP Server
This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.

Nefino MCP Server
Provides large language models with access to news and information about renewable energy projects in Germany, allowing filtering by location, topic (solar, wind, hydrogen), and date range.
Vectorize
Vectorize MCP server for advanced retrieval, Private Deep Research, Anything-to-Markdown file extraction and text chunking.
Mathematica Documentation MCP server
A server that provides access to Mathematica documentation through FastMCP, enabling users to retrieve function documentation and list package symbols from Wolfram Mathematica.
kb-mcp-server
An MCP server aimed to be portable, local, easy and convenient to support semantic/graph based retrieval of txtai "all in one" embeddings database. Any txtai embeddings db in tar.gz form can be loaded
Research MCP Server
The server functions as an MCP server to interact with Notion for retrieving and creating survey data, integrating with the Claude Desktop Client for conducting and reviewing surveys.