Skip to content
Back to search

mcp-metatrader5-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.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/Qoyyuum/mcp-metatrader5-server with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/Qoyyuum/mcp-metatrader5-server'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/qoyyuum--mcp-metatrader5-server/badge.svg)](/listings/qoyyuum--mcp-metatrader5-server)

HTML

<a href="/listings/qoyyuum--mcp-metatrader5-server"><img src="/api/listings/qoyyuum--mcp-metatrader5-server/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

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

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 326 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/Qoyyuum/mcp-metatrader5-server)
  2. [![MseeP.ai Security Assessment Badge](https://mseep.net/pr/qoyyuum-mcp-metatrader5-server-badge.png)](https://mseep.ai/app/qoyyuum-mcp-metatrader5-server)
  3. [![codecov](https://codecov.io/github/Qoyyuum/mcp-metatrader5-server/graph/badge.svg?token=SRECTEZUAR)](https://codecov.io/github/Qoyyuum/mcp-metatrader5-server)
  4. [![PyPI version](https://badge.fury.io/py/mcp-metatrader5-server.svg)](https://pypi.org/project/mcp-metatrader5-server/)
  5. # MetaTrader 5 MCP Server
  6. 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](https://mcp-metatrader5-server.readthedocs.io)
  7. ## Features
  8. - Connect to MetaTrader 5 terminal
  9. - Access market data (symbols, rates, ticks)
  10. - Place and manage trades
  11. - Analyze trading history
  12. - Integrate with AI assistants through the Model Context Protocol
  13. ## Installation
  14. ### From PyPI
  15. ```bash
  16. uvx --from mcp-metatrader5-server mt5mcp
  17. ```
  18. ### From Source
  19. ```bash
  20. git clone https://github.com/Qoyyuum/mcp-metatrader5-server.git
  21. cd mcp-metatrader5-server
  22. uv sync
  23. uv run mt5mcp
  24. ```
  25. ## Requirements
  26. - **uv** (recommended) or pip
  27. - **Python 3.11 or higher**
  28. - **MetaTrader 5 terminal** installed on Windows
  29. - **MetaTrader 5 account** (demo or real)
  30. ## Usage
  31. ### Quick Start
  32. The server runs in **stdio mode** by default for MCP clients like Claude Desktop:
  33. ```bash
  34. uv run mt5mcp
  35. ```
  36. ### Development Mode (HTTP)
  37. For testing with HTTP transport, create a `.env` file:
  38. ```env
  39. MT5_MCP_TRANSPORT=http
  40. MT5_MCP_HOST=127.0.0.1
  41. MT5_MCP_PORT=8000
  42. ```
  43. Then run:
  44. ```bash
  45. uv run mt5mcp
  46. ```
  47. The server will start at http://127.0.0.1:8000
  48. ### Installing for MCP Clients
  49. #### Method 1: Using `uvx` (Simplest - No Installation Required) ⭐
  50. Add this configuration to your MCP client's config file:
  51. **For Claude Desktop** (`claude_desktop_config.json`):
  52. ```json
  53. {
  54. "mcpServers": {
  55. "mcp-metatrader5-server": {
  56. "command": "uvx",
  57. "args": [
  58. "--from",
  59. "git+https://github.com/Qoyyuum/mcp-metatrader5-server",
  60. "mt5mcp"
  61. ]
  62. }
  63. }
  64. }
  65. ```
  66. #### Method 2: Using FastMCP Install (Recommended)
  67. ```bash
  68. git clone https://github.com/Qoyyuum/mcp-metatrader5-server
  69. cd mcp-metatrader5-server
  70. ```
  71. After git cloning the repo, run the following commands:
  72. For MCP JSON format
  73. ```bash
  74. uv run fastmcp install mcp-json src/mcp_mt5/main.py
  75. ```
  76. For Claude Desktop
  77. ```bash
  78. uv run fastmcp install claude-desktop src/mcp_mt5/main.py
  79. ```
  80. For Claude Code
  81. ```bash
  82. uv run fastmcp install claude-code src/mcp_mt5/main.py
  83. ```
  84. For Cursor
  85. ```bash
  86. uv run fastmcp install cursor src/mcp_mt5/main.py
  87. ```
  88. For Gemini CLI
  89. ```bash
  90. uv run fastmcp install gemini-cli src/mcp_mt5/main.py
  91. ```
  92. #### Method 3: Manual Configuration
  93. Add this to your `claude_desktop_config.json` or whatever LLM config file:
  94. ```json
  95. {
  96. "mcpServers": {
  97. "mcp-metatrader5-server": {
  98. "command": "uvx",
  99. "args": [
  100. "--from",
  101. "mcp-metatrader5-server",
  102. "mt5mcp"
  103. ],
  104. "env": {
  105. "MT5_PATH": "C:\\Program Files\\MetaTrader 5\\terminal64.exe",
  106. "MT5_LOGIN": "<YOUR_ACCOUNT_NUMBER>",
  107. "MT5_PASSWORD": "<YOUR_PASSWORD>",
  108. "MT5_SERVER": "<YOUR_BROKER_SERVER>"
  109. }
  110. }
  111. }
  112. }
  113. ```
  114. The `env` block is optional. When it is set, `initialize()` and `login()` can be
  115. called without arguments and the agent never needs to see or ask for your
  116. credentials. Explicit arguments still take precedence. `MT5_USERNAME` is
  117. accepted as an alias for `MT5_LOGIN`.
  118. > **Security:** with credentials in the `env` block, the config file holds a
  119. > secret. Keep it out of git, shared backups and shared or synced folders.
  120. ## API Reference
  121. ### Connection Management
  122. - `initialize()`: Initialize the MT5 terminal
  123. - `login(account, password, server)`: Log in to a trading account
  124. - `shutdown()`: Close the connection to the MT5 terminal
  125. ### Market Data Functions
  126. - `get_symbols()`: Get all available symbols
  127. - `get_symbols_by_group(group)`: Get symbols by group
  128. - `get_symbol_info(symbol)`: Get information about a specific symbol
  129. - `get_symbol_info_tick(symbol)`: Get the latest tick for a symbol
  130. - `copy_rates_from_pos(symbol, timeframe, start_pos, count)`: Get bars from a specific position
  131. - `copy_rates_from_date(symbol, timeframe, date_from, count)`: Get bars from a specific date
  132. - `copy_rates_range(symbol, timeframe, date_from, date_to)`: Get bars within a date range
  133. - `copy_ticks_from_pos(symbol, start_pos, count)`: Get ticks from a specific position
  134. - `copy_ticks_from_date(symbol, date_from, count)`: Get ticks from a specific date
  135. - `copy_ticks_range(symbol, date_from, date_to)`: Get ticks within a date range
  136. ### Trading Functions
  137. - `order_send(request)`: Send an order to the trade server
  138. - `order_check(request)`: Check if an order can be placed with the specified parameters
  139. - `positions_get(symbol, group)`: Get open positions
  140. - `positions_get_by_ticket(ticket)`: Get an open position by its ticket
  141. - `orders_get(symbol, group)`: Get active orders
  142. - `orders_get_by_ticket(ticket)`: Get an active order by its ticket
  143. - `history_orders_get(symbol, group, ticket, position, from_date, to_date)`: Get orders from history
  144. - `history_deals_get(symbol, group, ticket, position, from_date, to_date)`: Get deals from history
  145. ## Example Workflows
  146. ### Connecting and Getting Market Data
  147. ```python
  148. # Initialize MT5
  149. initialize()
  150. # Log in to your trading account
  151. login(account=123456, password="your_password", server="your_server")
  152. # Get available symbols
  153. symbols = get_symbols()
  154. # Get recent price data for EURUSD
  155. rates = copy_rates_from_pos(symbol="EURUSD", timeframe=15, start_pos=0, count=100)
  156. # Shut down the connection
  157. shutdown()
  158. ```
  159. ### Placing a Trade
  160. ```python
  161. # Initialize and log in
  162. initialize()
  163. login(account=123456, password="your_password", server="your_server")
  164. # Create an order request
  165. request = OrderRequest(
  166. action=mt5.TRADE_ACTION_DEAL,
  167. symbol="EURUSD",
  168. volume=0.1,
  169. type=mt5.ORDER_TYPE_BUY,
  170. price=mt5.symbol_info_tick("EURUSD").ask,
  171. deviation=20,
  172. magic=123456,
  173. comment="Buy order",
  174. type_time=mt5.ORDER_TIME_GTC,
  175. type_filling=mt5.ORDER_FILLING_IOC
  176. )
  177. # Send the order
  178. result = order_send(request)
  179. # Shut down the connection
  180. shutdown()
  181. ```
  182. ## Resources
  183. The server provides the following resources to help AI assistants understand how to use the MetaTrader 5 API:
  184. - `mt5://getting_started`: Basic workflow for using the MetaTrader 5 API
  185. - `mt5://trading_guide`: Guide for placing and managing trades
  186. - `mt5://market_data_guide`: Guide for accessing and analyzing market data
  187. - `mt5://order_types`: Information about order types
  188. - `mt5://order_filling_types`: Information about order filling types
  189. - `mt5://order_time_types`: Information about order time types
  190. - `mt5://trade_actions`: Information about trade request actions
  191. ## Prompts
  192. The server provides the following prompts to help AI assistants interact with users:
  193. - `connect_to_mt5(account, password, server)`: Connect to MetaTrader 5 and log in
  194. - `analyze_market_data(symbol, timeframe)`: Analyze market data for a specific symbol
  195. - `place_trade(symbol, order_type, volume)`: Place a trade for a specific symbol
  196. - `manage_positions()`: Manage open positions
  197. - `analyze_trading_history(days)`: Analyze trading history
  198. ## Development
  199. ### Project Structure
  200. ```
  201. mcp-metatrader5-server/
  202. ├── src/
  203. │ └── mcp_mt5/
  204. │ ├── __init__.py # Entry point with main()
  205. │ ├── main.py # FastMCP server with all tools
  206. │ └── test_client.py # Test client for development
  207. ├── docs/
  208. │ ├── getting_started.md
  209. │ ├── market_data_guide.md
  210. │ ├── trading_guide.md
  211. │ └── publishing.md
  212. ├── .env # Environment configuration (create from .env.example)
  213. ├── README.md
  214. ├── pyproject.toml # Project metadata (using hatchling)
  215. └── uv.lock # Dependency lock file
  216. ```
  217. ### Building the Package
  218. Using uv (recommended):
  219. ```bash
  220. uv build
  221. ```
  222. This will create wheel and source distributions in the `dist/` directory.
  223. ### Publishing to PyPI
  224. Using uv:
  225. ```bash
  226. # Build first
  227. uv build
  228. # Publish to PyPI
  229. uv publish
  230. # Or publish to TestPyPI first
  231. uv publish --publish-url https://test.pypi.org/legacy/
  232. ```
  233. ## License
  234. MIT
  235. ## Acknowledgements
  236. - [MetaQuotes](https://www.metaquotes.net/) for the MetaTrader 5 platform
  237. - [FastMCP](https://github.com/jlowin/fastmcp) for the MCP server implementation

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.