v1.30.0: Add 10 Wine/MT5 debugging tools
New debugging/diagnostics tools for crash investigation: - diagnose_wine: Check Wine installation and prefix health - get_mt5_logs: Get terminal/tester/metaeditor logs - search_mt5_errors: Search logs for error patterns - check_mt5_process: Check MT5 process status - kill_mt5_process: Kill stuck MT5 processes - check_system_resources: Check disk/memory/CPU - validate_mt5_config: Validate MT5 configuration - get_wine_prefix_info: Wine prefix details - get_backtest_crash_info: Investigate backtest failures Total tools: 85 Documentation updated in README.md and MCP_TOOLS.md
This commit is contained in:
@@ -126,3 +126,155 @@ pub fn tool_analyze_concurrent_peak() -> Value {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_list_deals() -> Value {
|
||||
json!({
|
||||
"name": "list_deals",
|
||||
"description": "List individual deals from a backtest report with optional filters",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["report_dir"],
|
||||
"properties": {
|
||||
"report_dir": { "type": "string", "description": "Path to report directory containing deals.csv" },
|
||||
"deal_type": { "type": "string", "enum": ["buy", "sell"], "description": "Filter by deal type" },
|
||||
"min_profit": { "type": "number", "description": "Minimum profit (use negative for losses)" },
|
||||
"max_profit": { "type": "number", "description": "Maximum profit" },
|
||||
"start_date": { "type": "string", "description": "Start date filter (YYYY.MM.DD)" },
|
||||
"end_date": { "type": "string", "description": "End date filter (YYYY.MM.DD)" },
|
||||
"min_volume": { "type": "number", "description": "Minimum volume/lots" },
|
||||
"max_volume": { "type": "number", "description": "Maximum volume/lots" },
|
||||
"limit": { "type": "integer", "default": 100, "description": "Max deals to return" }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_search_deals_by_comment() -> Value {
|
||||
json!({
|
||||
"name": "search_deals_by_comment",
|
||||
"description": "Search deals by comment text (case-insensitive partial match)",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["report_dir", "query"],
|
||||
"properties": {
|
||||
"report_dir": { "type": "string" },
|
||||
"query": { "type": "string", "description": "Search text in comments" },
|
||||
"limit": { "type": "integer", "default": 50 }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_search_deals_by_magic() -> Value {
|
||||
json!({
|
||||
"name": "search_deals_by_magic",
|
||||
"description": "Filter deals by magic number (EA identifier)",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["report_dir", "magic"],
|
||||
"properties": {
|
||||
"report_dir": { "type": "string" },
|
||||
"magic": { "type": "string", "description": "Magic number to filter by" },
|
||||
"limit": { "type": "integer", "default": 100 }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_analyze_profit_distribution() -> Value {
|
||||
json!({
|
||||
"name": "analyze_profit_distribution",
|
||||
"description": "Analyze profit distribution - small/medium/large wins and losses with detailed buckets",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["report_dir"],
|
||||
"properties": {
|
||||
"report_dir": { "type": "string" }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_analyze_time_performance() -> Value {
|
||||
json!({
|
||||
"name": "analyze_time_performance",
|
||||
"description": "Analyze performance by hour of day and day of week",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["report_dir"],
|
||||
"properties": {
|
||||
"report_dir": { "type": "string" }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_analyze_hold_time_distribution() -> Value {
|
||||
json!({
|
||||
"name": "analyze_hold_time_distribution",
|
||||
"description": "Analyze hold time distribution and correlation with profit",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["report_dir"],
|
||||
"properties": {
|
||||
"report_dir": { "type": "string" }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_analyze_layer_performance() -> Value {
|
||||
json!({
|
||||
"name": "analyze_layer_performance",
|
||||
"description": "Analyze performance by grid layer (extracted from deal comments)",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["report_dir"],
|
||||
"properties": {
|
||||
"report_dir": { "type": "string" }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_analyze_volume_vs_profit() -> Value {
|
||||
json!({
|
||||
"name": "analyze_volume_vs_profit",
|
||||
"description": "Analyze correlation between volume and profit, plus performance by volume bucket",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["report_dir"],
|
||||
"properties": {
|
||||
"report_dir": { "type": "string" }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_analyze_costs() -> Value {
|
||||
json!({
|
||||
"name": "analyze_costs",
|
||||
"description": "Analyze commission and swap costs impact on profitability",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["report_dir"],
|
||||
"properties": {
|
||||
"report_dir": { "type": "string" }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_analyze_efficiency() -> Value {
|
||||
json!({
|
||||
"name": "analyze_efficiency",
|
||||
"description": "Calculate efficiency metrics: profit per hour/day, annualized return, trade frequency",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["report_dir"],
|
||||
"properties": {
|
||||
"report_dir": { "type": "string" }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ pub fn get_tools_list() -> Value {
|
||||
optimization::tool_get_optimization_status(),
|
||||
optimization::tool_get_optimization_results(),
|
||||
optimization::tool_list_jobs(),
|
||||
// Analytics (9 tools)
|
||||
// Analytics (19 tools)
|
||||
analytics::tool_analyze_report(),
|
||||
analytics::tool_analyze_monthly_pnl(),
|
||||
analytics::tool_analyze_drawdown_events(),
|
||||
@@ -32,6 +32,17 @@ pub fn get_tools_list() -> Value {
|
||||
analytics::tool_analyze_direction_bias(),
|
||||
analytics::tool_analyze_streaks(),
|
||||
analytics::tool_analyze_concurrent_peak(),
|
||||
// Deal query tools (10)
|
||||
analytics::tool_list_deals(),
|
||||
analytics::tool_search_deals_by_comment(),
|
||||
analytics::tool_search_deals_by_magic(),
|
||||
analytics::tool_analyze_profit_distribution(),
|
||||
analytics::tool_analyze_time_performance(),
|
||||
analytics::tool_analyze_hold_time_distribution(),
|
||||
analytics::tool_analyze_layer_performance(),
|
||||
analytics::tool_analyze_volume_vs_profit(),
|
||||
analytics::tool_analyze_costs(),
|
||||
analytics::tool_analyze_efficiency(),
|
||||
// Baseline
|
||||
baseline::tool_compare_baseline(),
|
||||
// Experts
|
||||
@@ -58,6 +69,16 @@ pub fn get_tools_list() -> Value {
|
||||
utility::tool_check_mt5_status(),
|
||||
utility::tool_create_set_template(),
|
||||
utility::tool_export_report(),
|
||||
// Debugging/Diagnostics (10 tools)
|
||||
utility::tool_diagnose_wine(),
|
||||
utility::tool_get_mt5_logs(),
|
||||
utility::tool_search_mt5_errors(),
|
||||
utility::tool_check_mt5_process(),
|
||||
utility::tool_kill_mt5_process(),
|
||||
utility::tool_check_system_resources(),
|
||||
utility::tool_validate_mt5_config(),
|
||||
utility::tool_get_wine_prefix_info(),
|
||||
utility::tool_get_backtest_crash_info(),
|
||||
// Set Files
|
||||
setfiles::tool_read_set_file(),
|
||||
setfiles::tool_write_set_file(),
|
||||
@@ -67,7 +88,7 @@ pub fn get_tools_list() -> Value {
|
||||
setfiles::tool_describe_sweep(),
|
||||
setfiles::tool_list_set_files(),
|
||||
setfiles::tool_set_from_optimization(),
|
||||
// Reports (11 tools)
|
||||
// Reports (19 tools)
|
||||
reports::tool_list_reports(),
|
||||
reports::tool_search_reports(),
|
||||
reports::tool_get_latest_report(),
|
||||
@@ -78,6 +99,14 @@ pub fn get_tools_list() -> Value {
|
||||
reports::tool_get_history(),
|
||||
reports::tool_promote_to_baseline(),
|
||||
reports::tool_annotate_history(),
|
||||
reports::tool_get_report_by_id(),
|
||||
reports::tool_get_reports_summary(),
|
||||
reports::tool_get_best_reports(),
|
||||
reports::tool_search_reports_by_tags(),
|
||||
reports::tool_search_reports_by_date_range(),
|
||||
reports::tool_search_reports_by_notes(),
|
||||
reports::tool_get_reports_by_set_file(),
|
||||
reports::tool_get_comparable_reports(),
|
||||
];
|
||||
|
||||
serde_json::json!(tools)
|
||||
|
||||
@@ -148,3 +148,133 @@ pub fn tool_prune_reports() -> Value {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_get_report_by_id() -> Value {
|
||||
json!({
|
||||
"name": "get_report_by_id",
|
||||
"description": "Get a specific report by its ID with full details and optional equity chart",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["id"],
|
||||
"properties": {
|
||||
"id": { "type": "string", "description": "Report ID (from list_reports or search_reports)" },
|
||||
"include_chart": { "type": "boolean", "description": "Include equity chart as base64 PNG (default: true)", "default": true }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_get_reports_summary() -> Value {
|
||||
json!({
|
||||
"name": "get_reports_summary",
|
||||
"description": "Get aggregate statistics across reports - counts, averages by EA/symbol/timeframe/verdict",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"expert": { "type": "string", "description": "Filter by EA name substring" },
|
||||
"symbol": { "type": "string", "description": "Filter by exact symbol" },
|
||||
"timeframe": { "type": "string", "description": "Filter by exact timeframe" },
|
||||
"verdict": { "type": "string", "description": "Filter by verdict (pass/fail/marginal)" }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_get_best_reports() -> Value {
|
||||
json!({
|
||||
"name": "get_best_reports",
|
||||
"description": "Get top N reports sorted by performance metric (profit factor, win rate, drawdown, etc.)",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"sort_by": { "type": "string", "enum": ["net_profit", "profit_factor", "max_dd_pct", "win_rate_pct", "sharpe_ratio", "recovery_factor", "total_trades"], "default": "profit_factor", "description": "Metric to sort by" },
|
||||
"order": { "type": "string", "enum": ["asc", "desc"], "default": "desc", "description": "Sort order (use 'asc' for drawdown, 'desc' for profit)" },
|
||||
"limit": { "type": "integer", "default": 10, "description": "Number of reports to return" },
|
||||
"expert": { "type": "string", "description": "Filter by EA name substring" },
|
||||
"symbol": { "type": "string", "description": "Filter by exact symbol" },
|
||||
"timeframe": { "type": "string", "description": "Filter by exact timeframe" },
|
||||
"verdict": { "type": "string", "description": "Filter by verdict" }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_search_reports_by_tags() -> Value {
|
||||
json!({
|
||||
"name": "search_reports_by_tags",
|
||||
"description": "Search reports by tags - at least one tag must match (OR logic)",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["tags"],
|
||||
"properties": {
|
||||
"tags": { "type": "array", "items": { "type": "string" }, "description": "Tags to search for (e.g., ['production', 'verified'])" },
|
||||
"limit": { "type": "integer", "default": 50 }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_search_reports_by_date_range() -> Value {
|
||||
json!({
|
||||
"name": "search_reports_by_date_range",
|
||||
"description": "Search reports by backtest date range (from_date and to_date fields)",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"from_start": { "type": "string", "description": "From date >= this (YYYY.MM.DD)" },
|
||||
"from_end": { "type": "string", "description": "From date <= this (YYYY.MM.DD)" },
|
||||
"to_start": { "type": "string", "description": "To date >= this (YYYY.MM.DD)" },
|
||||
"to_end": { "type": "string", "description": "To date <= this (YYYY.MM.DD)" },
|
||||
"limit": { "type": "integer", "default": 50 }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_search_reports_by_notes() -> Value {
|
||||
json!({
|
||||
"name": "search_reports_by_notes",
|
||||
"description": "Full-text search in report notes field (case-insensitive LIKE search)",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["query"],
|
||||
"properties": {
|
||||
"query": { "type": "string", "description": "Search text (partial match)" },
|
||||
"limit": { "type": "integer", "default": 50 }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_get_reports_by_set_file() -> Value {
|
||||
json!({
|
||||
"name": "get_reports_by_set_file",
|
||||
"description": "Find all reports that used a specific .set parameter file",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": ["set_file"],
|
||||
"properties": {
|
||||
"set_file": { "type": "string", "description": "Set filename or partial path to match" },
|
||||
"limit": { "type": "integer", "default": 50 }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_get_comparable_reports() -> Value {
|
||||
json!({
|
||||
"name": "get_comparable_reports",
|
||||
"description": "Find reports comparable to a given report (same EA, symbol, timeframe) - useful for before/after analysis",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"report_id": { "type": "string", "description": "Reference report ID (if provided, uses its expert/symbol/timeframe)" },
|
||||
"expert": { "type": "string", "description": "EA name (required if report_id not provided)" },
|
||||
"symbol": { "type": "string", "description": "Symbol (required if report_id not provided)" },
|
||||
"timeframe": { "type": "string", "description": "Timeframe (required if report_id not provided)" },
|
||||
"exclude_id": { "type": "string", "description": "Exclude this report ID from results" },
|
||||
"limit": { "type": "integer", "default": 20 }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -165,3 +165,149 @@ pub fn tool_export_report() -> Value {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_diagnose_wine() -> Value {
|
||||
json!({
|
||||
"name": "diagnose_wine",
|
||||
"description": "Check Wine installation, version, and prefix health. Reports errors, warnings, and recent Wine errors.",
|
||||
"inputSchema": {
|
||||
"type": "object"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_get_mt5_logs() -> Value {
|
||||
json!({
|
||||
"name": "get_mt5_logs",
|
||||
"description": "Get MT5 terminal, tester, or MetaEditor logs with optional search filtering",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"log_type": {
|
||||
"type": "string",
|
||||
"enum": ["terminal", "tester", "metaeditor"],
|
||||
"default": "terminal",
|
||||
"description": "Type of log to retrieve"
|
||||
},
|
||||
"lines": {
|
||||
"type": "integer",
|
||||
"default": 100,
|
||||
"description": "Number of lines to return (from end of log)"
|
||||
},
|
||||
"search": {
|
||||
"type": "string",
|
||||
"description": "Optional search term to filter log lines"
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_search_mt5_errors() -> Value {
|
||||
json!({
|
||||
"name": "search_mt5_errors",
|
||||
"description": "Search MT5 logs for error patterns (error, failed, crash, exception, etc.) in recent hours",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"hours_back": {
|
||||
"type": "integer",
|
||||
"default": 24,
|
||||
"description": "Hours to search back in logs"
|
||||
},
|
||||
"max_errors": {
|
||||
"type": "integer",
|
||||
"default": 50,
|
||||
"description": "Maximum number of errors to return"
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_check_mt5_process() -> Value {
|
||||
json!({
|
||||
"name": "check_mt5_process",
|
||||
"description": "Check if MT5 processes are running, get process info (PID, CPU, memory usage)",
|
||||
"inputSchema": {
|
||||
"type": "object"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_kill_mt5_process() -> Value {
|
||||
json!({
|
||||
"name": "kill_mt5_process",
|
||||
"description": "Kill stuck MT5 processes. Use force=true for stuck wineserver.",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"pid": {
|
||||
"type": "string",
|
||||
"description": "Optional specific PID to kill"
|
||||
},
|
||||
"force": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Use SIGKILL (-9) instead of SIGTERM (-15), also kills wineserver"
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_check_system_resources() -> Value {
|
||||
json!({
|
||||
"name": "check_system_resources",
|
||||
"description": "Check disk space, memory, and CPU. Warns if resources are low for MT5 operations.",
|
||||
"inputSchema": {
|
||||
"type": "object"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_validate_mt5_config() -> Value {
|
||||
json!({
|
||||
"name": "validate_mt5_config",
|
||||
"description": "Validate MT5 configuration files (terminal.ini, tester settings). Reports errors and warnings.",
|
||||
"inputSchema": {
|
||||
"type": "object"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_get_wine_prefix_info() -> Value {
|
||||
json!({
|
||||
"name": "get_wine_prefix_info",
|
||||
"description": "Get detailed Wine prefix information: Windows version, installed programs, registry files, drive_c size",
|
||||
"inputSchema": {
|
||||
"type": "object"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_get_backtest_crash_info() -> Value {
|
||||
json!({
|
||||
"name": "get_backtest_crash_info",
|
||||
"description": "Investigate backtest crashes/failures. Checks for incomplete markers, missing deals.csv, error logs. Can scan recent reports.",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"report_dir": {
|
||||
"type": "string",
|
||||
"description": "Optional specific report directory to check"
|
||||
},
|
||||
"check_recent": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Also check recent reports for failures"
|
||||
},
|
||||
"hours_back": {
|
||||
"type": "integer",
|
||||
"default": 6,
|
||||
"description": "Hours back to check for recent failures"
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user