@@ -639,6 +639,44 @@ void testThrownMcpErrorAndJsonRpcError() throws Exception {
639639 mcpServer .close ();
640640 }
641641
642+ @ ParameterizedTest (name = "{0} : {displayName} " )
643+ @ ValueSource (strings = { "httpclient" })
644+ void testToolCallWithUnicodeArguments (String clientType ) {
645+
646+ var clientBuilder = clientBuilders .get (clientType );
647+
648+ // String containing multi-byte UTF-8 characters: em dash, Chinese, emoji
649+ String unicodeInput = "Test \u2014 em dash, \u5929 \u6c14 \u9884 \u62a5 , \ud83d \ude00 " ;
650+
651+ var echoTool = new McpStatelessServerFeatures .SyncToolSpecification (
652+ Tool .builder ().name ("echo" ).description ("Echoes input" ).inputSchema (EMPTY_JSON_SCHEMA ).build (),
653+ (transportContext , request ) -> {
654+ String text = (String ) request .arguments ().get ("text" );
655+ return CallToolResult .builder ().content (List .of (new TextContent (text ))).build ();
656+ });
657+
658+ var mcpServer = McpServer .sync (mcpStatelessServerTransport )
659+ .capabilities (ServerCapabilities .builder ().tools (true ).build ())
660+ .tools (echoTool )
661+ .build ();
662+
663+ try (var mcpClient = clientBuilder .build ()) {
664+ InitializeResult initResult = mcpClient .initialize ();
665+ assertThat (initResult ).isNotNull ();
666+
667+ CallToolResult response = mcpClient
668+ .callTool (new McpSchema .CallToolRequest ("echo" , Map .of ("text" , unicodeInput )));
669+
670+ assertThat (response ).isNotNull ();
671+ assertThat (response .content ()).hasSize (1 );
672+ assertThat (response .content ().get (0 )).isInstanceOf (TextContent .class );
673+ assertThat (((TextContent ) response .content ().get (0 )).text ()).isEqualTo (unicodeInput );
674+ }
675+ finally {
676+ mcpServer .close ();
677+ }
678+ }
679+
642680 private double evaluateExpression (String expression ) {
643681 // Simple expression evaluator for testing
644682 return switch (expression ) {
0 commit comments