Claus Ibsen created CAMEL-26668:
-----------------------------------
Summary: camel-mcp-server - polish the error responses on /mcp
when a request fails
Key: CAMEL-26668
URL: https://issues.apache.org/jira/browse/CAMEL-26668
Project: Camel
Issue Type: Improvement
Components: camel-mcp-server
Reporter: Claus Ibsen
Fix For: 4.24.0
The Camel Main engine of camel-mcp-server answers some failed requests on
{{/mcp}} with a body that is not a proper JSON-RPC error response.
{{VertxMcpStreamableServerTransportProvider.respondError}} writes the
{{McpError}} Java object as JSON, which is used for:
* 415 when the {{Content-Type}} is not {{application/json}};
* 400 when the message cannot be parsed;
* 404 when the session is not found;
* 500 for an unknown message type.
MCP clients expect a JSON-RPC error object there.
*Proposal*
* reply with a JSON-RPC error response without an {{id}}:
{{\{"jsonrpc":"2.0","error":\{"code":<code>,"message":"<message>"\}\}}}, built
from the error code and a short fixed message;
* keep the messages short and fixed, for example "Invalid message format"
instead of the text of the parser;
* use the same shape for the 403 of the origin check (CAMEL-26359) and the
bad-request replies, so all error replies on {{/mcp}} look the same;
* tests that check the body of each error reply.
_Claude Code on behalf of Claus Ibsen (davsclaus)_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)