FastAPI-Backend-Models / verify_routes.py
malek-messaoudii
chore: Update requirements.txt to address urllib3 compatibility issues and add requests-toolbelt for enhanced HTTP request handling.
91ae7d9
raw
history blame
2.04 kB
"""Script to verify MCP routes are properly registered"""
import sys
from pathlib import Path
# Add project root to path
sys.path.insert(0, str(Path(__file__).parent))
try:
from main import app
print("=" * 60)
print("Checking registered routes...")
print("=" * 60)
mcp_routes = []
all_routes = []
for route in app.routes:
if hasattr(route, 'path') and hasattr(route, 'methods'):
path = route.path
methods = route.methods if route.methods else set()
all_routes.append((path, methods))
if '/mcp' in path:
mcp_routes.append((path, methods))
print(f"\nTotal routes found: {len(all_routes)}")
print(f"MCP-related routes found: {len(mcp_routes)}")
print("\n" + "=" * 60)
print("MCP Routes:")
print("=" * 60)
for path, methods in sorted(mcp_routes):
methods_str = ', '.join(sorted(methods)) if methods else 'N/A'
print(f" {methods_str:15} {path}")
# Check for new routes
extract_topic_found = any('/extract-topic' in path for path, _ in mcp_routes)
voice_chat_found = any('/voice-chat' in path for path, _ in mcp_routes)
print("\n" + "=" * 60)
print("Route Verification:")
print("=" * 60)
print(f" extract-topic route: {'βœ“ FOUND' if extract_topic_found else 'βœ— NOT FOUND'}")
print(f" voice-chat route: {'βœ“ FOUND' if voice_chat_found else 'βœ— NOT FOUND'}")
if extract_topic_found and voice_chat_found:
print("\nβœ“ All new routes are properly registered!")
print("\nIf routes don't appear in Swagger UI:")
print(" 1. Restart the FastAPI server")
print(" 2. Clear browser cache or use Ctrl+Shift+R")
print(" 3. Check server logs for any import errors")
else:
print("\nβœ— Some routes are missing. Check for import errors in server logs.")
except Exception as e:
print(f"Error: {e}")
import traceback
traceback.print_exc()