XTBApiServer

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Enables configuration of the XTB API credentials through a .env file, supporting both demo and live trading account setups.

  • Supports installation via Git repository cloning.

  • Provides the runtime environment for the XTB API server, requiring version 16 or higher for proper operation.

XTBApi服务器

这是一个 MCP 服务器,使用@sharplygroup/xtb-api-js库公开 XTB API。它允许您通过模型上下文协议 (MCP) 与您的 XTB 交易账户进行交互。

先决条件

  • Node.js(版本 16 或更高版本)
  • npm
  • XTB交易账户

安装

  1. 克隆此存储库:git clone [repository_url]
  2. 导航到项目目录:cd xtb-mcp-server
  3. 安装依赖项:npm install

配置

  1. 在项目目录中创建一个.env文件并添加您的 XTB API 凭证:
DEMO_ACCOUNT=true USER_ID=your_user_id PASSWORD=your_password

**注意:**请将your_user_idyour_password替换为您的实际 XTB API 凭证。如果您使用的是真实账户,请将DEMO_ACCOUNT设置为false

运行服务器

  1. 构建 TypeScript 代码:npm run build
  2. 运行服务器:node build/index.js

连接 MCP 客户端

您可以使用任何 MCP 客户端(例如 MCP Inspector)连接到此服务器。

  1. 全局安装 MCP Inspector:npm install -g @modelcontextprotocol/inspector
  2. 使用您的服务器运行 MCP Inspector:npx @modelcontextprotocol/inspector node build/index.js
  3. 在 MCP Inspector UI 中,选择“stdio”作为传输类型,然后单击“连接”。

可用工具

该 MCP 服务器公开了以下工具:

账户操作

  • getCurrentUserData :返回有关账户货币和账户杠杆的信息。
  • getMarginLevel :返回各种账户指标。

计算运算

  • getCommissionDef :返回佣金和汇率的计算。
    • 参数: symbol (字符串)、 volume (数字)
  • getMarginTrade :返回给定工具和交易量的预期保证金。
    • 参数: symbol (字符串)、 volume (数字)
  • getProfitCalculation :计算给定交易数据的预计利润。
    • 参数: closePrice (数字)、 cmd (数字)、 openPrice (数字)、 symbol (字符串)、 volume (数字)

市场数据操作

  • getCalendar :返回包含市场事件的日历。
  • getChartLastRequest :返回图表信息,从开始日期到当前时间。
    • 参数: info (任意)
  • getChartRangeRequest :返回给定开始日期和结束日期之间的数据图表信息。
    • 参数: info (任意)
  • getTickPrices :返回给定符号的当前报价数组,仅返回自给定时间戳发生变化的报价。
    • 参数: level (数字)、 symbols (字符串[])、 timestamp (数字)
  • getTradingHours :返回报价和交易时间。
    • 参数: symbols (string[])

新闻运营

  • getNews :返回交易服务器在指定时间段内发送的新闻。
    • 参数: end (数字), start (数字)

服务器操作

  • getServerTime :返回交易服务器的当前时间。
  • getVersion :返回当前 API 版本。
  • ping :定期调用此函数足以刷新系统中所有组件的内部状态。

符号操作

  • getAllSymbols :返回用户可用的所有符号的数组。
  • getSymbol :返回有关用户可用的符号的信息。
    • 参数: symbol (字符串)

贸易业务

  • getTrades :返回用户交易的数组。
    • 参数: openedOnly (布尔值)
  • getTradeRecords :返回orders参数中列出的交易数组。
    • 参数: orders (number[])
  • getTradesHistory :返回在指定时间段内关闭的用户交易数组。
    • 参数: end (数字), start (数字)
  • getTradeStatus :返回当前交易状态。
    • 参数: order (数量)

交易业务

  • tradeTransaction :开始贸易交易。
    • 参数: tradeTransInfo (任意)
  • tradeTransactionStatus :返回当前交易状态。
    • 参数: order (数量)

命令执行

  • executeCommand :在服务器上执行命令。
    • 参数: command (字符串)

提示

有以下提示可用:

  • getAccountDataPrompt :获取当前账户数据。
  • getSymbolInfoPrompt :获取有关特定符号的信息。
    • 参数: symbol (字符串)

免责声明

此 MCP 服务器仅供参考,使用风险自负。在将此服务器用于真实交易账户之前,请确保您了解 XTB API 及其潜在风险。

-
security - not tested
F
license - not found
-
quality - not tested

公开 XTB 交易 API 的 MCP 服务器,允许用户通过模型上下文协议与其 XTB 交易账户进行交互,以执行账户管理、市场数据检索和交易执行等操作。

  1. Prerequisites
    1. Installation
      1. Configuration
        1. Running the Server
          1. Connecting with an MCP Client
            1. Available Tools
              1. Account Operations
              2. Calculation Operations
              3. Market Data Operations
              4. News Operations
              5. Server Operations
              6. Symbol Operations
              7. Trade Operations
              8. Trading Operations
              9. Command Execution
            2. Prompts
              1. Disclaimer
                ID: 4pw9haj5up