SuperAPIAI Directory

metatrader-mcp-server

github.com · AI developer platforms

Execute trades on the MetaTrader 5 platform.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsAPI

About this tool

MetaTrader MCP Server is an open-source project designed to connect AI assistants (such as Claude, ChatGPT) with the MetaTrader 5 trading platform through the Model Context Protocol (MCP), enabling users to perform trading operations using natural language. The project is developed in Python and requires Python 3.10 or higher and the MetaTrader 5 terminal.

Purpose This project is mainly aimed at individual traders who want to use AI to automate trading, developers building trading bots or analysis tools, analysts who need quick access to market data, and anyone interested in combining AI with financial markets.

Main Capabilities

  • Natural Language Trading: Users can use simple English instructions to have the AI execute trades, such as "show my account balance", "buy 0.01 lots of EUR/USD", "close all profitable positions".
  • Multi-AI Support: Compatible with Claude Desktop, ChatGPT (via Open WebUI), etc.
  • Full Market Access: Get real-time prices, historical data, and trading symbol information.
  • Account Control: Query balance, equity, margin, and trading statistics.
  • Order Management: Place, modify, and close orders.
  • Security: All credentials remain on the user's local machine.
  • Flexible Interface: Can be used as an MCP server, REST API, or WebSocket stream.
  • Built-in Trading Assistant Skill: Includes a Trading Terminal Assistant skill that provides structured knowledge of 32 trading tools, output formats, and MetaTrader 5 domain expertise.

Usage

  1. Installation: Install the package via pip pip install metatrader-mcp-server.
  2. Enable Algorithmic Trading: In MetaTrader 5, go to Tools → Options → Expert Advisors, and check "Allow algorithmic trading".
  3. Configure the AI Client: For Claude Desktop, edit the configuration file (Windows: %APPDATA%\Claude\claude_desktop_config.json,Mac: ~/Library/Application Support/Claude/claude_desktop_config.json), add the MCP server configuration, and fill in the MT5 login number, password, and server name.
  4. Run as an HTTP Server: After starting the HTTP server, you can visit http://localhost:8000/docs in a browser to view the API documentation, and add the tool server in Open WebUI.
  5. WebSocket Quote Server: You can start a WebSocket server to stream tick data in real time (bid price, ask price, spread, volume), with the default address ws://0.0.0.0:8765.
  6. Remote Connection: You can run the MCP server on a Windows VPS and connect remotely from Claude Desktop via SSE.
  7. Install Skills: You can install the skills in the claude-skill/ directory to Claude Code or Claude Desktop, and invoke them via /trading .

Available Operations

  • Account Management: get_account_info, get_symbols, get_symbol_price, get_candles_latest, get_candles_by_date, get_symbol_info
  • Order Execution: place_market_order, place_pending_order, modify_position, modify_pending_order
  • Position Management: get_all_positions, get_positions_by_symbol, get_positions_by_id, close_position, close_all_positions, close_all_positions_by_symbol, close_all_profitable_positions, close_all_losing_positions, etc.
  • Trading History: get_deals, get_orders

Applicable Scenarios

  • Natural language trading through an AI assistant
  • Developing trading bots or analysis tools
  • Real-time monitoring of market data
  • Remote management of trading accounts

Limitations

  • Requires Python 3.10+ and the MetaTrader 5 terminal.
  • Trading involves significant risk; the software is provided "as is", and the developers assume no responsibility for any trading losses.
  • The MCP protocol does not include authentication; when exposing the SSE server, use a firewall, reverse proxy, or SSH tunnel.
  • Project version 0.5.1, under active development.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools