- Explore MCP Servers
- xtb-mcp-server
Xtb Mcp Server
What is Xtb Mcp Server
xtb-mcp-server is an MCP server that exposes the XTB API using the @sharplygroup/xtb-api-js library, enabling interaction with XTB trading accounts through the Model Context Protocol.
Use cases
Use cases include retrieving account information, executing trade transactions, calculating profits, accessing market data, and monitoring trading activities through automated scripts or applications.
How to use
To use xtb-mcp-server, clone the repository, install dependencies, configure your XTB API credentials in a .env file, build the TypeScript code, and run the server. Connect using any MCP client like MCP Inspector.
Key features
Key features include account operations (e.g., getCurrentUserData), calculation operations (e.g., getProfitCalculation), market data operations (e.g., getTickPrices), news operations (e.g., getNews), and various trade and server operations.
Where to use
xtb-mcp-server is primarily used in the financial trading sector, particularly for users of the XTB trading platform who wish to automate and manage their trading activities programmatically.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Xtb Mcp Server
xtb-mcp-server is an MCP server that exposes the XTB API using the @sharplygroup/xtb-api-js library, enabling interaction with XTB trading accounts through the Model Context Protocol.
Use cases
Use cases include retrieving account information, executing trade transactions, calculating profits, accessing market data, and monitoring trading activities through automated scripts or applications.
How to use
To use xtb-mcp-server, clone the repository, install dependencies, configure your XTB API credentials in a .env file, build the TypeScript code, and run the server. Connect using any MCP client like MCP Inspector.
Key features
Key features include account operations (e.g., getCurrentUserData), calculation operations (e.g., getProfitCalculation), market data operations (e.g., getTickPrices), news operations (e.g., getNews), and various trade and server operations.
Where to use
xtb-mcp-server is primarily used in the financial trading sector, particularly for users of the XTB trading platform who wish to automate and manage their trading activities programmatically.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
XTBApiServer
This is an MCP server that exposes the XTB API using the @sharplygroup/xtb-api-js library. It allows you to interact with your XTB trading account through the Model Context Protocol.
Prerequisites
- Node.js (version 16 or higher)
- npm
- An XTB trading account
Installation
- Clone this repository:
git clone [repository_url] - Navigate to the project directory:
cd xtb-mcp-server - Install dependencies:
npm install
Configuration
- Create a
.envfile in the project directory and add your XTB API credentials:
DEMO_ACCOUNT=true USER_ID=your_user_id PASSWORD=your_password
Note: Replace your_user_id and your_password with your actual XTB API credentials. Set DEMO_ACCOUNT to false if you are using a live account.
Running the Server
- Build the TypeScript code:
npm run build - Run the server:
node build/index.js
Connecting with an MCP Client
You can connect to this server using any MCP client, such as the MCP Inspector.
- Install the MCP Inspector globally:
npm install -g @modelcontextprotocol/inspector - Run the MCP Inspector with your server:
npx @modelcontextprotocol/inspector node build/index.js - In the MCP Inspector UI, select “stdio” as the transport type and click “Connect”.
Available Tools
The following tools are exposed by this MCP server:
Account Operations
- getCurrentUserData: Returns information about account currency and account leverage.
- getMarginLevel: Returns various account indicators.
Calculation Operations
- getCommissionDef: Returns calculation of commission and rate of exchange.
- Parameters:
symbol(string),volume(number)
- Parameters:
- getMarginTrade: Returns expected margin for given instrument and volume.
- Parameters:
symbol(string),volume(number)
- Parameters:
- getProfitCalculation: Calculates estimated profit for given deal data.
- Parameters:
closePrice(number),cmd(number),openPrice(number),symbol(string),volume(number)
- Parameters:
Market Data Operations
- getCalendar: Returns calendar with market events.
- getChartLastRequest: Returns chart info, from start date to the current time.
- Parameters:
info(any)
- Parameters:
- getChartRangeRequest: Returns chart info with data between given start and end dates.
- Parameters:
info(any)
- Parameters:
- getTickPrices: Returns array of current quotations for given symbols, only quotations that changed from given timestamp are returned.
- Parameters:
level(number),symbols(string[]),timestamp(number)
- Parameters:
- getTradingHours: Returns quotes and trading times.
- Parameters:
symbols(string[])
- Parameters:
News Operations
- getNews: Returns news from trading server which were sent within specified period of time.
- Parameters:
end(number),start(number)
- Parameters:
Server Operations
- getServerTime: Returns current time on trading server.
- getVersion: Returns the current API version.
- ping: Regularly calling this function is enough to refresh the internal state of all the components in the system.
Symbol Operations
- getAllSymbols: Returns an array of all symbols available for the user.
- getSymbol: Returns information about the symbol available for the user.
- Parameters:
symbol(string)
- Parameters:
Trade Operations
- getTrades: Returns an array of user’s trades.
- Parameters:
openedOnly(boolean)
- Parameters:
- getTradeRecords: Returns an array of trades listed in the
ordersargument.- Parameters:
orders(number[])
- Parameters:
- getTradesHistory: Returns an array of user’s trades which were closed within specified period of time.
- Parameters:
end(number),start(number)
- Parameters:
- getTradeStatus: Returns current transaction status.
- Parameters:
order(number)
- Parameters:
Trading Operations
- tradeTransaction: Starts a trade transaction.
- Parameters:
tradeTransInfo(any)
- Parameters:
- tradeTransactionStatus: Returns current transaction status.
- Parameters:
order(number)
- Parameters:
Command Execution
- executeCommand: Executes a command on the server.
- Parameters:
command(string)
- Parameters:
Prompts
The following prompts are available:
- getAccountDataPrompt: Get the current account data.
- getSymbolInfoPrompt: Get information about a specific symbol.
- Parameters:
symbol(string)
- Parameters:
Disclaimer
This MCP server is provided as an example and should be used at your own risk. Please ensure that you understand the XTB API and the potential risks involved before using this server with a live trading account.
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










