MetaTrader 5 MCP Server logo

MetaTrader 5 MCP Server

Community
Qoyyuum

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.

PublisherQoyyuum
Repositorymcp-metatrader5-server
LanguagePython
Forks
53
Stars
136
Available tools
0
Transport typestdio
Categories
Licensenull
Links
  • Connect tools to AI workflows

    MetaTrader 5 MCP Server exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    136 stars and 53 forks from the linked repository.

Ask DeepWiki

MseeP.ai Security Assessment Badge

codecov

PyPI version

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

bash
uvx --from mcp-metatrader5-server mt5mcp

From Source

bash
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:

bash
uv run mt5mcp

Development Mode (HTTP)

For testing with HTTP transport, create a .env file:

env
MT5_MCP_TRANSPORT=http
MT5_MCP_HOST=127.0.0.1
MT5_MCP_PORT=8000

Then run:

bash
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):

json
{
  "mcpServers": {
    "mcp-metatrader5-server": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/Qoyyuum/mcp-metatrader5-server",
        "mt5mcp"
      ]
    }
  }
}

Method 2: Using FastMCP Install (Recommended)

bash
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

bash
uv run fastmcp install mcp-json src/mcp_mt5/main.py

For Claude Desktop

bash
uv run fastmcp install claude-desktop src/mcp_mt5/main.py

For Claude Code

bash
uv run fastmcp install claude-code src/mcp_mt5/main.py

For Cursor

bash
uv run fastmcp install cursor src/mcp_mt5/main.py

For Gemini CLI

bash
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:

json
{
  "mcpServers": {
    "mcp-metatrader5-server": {
      "command": "uvx",
      "args": [
        "--from",
        "mcp-metatrader5-server",
        "mt5mcp"
      ]
    }
  }
}

API Reference

Connection Management

  • initialize(): Initialize the MT5 terminal
  • login(account, password, server): Log in to a trading account
  • shutdown(): Close the connection to the MT5 terminal

Market Data Functions

  • get_symbols(): Get all available symbols
  • get_symbols_by_group(group): Get symbols by group
  • get_symbol_info(symbol): Get information about a specific symbol
  • get_symbol_info_tick(symbol): Get the latest tick for a symbol
  • copy_rates_from_pos(symbol, timeframe, start_pos, count): Get bars from a specific position
  • copy_rates_from_date(symbol, timeframe, date_from, count): Get bars from a specific date
  • copy_rates_range(symbol, timeframe, date_from, date_to): Get bars within a date range
  • copy_ticks_from_pos(symbol, start_pos, count): Get ticks from a specific position
  • copy_ticks_from_date(symbol, date_from, count): Get ticks from a specific date
  • copy_ticks_range(symbol, date_from, date_to): Get ticks within a date range

Trading Functions

  • order_send(request): Send an order to the trade server
  • order_check(request): Check if an order can be placed with the specified parameters
  • positions_get(symbol, group): Get open positions
  • positions_get_by_ticket(ticket): Get an open position by its ticket
  • orders_get(symbol, group): Get active orders
  • orders_get_by_ticket(ticket): Get an active order by its ticket
  • history_orders_get(symbol, group, ticket, position, from_date, to_date): Get orders from history
  • history_deals_get(symbol, group, ticket, position, from_date, to_date): Get deals from history

Example Workflows

Connecting and Getting Market Data

python
# 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

python
# 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 API
  • mt5://trading_guide: Guide for placing and managing trades
  • mt5://market_data_guide: Guide for accessing and analyzing market data
  • mt5://order_types: Information about order types
  • mt5://order_filling_types: Information about order filling types
  • mt5://order_time_types: Information about order time types
  • mt5://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 in
  • analyze_market_data(symbol, timeframe): Analyze market data for a specific symbol
  • place_trade(symbol, order_type, volume): Place a trade for a specific symbol
  • manage_positions(): Manage open positions
  • analyze_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):

bash
uv build

This will create wheel and source distributions in the dist/ directory.

Publishing to PyPI

Using uv:

bash
# 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

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "qoyyuum-mcp-metatrader5-server": {
      "command": "uvx",
      "args": [
        "mcp-metatrader5-server"
      ]
    }
  }
}

Use MetaTrader 5 MCP Server MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once MetaTrader 5 MCP Server is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add MetaTrader 5 MCP Server as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the MetaTrader 5 MCP Server MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "qoyyuum-mcp-metatrader5-server": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-metatrader5-server"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the MetaTrader 5 MCP Server MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the MetaTrader 5 MCP Server MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use MetaTrader 5 MCP Server to help me with this task?
MetaTrader 5 MCP Server
Sure. I read it.
Here is what I found using MetaTrader 5 MCP Server.

Frequently asked questions

What is the MetaTrader 5 MCP Server MCP server used for?

MetaTrader 5 MCP Server is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use MetaTrader 5 MCP Server MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use MetaTrader 5 MCP Server with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use MetaTrader 5 MCP Server MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With MetaTrader 5 MCP Server connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect MetaTrader 5 MCP Server MCP to TypingMind?

MetaTrader 5 MCP Server runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does MetaTrader 5 MCP Server MCP provide in TypingMind?

MetaTrader 5 MCP Server exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use MetaTrader 5 MCP Server MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If MetaTrader 5 MCP Server requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter šŸ‘‡