metatrader-mcp-server-linux

metatrader-mcp-server-linux

Enables AI assistants to trade on MetaTrader 5 on Linux by bridging the Windows-only MetaTrader5 package through Wine.

Category
访问服务器

README

<div align="center"> <h1>MetaTrader MCP Server — Linux Edition</h1> <p><strong>Use AI assistants (Claude Code, Ollama) to trade on MetaTrader 5 — on Linux</strong></p> </div>

<br />

<div align="center">

Python 3.10+ License: MIT Platform: Linux

</div>

<br />


Why This Exists

Claude Desktop — the simplest way to connect MCP servers on Windows and Mac — is not available on Linux.

This repo makes MetaTrader MCP work on Linux by bridging the Windows-only MetaTrader5 Python package through Wine using mt5linux. Once set up, you can use:

  • Claude Code (Anthropic's CLI) — fully confirmed working
  • Ollama local LLMs (qwen2.5:7b-instruct, qwen3-8b-instruct, etc.) — fully confirmed working
  • Any other MCP-compatible client

Credits

This project is built on the shoulders of two open source projects:

  • ariadng/metatrader-mcp-server by @ariadng — the original MCP server implementation. All the core trading logic, MCP tools, and server architecture come from his work. Go star his repo.

  • lucas-campagna/mt5linux by @lucas-campagna — the RPyC bridge that makes it possible to run the MetaTrader5 Python package on Linux via Wine. Without this, none of this would work on Linux.

What we added: the Linux compatibility patches, the mt5linux shim, the start.sh wrapper, and this documentation.


⚠️ Important Disclaimer

Trading financial instruments involves significant risk of loss. This software is provided as-is, and the developers accept no liability for any trading losses, gains, or consequences of using this software. This is not financial advice. Always trade responsibly.


How It Works

Claude Code  ──────────────────────┐
                                   │  stdio
Ollama (Gemma4, gpt-oss, etc.)  ───┤
                                   ↓
              metatrader-mcp-server  (native Linux Python)
                                   ↓  RPyC over TCP :18812
              mt5linux bridge  (Windows Python inside Wine)
                                   ↓  Windows IPC
              MetaTrader 5 terminal  (Wine)

Quick Start

See the full step-by-step guide: LINUX_SETUP.md

It covers everything from installing Windows Python inside Wine to registering the MCP server with Claude Code or Ollama — including all the gotchas we ran into.

The short version:

# 1. Install Windows Python 3.10 inside your MT5 Wine prefix
WINEPREFIX=~/.mt5 wine python-3.10.11-amd64.exe /quiet InstallAllUsers=0 PrependPath=1

# 2. Install MetaTrader5 + mt5linux inside Wine Python
WINEPREFIX=~/.mt5 wine python -m pip install MetaTrader5 mt5linux "numpy<2.0"

# 3. Install mt5linux on native Linux Python
pip install mt5linux

# 4. Clone and install this repo
git clone https://github.com/ESSIEM1/metatrader-mcp-server-linux.git
cd metatrader-mcp-server-linux
pip install -e .

# 5. Edit start.sh with your credentials, then register with Claude Code
claude mcp add --transport stdio metatrader -- /home/$USER/metatrader-mcp-server-linux/start.sh

Features

Everything from the original ariadng/metatrader-mcp-server, plus Linux support:

  • 25 MCP tools — account info, market data, order execution, position management, trading history
  • Natural language trading — "Buy 0.01 lots of EURUSD" or "Close all losing positions"
  • Claude Code — works via stdio MCP transport
  • Ollama local LLMs — confirmed working with Gemma4, gpt-oss, qwen3.5:9b, llama3.1:8b
  • SSE/HTTP transport — for remote or Ollama connections
  • WebSocket quote server — real-time tick streaming

Available Tools

Account

  • get_account_info — balance, equity, margin, leverage

Market Data

  • get_symbols, get_symbol_price, get_symbol_info
  • get_candles_latest, get_candles_by_date

Orders

  • place_market_order, place_pending_order
  • modify_position, modify_pending_order

Positions

  • get_all_positions, close_position, close_all_positions
  • close_all_profitable_positions, close_all_losing_positions

Pending Orders

  • get_all_pending_orders, cancel_pending_order, cancel_all_pending_orders

History

  • get_deals, get_orders

Ollama Support

Confirmed working models:

Model Tool use Notes
qwen2.5:7b-instruct ✅ confirmed Recommended — fast, reliable tool use
qcwind/qwen3-8b-instruct-Q4-K-M ✅ confirmed Good for trading logic — more agentic behavior
qwen3.5:9b ⚠️ Fast, lightweight
llama3.1:8b ⚠️ Decent tool support — sometimes forgets tools
deepseek-r1:14b ⚠️ Reasoning model — tool support varies

See LINUX_SETUP.md for Ollama setup instructions.


IMPOTANT RUNNING INFORMATION

  1. Make sure you run claude code or ollama launch claude inside the folder:

~/metatrader-mcp-server-linux

(or ~/metatrader-mcp-server if you have modified the original MCP from Aria Dhanang and manually added our LINUX_SETUP.md patches.)

Failing to do so will result in the MCP server and tools being unavailable to Claude or local LLMs.

  1. Many small llms are not able to find the mcp tools. Make sure you use an "Instruct" model such as "qwen2.5:7b-instruct" or "qcwind/qwen3-8b-instruct-Q4-K-M", both tested and confirmed working and available at https://ollama.com/

  2. Running ollama launch claude should automatically run the script, opening and connecting to MT5. If your model is not communicating with MT5, make sure MT5 is open or run the script manually: ~/metatrader-mcp-server/start.sh in a different terminal tab.


Launching

a) Using Claude CLI

cd ~/metatrader-mcp-server-linux claude

Then inside the CLI:

Using the metatrader-mcp-server tools, give me the account balance.

B) Using Ollama

cd ~/metatrader-mcp-server-linux ollama launch claude

Then:

Select model: qwen2.5:7b-instruct Enter prompt: Using the metatrader-mcp-server tools, give me the account balance.


Tested Environment

Component Version
OS Debian 13 Trixie
Kernel Linux 6.12.88+deb13-amd64
Wine 10.0
MT5 build 5833
Windows Python (Wine) 3.10.11
Linux Python 3.11.9
MetaTrader5 package 5.0.5735
Claude Code v2.1.153
Ollama + qwen2.5:7b-instruct and qwen3-8b-instruct-Q4-K-M confirmed working
CPU: AMD EPYC 7551P 32-Core (64)
GPU: NVIDIA RTX 3060 12GB
MEMORY: 256GB 2667 ECC

License

MIT — same as the original project. See LICENSE.


<div align="center">

Linux patches by ESSIEM1

Original MCP server by Aria Dhanang • mt5linux bridge by Lucas Campagna

⭐ If this helped you, star the original repos too!

</div>

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选