fix(mcp): prevent internal handler serialization errors from being silently discarded or defaulting to empty strings

This commit is contained in:
Riz Ashraf committed 2026-09-27 22:30:32 +01:00
1 parent 8f32a09399
commit febd48c65d
5 files changed
+12 -12

No files matched your search

+1 -1
View File
@@ -86,7 +86,7 @@ pub async fn handle_socket(socket: WebSocket, state: Arc<AppState>, _client_type
if let Ok(payload) = serde_json::from_str::<serde_json::Value>(&text) {
// Process MCP request
if let Some(response) = handler.handle_request(payload).await {
let res_str = serde_json::to_string(&response).unwrap_or_default();
let res_str = serde_json::to_string(&response).unwrap_or_else(|e| format!(r#"{{\"jsonrpc\":\"2.0\",\"id\":null,\"error\":{{\"code\":-32603,\"message\":\"{}\"}}}}"#, e));
let tx_opt = state_clone
.clients
.read()