davsclaus opened a new pull request, #26966:
URL: https://github.com/apache/camel/pull/26966

   [CAMEL-25076](https://issues.apache.org/jira/browse/CAMEL-25076)
   
   ## Problem
   
   `StdioMcpServerEngineTest` fails on main (all three tests error in `setUp`), 
and it breaks the CI of PRs that build camel-mcp-server, such as #26940:
   
   ```
   java.lang.RuntimeException: Failed to enqueue message
     at 
io.modelcontextprotocol.server.transport.StdioServerTransportProvider$StdioMcpSessionTransport.lambda$sendMessage$0
     at io.modelcontextprotocol.server.McpSyncServer.addTool
     at 
org.apache.camel.component.mcp.server.stdio.StdioMcpServerEngine.toolAdded
   ```
   
   `McpSyncServer.addTool` registers the tool and then notifies the client that 
the tool list changed. When stdin ends, the SDK closes the outbound side of the 
session, and the notification fails. The test uses an empty stdin, so it races 
with this. The same happens for real when the parent process closes stdin and 
an `ai-tool` route is added afterwards (for example on a dev reload): the route 
fails.
   
   ## Fix
   
   The tool is registered either way, so `StdioMcpServerEngine` now logs a 
failed notification as a WARN instead of failing. Invalid tools 
(`IllegalArgumentException`/`IllegalStateException`, such as a bad input 
schema) still fail.
   
   ## Tests
   
   - New `toolAddedAfterStdinClosedDoesNotFail`: fails without the fix, passes 
with it.
   - camel-mcp-server: all 44 tests pass; `StdioMcpServerEngineTest` passes on 
3 consecutive runs.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to