Skip to content

MCP Server

The XBTFX MCP Server exposes the full Trading API through the Model Context Protocol (MCP), allowing AI assistants to trade forex, crypto, metals, indices, stocks, and energies on your XBTFX MetaTrader 5 account.

npm: @xbtfx/mcp-trading | GitHub: XBTFX/xbtfx-mcp-server | Version: 1.1.0

Terminal window
claude mcp add xbtfx-trading -e XBTFX_API_KEY=xbtfx_live_your_key_here -- npx @xbtfx/mcp-trading

Add to claude_desktop_config.json:

{
"mcpServers": {
"xbtfx-trading": {
"command": "npx",
"args": ["@xbtfx/mcp-trading"],
"env": {
"XBTFX_API_KEY": "xbtfx_live_your_key_here"
}
}
}
}

See Supported Clients for Cursor, Windsurf, OpenAI Codex, and other clients.

ToolDescription
get_auth_statusCheck API key status, login, margin mode, permissions
get_accountBalance, equity, margin, free margin, P&L, leverage
get_positionsOpen positions with ticket, symbol, side, volume, prices, P&L
get_ordersPending limit/stop orders
get_historyDeal history by period or custom date range
get_symbolsAll 400+ tradeable instruments with bid/ask (large response, 2 weight)
get_symbolFull contract spec — digits, volume limits, spread, swaps, margins, sessions
get_quoteLive bid/ask for one or more symbols (max 20)
ToolDescription
tradeOpen a position (buy/sell) with optional SL/TP
close_positionClose a position (full or partial)
modify_positionUpdate SL/TP on an existing position
close_byClose against an opposite position (hedging accounts only)
reverse_positionClose and re-open in the opposite direction
close_allClose all open positions (10 weight)
close_symbolClose all positions for one symbol (10 weight)

The MCP server runs locally as a subprocess of your AI client. It connects to https://interface.xbtfx.com using your API key and translates MCP tool calls into REST API requests.

AI Client ←MCP→ xbtfx-mcp-server ←HTTPS→ interface.xbtfx.com ←bridge→ MT5

All trading tools support idempotency — the server auto-generates an Idempotency-Key header for each trade to prevent duplicates on retry.

You: What’s my account balance?

AI: calls get_account — Your balance is $988.00 with $888.00 free margin. Leverage is 1:1000. No open positions.

You: What’s the current EURUSD price?

AI: calls get_quote — EURUSD bid: 1.16638, ask: 1.16639, spread: 0.00001

You: Buy 0.01 lots of EURUSD with a 50 pip stop loss

AI: calls get_symbol then trade — Opened BUY 0.01 EURUSD. Retcode 10008 (placed). SL set at 1.14850.

See Configuration for environment variables and advanced setup.

github.com/XBTFX/xbtfx-mcp-server