XTBApi服务器
这是一个 MCP 服务器,使用@sharplygroup/xtb-api-js
库公开 XTB API。它允许您通过模型上下文协议 (MCP) 与您的 XTB 交易账户进行交互。
先决条件
Node.js(版本 16 或更高版本)
npm
XTB交易账户
安装
克隆此存储库:git clone [repository_url]
导航到项目目录:cd xtb-mcp-server
安装依赖项:npm install
配置
在项目目录中创建一个
.env
文件并添加您的 XTB API 凭证:
**注意:**请将your_user_id
和your_password
替换为您的实际 XTB API 凭证。如果您使用的是真实账户,请将DEMO_ACCOUNT
设置为false
。
运行服务器
构建 TypeScript 代码:npm run build
运行服务器:node build/index.js
连接 MCP 客户端
您可以使用任何 MCP 客户端(例如 MCP Inspector)连接到此服务器。
全局安装 MCP Inspector:npm install -g @modelcontextprotocol/inspector
使用您的服务器运行 MCP Inspector:npx @modelcontextprotocol/inspector node build/index.js
在 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 及其潜在风险。
This server cannot be installed
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.
公开 XTB 交易 API 的 MCP 服务器,允许用户通过模型上下文协议与其 XTB 交易账户进行交互,以执行账户管理、市场数据检索和交易执行等操作。
Related Resources
Related MCP Servers
- -securityAlicense-qualityMCP Server provides a simpler API to interact with the Model Context Protocol by allowing users to define custom tools and services to streamline workflows and processes.Last updated -73MIT License
- -securityFlicense-qualityA Model Context Protocol (MCP) server providing comprehensive access to the XRP Ledger (XRPL). This service enables AI models to interact with XRPL through standardized endpoints.Last updated -3
- AsecurityAlicenseAqualityA Model Context Protocol (MCP) server implementation that provides EMQX MQTT broker interaction.Last updated -420Apache 2.0
- AsecurityAlicenseAqualityAn MCP server that integrates the XTQuant quantitative trading platform with AI assistants, allowing AI to directly access and operate on trading data and functionality.Last updated -896MIT License