2626import io .modelcontextprotocol .server .McpServerFeatures .AsyncToolSpecification ;
2727import io .modelcontextprotocol .server .McpServerFeatures .SyncToolSpecification ;
2828import io .modelcontextprotocol .server .McpSyncServerExchange ;
29+ import io .modelcontextprotocol .spec .McpSchema ;
2930import io .modelcontextprotocol .spec .McpSchema .CallToolResult ;
3031import io .modelcontextprotocol .spec .McpSchema .Implementation ;
3132import io .modelcontextprotocol .spec .McpSchema .ListToolsResult ;
@@ -226,7 +227,10 @@ void toSyncToolSpecificationShouldConvertSingleCallback() {
226227 assertThat (toolSpecification ).isNotNull ();
227228 assertThat (toolSpecification .tool ().name ()).isEqualTo ("test" );
228229
229- CallToolResult result = toolSpecification .call ().apply (mock (McpSyncServerExchange .class ), Map .of ());
230+ McpSchema .CallToolRequest mockRequest = mock (McpSchema .CallToolRequest .class );
231+ when (mockRequest .arguments ()).thenReturn (Map .of ());
232+
233+ CallToolResult result = toolSpecification .callHandler ().apply (mock (McpSyncServerExchange .class ), mockRequest );
230234 TextContent content = (TextContent ) result .content ().get (0 );
231235 assertThat (content .text ()).isEqualTo ("success" );
232236 assertThat (result .isError ()).isFalse ();
@@ -239,7 +243,11 @@ void toSyncToolSpecificationShouldHandleError() {
239243 SyncToolSpecification toolSpecification = McpToolUtils .toSyncToolSpecification (callback );
240244
241245 assertThat (toolSpecification ).isNotNull ();
242- CallToolResult result = toolSpecification .call ().apply (mock (McpSyncServerExchange .class ), Map .of ());
246+
247+ McpSchema .CallToolRequest mockRequest = mock (McpSchema .CallToolRequest .class );
248+ when (mockRequest .arguments ()).thenReturn (Map .of ());
249+
250+ CallToolResult result = toolSpecification .callHandler ().apply (mock (McpSyncServerExchange .class ), mockRequest );
243251 TextContent content = (TextContent ) result .content ().get (0 );
244252 assertThat (content .text ()).isEqualTo ("error" );
245253 assertThat (result .isError ()).isTrue ();
@@ -267,7 +275,10 @@ void toAsyncToolSpecificationShouldConvertSingleCallback() {
267275 assertThat (toolSpecification ).isNotNull ();
268276 assertThat (toolSpecification .tool ().name ()).isEqualTo ("test" );
269277
270- StepVerifier .create (toolSpecification .call ().apply (mock (McpAsyncServerExchange .class ), Map .of ()))
278+ McpSchema .CallToolRequest mockRequest = mock (McpSchema .CallToolRequest .class );
279+ when (mockRequest .arguments ()).thenReturn (Map .of ());
280+
281+ StepVerifier .create (toolSpecification .callHandler ().apply (mock (McpAsyncServerExchange .class ), mockRequest ))
271282 .assertNext (result -> {
272283 TextContent content = (TextContent ) result .content ().get (0 );
273284 assertThat (content .text ()).isEqualTo ("success" );
@@ -283,7 +294,11 @@ void toAsyncToolSpecificationShouldHandleError() {
283294 AsyncToolSpecification toolSpecification = McpToolUtils .toAsyncToolSpecification (callback );
284295
285296 assertThat (toolSpecification ).isNotNull ();
286- StepVerifier .create (toolSpecification .call ().apply (mock (McpAsyncServerExchange .class ), Map .of ()))
297+
298+ McpSchema .CallToolRequest mockRequest = mock (McpSchema .CallToolRequest .class );
299+ when (mockRequest .arguments ()).thenReturn (Map .of ());
300+
301+ StepVerifier .create (toolSpecification .callHandler ().apply (mock (McpAsyncServerExchange .class ), mockRequest ))
287302 .assertNext (result -> {
288303 TextContent content = (TextContent ) result .content ().get (0 );
289304 assertThat (content .text ()).isEqualTo ("error" );
0 commit comments