#!/usr/bin/env python3
"""Verify all MCP tools are accessible and working."""
import asyncio
import sys
from pathlib import Path
# Add src to path
sys.path.insert(0, str(Path(__file__).parent))
from src.server import mcp
def list_all_tools():
"""List all registered MCP tools."""
print("=" * 80)
print("MCP TOOLS VERIFICATION")
print("=" * 80)
# Get all registered tools from the FastMCP server
tools = []
# FastMCP stores tools in the _tools dictionary
if hasattr(mcp, '_tool_manager') and hasattr(mcp._tool_manager, '_tools'):
tools = list(mcp._tool_manager._tools.keys())
elif hasattr(mcp, 'list_tools'):
# Alternative method if available
tools_list = mcp.list_tools()
tools = [t.name for t in tools_list] if tools_list else []
print(f"\nTotal tools registered: {len(tools)}\n")
# Group tools by category
categories = {
"Indexing": [],
"Search": [],
"Query": [],
"Performance & Risk": [],
"Reports": [],
"Simulation": []
}
for tool_name in sorted(tools):
if tool_name in ['index_statement', 'reindex_statement', 'get_indexing_stats', 'rebuild_from_archives']:
categories["Indexing"].append(tool_name)
elif tool_name in ['search_statements']:
categories["Search"].append(tool_name)
elif tool_name in ['get_holdings_by_symbol', 'get_transactions_by_date_range', 'get_account_balance',
'get_performance_history', 'compare_to_benchmark', 'get_portfolio_summary']:
categories["Query"].append(tool_name)
elif tool_name in ['get_risk_metrics', 'calculate_risk_metrics']:
categories["Performance & Risk"].append(tool_name)
elif tool_name in ['update_monthly_returns']:
categories["Reports"].append(tool_name)
elif tool_name in ['run_monte_carlo_simulation', 'run_stress_test_simulation']:
categories["Simulation"].append(tool_name)
# Print by category
for category, tool_list in categories.items():
if tool_list:
print(f"π {category}:")
for tool in tool_list:
print(f" β
{tool}")
print()
# Verify Monte Carlo specifically
print("=" * 80)
if 'run_monte_carlo_simulation' in tools:
print("β
Monte Carlo Simulation Tool: AVAILABLE")
print()
print(" Tool name: run_monte_carlo_simulation")
print(" Parameters:")
print(" - n_simulations: int (default: 10000)")
print(" - projection_years: int (default: 5)")
print(" - account_numbers: list[str] (default: all accounts)")
print(" - percentiles: list[float] (default: [10, 25, 50, 75, 90])")
print()
print(" Returns:")
print(" - simulation_metadata")
print(" - input_statistics")
print(" - year_by_year_projections")
print(" - visualizations (PNG charts)")
print(" - data_files (CSV files)")
print()
print(" Output locations:")
print(" - Timestamped: data/reports/monte_carlo/{timestamp}/")
print(" - Latest: data/reports/monte_carlo/latest/")
else:
print("β Monte Carlo Simulation Tool: NOT FOUND")
print("=" * 80)
if 'run_stress_test_simulation' in tools:
print("β
Stress Test Simulation Tool: AVAILABLE")
print()
print(" Tool name: run_stress_test_simulation")
print(" Parameters:")
print(" - n_simulations: int (default: 10000)")
print(" - projection_years: int (default: 5)")
print(" - account_numbers: list[str] (default: all accounts)")
print(" - percentiles: list[float] (default: [10, 25, 50, 75, 90])")
print()
print(" Stress Scenarios:")
print(" - Market Crash: 30% immediate decline at random point")
print(" - Bear Market: 12 months of -5% monthly returns")
print(" - Volatility Spike: 3x volatility for 6 months")
print()
print(" Returns:")
print(" - simulation_metadata")
print(" - input_statistics")
print(" - baseline (no stress projections)")
print(" - stress_scenarios (crash, bear, volatility)")
print(" - visualizations (comparison charts)")
print(" - data_files (scenario comparison, impact analysis)")
print()
print(" Output locations:")
print(" - Timestamped: data/reports/stress_test/{timestamp}/")
print(" - Latest: data/reports/stress_test/latest/")
else:
print("β Stress Test Simulation Tool: NOT FOUND")
print("=" * 80)
print()
# Check dependencies
print("Checking dependencies...")
try:
import numpy
print(f" β
numpy {numpy.__version__}")
except ImportError:
print(" β numpy NOT INSTALLED")
try:
import scipy
print(f" β
scipy {scipy.__version__}")
except ImportError:
print(" β scipy NOT INSTALLED")
try:
import matplotlib
print(f" β
matplotlib {matplotlib.__version__}")
except ImportError:
print(" β matplotlib NOT INSTALLED")
try:
import pandas
print(f" β
pandas {pandas.__version__}")
except ImportError:
print(" β pandas NOT INSTALLED")
print()
print("=" * 80)
print("β
VERIFICATION COMPLETE")
print("=" * 80)
if __name__ == "__main__":
list_all_tools()