davsclaus commented on code in PR #29301:
URL: https://github.com/apache/camel/pull/29301#discussion_r4491253248
##########
components/camel-ai/camel-mcp-server/src/main/java/org/apache/camel/component/mcp/server/vertx/VertxMcpStreamableServerTransportProvider.java:
##########
@@ -488,17 +486,26 @@ private boolean respondBadRequest(Context connection,
RoutingContext ctx, List<S
if (errors.isEmpty()) {
return false;
}
- respondError(connection, ctx, 400,
-
McpError.builder(McpSchema.ErrorCodes.METHOD_NOT_FOUND).message(String.join(";
", errors)).build());
+ respondError(connection, ctx, 400,
McpSchema.ErrorCodes.INVALID_REQUEST, String.join("; ", errors));
return true;
}
- private void respondError(Context connection, RoutingContext ctx, int
status, McpError error) {
+ /**
+ * Answers with the given HTTP status and a JSON-RPC error response
without an id (the request id is not known, and
+ * {@link McpSchema.JSONRPCResponse} requires one).
+ */
+ private void respondError(Context connection, RoutingContext ctx, int
status, int code, String message) {
+ Map<String, Object> error = new LinkedHashMap<>();
+ error.put("code", code);
+ error.put("message", message);
+ Map<String, Object> response = new LinkedHashMap<>();
+ response.put("jsonrpc", McpSchema.JSONRPC_VERSION);
+ response.put("error", error);
String json;
try {
- json = jsonMapper.writeValueAsString(error);
+ json = jsonMapper.writeValueAsString(response);
} catch (Exception e) {
Review Comment:
Done in 076bbdf03b02: the fallback body keeps the `message` (escaped). The
JSON body is now built in one `errorBody` method, also used by the 403 of the
Origin check from #29284.
_Claude Code on behalf of Claus Ibsen (davsclaus)_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]