Peter Michael Gits Claude commited on
Commit Β·
cdc2e76
1
Parent(s): 0caa1e7
fix: Always initialize WebSocket URLs regardless of MCP status
Browse files- WebSocket URLs were only initialized when MCP failed completely
- Fake MCP success prevented WebSocket fallback initialization
- Now WebSocket/HTTP services are always initialized first
- This ensures STT WebSocket connection is always available
- Fixes "hasattr(self, 'stt_websocket_urls'): False" issue
π€ Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
core/mcp_audio_handler.py
CHANGED
|
@@ -75,8 +75,11 @@ class MCPAudioHandler:
|
|
| 75 |
def _discover_services(self):
|
| 76 |
"""Discover available MCP services."""
|
| 77 |
try:
|
| 78 |
-
#
|
|
|
|
|
|
|
| 79 |
|
|
|
|
| 80 |
# First, try to import MCP client
|
| 81 |
try:
|
| 82 |
from mcp import ClientSession
|
|
@@ -89,20 +92,17 @@ class MCPAudioHandler:
|
|
| 89 |
|
| 90 |
except ImportError as e:
|
| 91 |
print(f"π§ MCP: MCP client not available: {e}")
|
| 92 |
-
print("π§ MCP:
|
| 93 |
-
# Fall back to HTTP-based approach
|
| 94 |
-
self._fallback_to_http()
|
| 95 |
return
|
| 96 |
|
| 97 |
except Exception as e:
|
| 98 |
print(f"π§ MCP SERVICE DISCOVERY ERROR: {e}")
|
| 99 |
logger.error(f"MCP service discovery failed: {e}")
|
| 100 |
-
|
| 101 |
-
self._fallback_to_http()
|
| 102 |
|
| 103 |
-
def
|
| 104 |
-
"""
|
| 105 |
-
print("π§ WEBSOCKET/HTTP
|
| 106 |
|
| 107 |
# Import HTTP handler components
|
| 108 |
try:
|
|
|
|
| 75 |
def _discover_services(self):
|
| 76 |
"""Discover available MCP services."""
|
| 77 |
try:
|
| 78 |
+
# ALWAYS initialize WebSocket and HTTP fallbacks first
|
| 79 |
+
# This ensures we have working service connections regardless of MCP status
|
| 80 |
+
self._initialize_websocket_and_http_services()
|
| 81 |
|
| 82 |
+
# Check what MCP tools are available in the environment
|
| 83 |
# First, try to import MCP client
|
| 84 |
try:
|
| 85 |
from mcp import ClientSession
|
|
|
|
| 92 |
|
| 93 |
except ImportError as e:
|
| 94 |
print(f"π§ MCP: MCP client not available: {e}")
|
| 95 |
+
print("π§ MCP: Using WebSocket/HTTP services (already initialized)")
|
|
|
|
|
|
|
| 96 |
return
|
| 97 |
|
| 98 |
except Exception as e:
|
| 99 |
print(f"π§ MCP SERVICE DISCOVERY ERROR: {e}")
|
| 100 |
logger.error(f"MCP service discovery failed: {e}")
|
| 101 |
+
print("π§ MCP: Using WebSocket/HTTP services (already initialized)")
|
|
|
|
| 102 |
|
| 103 |
+
def _initialize_websocket_and_http_services(self):
|
| 104 |
+
"""Initialize WebSocket and HTTP-based service connections (primary method)."""
|
| 105 |
+
print("π§ WEBSOCKET/HTTP INIT: Initializing WebSocket and HTTP-based service connections")
|
| 106 |
|
| 107 |
# Import HTTP handler components
|
| 108 |
try:
|