This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit a273e5cf32e87fc7a25b81121430a3170afc5492
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jul 10 18:03:02 2026 +0200

    chore: return JSON-RPC error instead of bare 500 in TuiMcpServer exception 
handler
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../camel/dsl/jbang/core/commands/tui/TuiMcpServer.java     | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiMcpServer.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiMcpServer.java
index 82734e04457d..a4cca6563049 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiMcpServer.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiMcpServer.java
@@ -190,7 +190,18 @@ class TuiMcpServer {
                 logMethodCall(jsonrpcMethod, request, body, responseJson);
             }
         } catch (Exception e) {
-            exchange.sendResponseHeaders(500, -1);
+            try {
+                JsonObject error = new JsonObject();
+                error.put("code", -32603);
+                error.put("message", "Internal error");
+                JsonObject response = new JsonObject();
+                response.put("jsonrpc", "2.0");
+                response.put("id", null);
+                response.put("error", error);
+                sendJson(exchange, 200, response);
+            } catch (Exception ignored) {
+                // headers already sent
+            }
         } finally {
             exchange.close();
         }

Reply via email to