MCP Tools Reference¶
This page documents all tools exposed by the TradeServer MCP server. Tools marked with No auth can be called without an API key.
System¶
health_check¶
Verifies connectivity and validates credentials. Returns ok on success.
No parameters.
HaasScript Management¶
list_scripts¶
Returns all HaasScript records for the authenticated user. Each item includes id, name, type, and dependency info. Covers Lua, Visual, and Command script types.
No parameters.
get_script¶
Returns a single full HaasScript record including source code and compile result.
| Parameter | Type | Required | Description |
|---|---|---|---|
scriptid |
string | Yes | Script ID hash |
add_script¶
Creates a new HaasScript. Returns the created script record.
| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Script name |
description |
string | No | Script description |
script |
string | Yes | Lua source code (may be base64+gzip compressed) |
type |
string | Yes | Script type: Lua, Visual, or Command |
edit_script_source¶
Replaces the source code of an existing HaasScript and recompiles it.
| Parameter | Type | Required | Description |
|---|---|---|---|
scriptid |
string | Yes | Script ID hash |
sourcecode |
string | Yes | New Lua source code |
settings |
object | No | HaasScriptSettings JSON (accountId, marketTag, interval, etc.) |
compile_script¶
Compiles a HaasScript without saving it. Returns the compile result including errors and discovered input fields. No auth required.
| Parameter | Type | Required | Description |
|---|---|---|---|
sourcecode |
string | Yes | Lua source code to compile |
scripttype |
string | No | Script type: Lua (default) or Visual |
delete_script¶
Permanently deletes a HaasScript. Returns true on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
scriptid |
string | Yes | Script ID hash |
Backtest Execution¶
execute_backtest¶
Runs a backtest for a HaasScript over a specified time range. Returns a backtestId string on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
backtestid |
string | Yes | Unique backtest ID (generate a new hash) |
scriptid |
string | Yes | Script ID to backtest |
settings |
object | Yes | HaasScriptSettings JSON |
startunix |
integer | Yes | Backtest start time (Unix timestamp, seconds) |
endunix |
integer | Yes | Backtest end time (Unix timestamp, seconds) |
get_backtest_status¶
Returns real-time execution status for a running backtest.
| Parameter | Type | Required | Description |
|---|---|---|---|
serviceid |
string | Yes | Service ID returned when the backtest was started |
backtestid |
string | Yes | Backtest ID |
get_backtest_info¶
Returns summary information for a completed backtest (profit, ROI, timestamps).
| Parameter | Type | Required | Description |
|---|---|---|---|
backtestid |
string | Yes | Backtest ID |
get_backtest_runtime¶
Returns the full runtime state of a completed backtest including trade reports and positions.
| Parameter | Type | Required | Description |
|---|---|---|---|
backtestid |
string | Yes | Backtest ID |
get_backtest_logs¶
Returns the execution log lines for a backtest.
| Parameter | Type | Required | Description |
|---|---|---|---|
backtestid |
string | Yes | Backtest ID |
get_backtest_positions¶
Returns a paginated list of trade positions from a completed backtest.
| Parameter | Type | Required | Description |
|---|---|---|---|
backtestid |
string | Yes | Backtest ID |
nextpageid |
integer | Yes | Pagination cursor (0 for first page) |
pagelength |
integer | Yes | Results per page |
get_backtest_history¶
Returns a paginated list of all stored backtest results.
| Parameter | Type | Required | Description |
|---|---|---|---|
nextpageid |
integer | Yes | Pagination cursor (0 for first page) |
pagelength |
integer | Yes | Results per page |
list_active_backtests¶
Returns all currently running backtest executions for the authenticated user.
No parameters.
is_script_executing¶
Returns the current execution state for a script (whether a backtest is running).
| Parameter | Type | Required | Description |
|---|---|---|---|
scriptid |
string | Yes | Script ID to check |
cancel_backtest¶
Cancels a currently running backtest. Returns true on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
backtestid |
string | Yes | Backtest ID to cancel |
serviceid |
string | Yes | Service ID returned when the backtest was started |
delete_backtest¶
Permanently deletes a stored backtest result. Returns true on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
backtestid |
string | Yes | Backtest ID to delete |
Trading Bots¶
list_bots¶
Returns all trading bots for the authenticated user.
No parameters.
get_bot¶
Returns a single bot by ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
botid |
string | Yes | Bot ID hash |
get_bot_runtime¶
Returns the current runtime state of a bot including open positions and orders.
| Parameter | Type | Required | Description |
|---|---|---|---|
botid |
string | Yes | Bot ID hash |
get_bot_report¶
Returns the performance report for a bot (Sharpe ratio, win rate, profit factor, etc.).
| Parameter | Type | Required | Description |
|---|---|---|---|
botid |
string | Yes | Bot ID hash |
get_bot_open_orders¶
Returns the currently open orders for a bot.
| Parameter | Type | Required | Description |
|---|---|---|---|
botid |
string | Yes | Bot ID hash |
get_bot_positions¶
Returns open or closed positions for a bot. Closed positions are paginated.
| Parameter | Type | Required | Description |
|---|---|---|---|
botid |
string | Yes | Bot ID hash |
status |
string | No | open (default) or closed |
nextpageid |
integer | No | Pagination cursor for closed positions (default 0) |
pagelength |
integer | No | Page size for closed positions (default 50) |
get_bot_logs¶
Returns a paginated log of bot messages.
| Parameter | Type | Required | Description |
|---|---|---|---|
botid |
string | Yes | Bot ID hash |
nextpageid |
integer | Yes | Pagination cursor (0 for first page) |
pagelength |
integer | Yes | Log lines per page |
offset |
integer | No | Line offset within the page |
get_bot_profits¶
Returns profit history for all bots over a time period.
| Parameter | Type | Required | Description |
|---|---|---|---|
startdate |
integer | Yes | Period start (Unix timestamp, seconds) |
enddate |
integer | Yes | Period end (Unix timestamp, seconds) |
Exchange Accounts¶
list_accounts¶
Returns all exchange accounts (real and simulated) for the authenticated user.
No parameters.
Labs (Parameter Optimization)¶
Labs let you run automated parameter-space searches across a HaasScript to find optimal settings.
list_labs¶
Returns all lab records for the authenticated user.
No parameters.
create_lab¶
Creates a new lab for running parameter-space simulations on a HaasScript.
| Parameter | Type | Required | Description |
|---|---|---|---|
scriptid |
string | Yes | Script ID to use for the lab |
name |
string | Yes | Lab name |
accountid |
string | Yes | Exchange account ID |
market |
string | Yes | Market tag (e.g. BINANCE_BTC_USDT_) |
interval |
integer | Yes | Candle interval in minutes |
style |
integer | Yes | Chart price plot style enum value |
clone_lab¶
Clones an existing lab record. Returns the new lab record.
| Parameter | Type | Required | Description |
|---|---|---|---|
labid |
string | Yes | Lab ID to clone |
name |
string | No | Name for the cloned lab |
get_lab_details¶
Returns the full details of a lab record including configuration and parameters.
| Parameter | Type | Required | Description |
|---|---|---|---|
labid |
string | Yes | Lab ID |
update_lab¶
Updates a lab's configuration, settings, and parameter ranges.
| Parameter | Type | Required | Description |
|---|---|---|---|
labid |
string | Yes | Lab ID to update |
name |
string | Yes | Lab name |
type |
string | Yes | Algorithm type enum value (e.g. 0 = Random) |
config |
object | Yes | UserLabConfig JSON (maxBots, maxIterations, etc.) |
settings |
object | Yes | HaasScriptSettings JSON |
parameters |
array | Yes | List of UserLabParameter objects defining parameter search ranges |
start_lab_execution¶
Starts a lab execution over a time range.
| Parameter | Type | Required | Description |
|---|---|---|---|
labid |
string | Yes | Lab ID to execute |
startunix |
integer | Yes | Backtest start time (Unix timestamp, seconds) |
endunix |
integer | Yes | Backtest end time (Unix timestamp, seconds) |
sendemail |
boolean | No | Send email notification on completion |
get_lab_execution_status¶
Returns the current execution status of a running lab.
| Parameter | Type | Required | Description |
|---|---|---|---|
labid |
string | Yes | Lab ID |
get_lab_results¶
Returns a paginated list of backtest results for a lab.
| Parameter | Type | Required | Description |
|---|---|---|---|
labid |
string | Yes | Lab ID |
nextpageid |
integer | Yes | Pagination cursor (0 for first page) |
pagelength |
integer | Yes | Results per page |
cancel_lab_execution¶
Cancels a running lab execution.
| Parameter | Type | Required | Description |
|---|---|---|---|
labid |
string | Yes | Lab ID |
delete_lab¶
Permanently deletes a lab record. Returns true on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
labid |
string | Yes | Lab ID to delete |
Markets & Price Data¶
list_markets¶
Returns all available markets across all price sources. No auth required.
No parameters.
check_market_data¶
Returns tick data for a market over a time range. Useful for confirming data availability before running a backtest. No auth required.
| Parameter | Type | Required | Description |
|---|---|---|---|
market |
string | Yes | Market tag (e.g. BINANCE_BTC_USDT_) |
startunix |
integer | Yes | Start time (Unix timestamp, seconds) |
endunix |
integer | Yes | End time (Unix timestamp, seconds) |
interval |
integer | Yes | Candle interval in minutes |
sync_market_data¶
Triggers a data sync for a market. No auth required.
| Parameter | Type | Required | Description |
|---|---|---|---|
market |
string | Yes | Market tag (e.g. BINANCE_BTC_USDT_) |
Wallet & Portfolio¶
get_wallet¶
Returns the raw wallet (balances) for a single exchange account.
| Parameter | Type | Required | Description |
|---|---|---|---|
accountid |
string | Yes | Exchange account ID |
list_wallets¶
Returns raw wallets for all exchange accounts belonging to the authenticated user.
No parameters.
get_balance¶
Returns the balance for an account converted to a target currency.
| Parameter | Type | Required | Description |
|---|---|---|---|
accountid |
string | Yes | Exchange account ID |
currency |
string | Yes | Target currency (e.g. USDT) |
aggregatecurrencies |
boolean | Yes | Aggregate all currencies into a single total |
get_portfolio¶
Returns the full portfolio (holdings and value) across one or more accounts.
| Parameter | Type | Required | Description |
|---|---|---|---|
accountids |
string | Yes | Comma-separated account IDs, or empty string for all accounts |
coins |
string | Yes | Comma-separated coin list to include, or empty string for all |
currency |
string | Yes | Target currency for value conversion (e.g. USDT) |
timestamp |
integer | Yes | Unix timestamp for historical snapshot; use 0 for current value |