[ 
https://issues.apache.org/jira/browse/CAMEL-25385?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18123961#comment-18123961
 ] 

Claus Ibsen commented on CAMEL-25385:
-------------------------------------

To be fixed in 4.24.0 as part of CAMEL-25388. With CAMEL-25390 the runtime 
replies with the error instead of only logging it, so the tool reports the 
ClassCastException at once (as an MCP error) rather than a 10 s timeout. The 
header parsing in the shared send_message tool itself is fixed under 
CAMEL-25398.

_Claude Code on behalf of davsclaus (Claus Ibsen)_

> camel-jbang - the send_message MCP tool times out and does not send the 
> message when headers are given
> ------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25385
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25385
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jbang
>    Affects Versions: 4.22.1
>         Environment: Camel JBang 4.22.1, JBang 0.142.0, Java 25.0.4, macOS; 
> also seen in a Linux container on Kubernetes
>            Reporter: Serdar Gökay
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> The {{send_message}} tool in the shared {{ToolRegistry}} documents 
> {{headers}} as "Message headers as key=value pairs separated by newlines". 
> When headers are given, the message is not sent. After 10 seconds the tool 
> returns, with isError=false:
> {noformat}
> {"result":"Timeout waiting for response from PID 39618 for action: send"}
> {noformat}
> The application logs:
> {noformat}
> WARN LocalCliConnector : Error executing action: send due to: class 
> java.lang.String cannot be cast to class java.util.Collection 
> (java.lang.String and java.util.Collection are in module java.base of loader 
> 'bootstrap'). This exception is ignored.
> java.lang.ClassCastException: class java.lang.String cannot be cast to class 
> java.util.Collection (java.lang.String and java.util.Collection are in module 
> java.base of loader 'bootstrap')
> {noformat}
> The same call without headers succeeds, and the CLI delivers the header:
> {noformat}
> camel cmd send --endpoint=direct:echo --body=hi --header=foo=bar --reply demo
> {noformat}
> h3. Reproduce
> Camel JBang 4.22.1. {{demo.camel.yaml}}:
> {noformat}
> - route:
>     id: tick
>     from:
>       uri: timer:tick
>       steps:
>         - log: tick
> - route:
>     id: echo
>     from:
>       uri: direct:echo
>       steps:
>         - log: "foo=${header.foo}"
> {noformat}
> {noformat}
> camel run demo.camel.yaml --mcp
> {noformat}
> Then call {{send_message}} from an MCP client connected to the {{/mcp}} 
> endpoint, with these arguments:
> {noformat}
> {"endpoint": "direct:echo", "body": "hi", "headers": "foo=bar"}
> {noformat}
> h3. Cause
> {{RuntimeHelper.sendMessage}} puts the headers string into the action 
> unchanged ({{root.put("headers", headers)}}). 
> {{LocalCliConnector.doActionSendTask}} reads 
> {{root.getCollection("headers")}} and expects the array of key/value objects 
> that {{CamelSendAction}} builds from its header option. Converting the 
> key=value lines into that array in {{RuntimeHelper.sendMessage}} would fix it.
> From reading the code, {{camel_runtime_send}} in the {{camel mcp}} server 
> ({{RuntimeTools}} delegates to {{send_message}}) and the TUI 
> ({{McpFacade.sendMessage}}) use the same path. The code is unchanged on main.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to