|
51 | 51 | import reactor.core.publisher.Mono; |
52 | 52 | import reactor.test.StepVerifier; |
53 | 53 |
|
54 | | -import static io.modelcontextprotocol.util.ToolsUtils.EMPTY_JSON_SCHEMA; |
55 | 54 | import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson; |
56 | 55 | import static net.javacrumbs.jsonunit.assertj.JsonAssertions.json; |
57 | 56 | import static org.assertj.core.api.Assertions.assertThat; |
@@ -103,7 +102,7 @@ void testCreateMessageWithoutSamplingCapabilities(String clientType) { |
103 | 102 | var clientBuilder = clientBuilders.get(clientType); |
104 | 103 |
|
105 | 104 | McpServerFeatures.AsyncToolSpecification tool = McpServerFeatures.AsyncToolSpecification.builder() |
106 | | - .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(EMPTY_JSON_SCHEMA).build()) |
| 105 | + .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(Map.of()).build()) |
107 | 106 | .callHandler((exchange, request) -> { |
108 | 107 | return exchange.createMessage(mock(McpSchema.CreateMessageRequest.class)) |
109 | 108 | .then(Mono.just(mock(CallToolResult.class))); |
@@ -153,7 +152,7 @@ void testCreateMessageSuccess(String clientType) { |
153 | 152 | AtomicReference<CreateMessageResult> samplingResult = new AtomicReference<>(); |
154 | 153 |
|
155 | 154 | McpServerFeatures.AsyncToolSpecification tool = McpServerFeatures.AsyncToolSpecification.builder() |
156 | | - .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(EMPTY_JSON_SCHEMA).build()) |
| 155 | + .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(Map.of()).build()) |
157 | 156 | .callHandler((exchange, request) -> { |
158 | 157 |
|
159 | 158 | var createMessageRequest = McpSchema.CreateMessageRequest.builder() |
@@ -232,7 +231,7 @@ void testCreateMessageWithRequestTimeoutSuccess(String clientType) throws Interr |
232 | 231 | AtomicReference<CreateMessageResult> samplingResult = new AtomicReference<>(); |
233 | 232 |
|
234 | 233 | McpServerFeatures.AsyncToolSpecification tool = McpServerFeatures.AsyncToolSpecification.builder() |
235 | | - .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(EMPTY_JSON_SCHEMA).build()) |
| 234 | + .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(Map.of()).build()) |
236 | 235 | .callHandler((exchange, request) -> { |
237 | 236 |
|
238 | 237 | var createMessageRequest = McpSchema.CreateMessageRequest.builder() |
@@ -307,7 +306,7 @@ void testCreateMessageWithRequestTimeoutFail(String clientType) throws Interrupt |
307 | 306 | .build(); |
308 | 307 |
|
309 | 308 | McpServerFeatures.AsyncToolSpecification tool = McpServerFeatures.AsyncToolSpecification.builder() |
310 | | - .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(EMPTY_JSON_SCHEMA).build()) |
| 309 | + .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(Map.of()).build()) |
311 | 310 | .callHandler((exchange, request) -> { |
312 | 311 |
|
313 | 312 | var createMessageRequest = McpSchema.CreateMessageRequest.builder() |
@@ -357,7 +356,7 @@ void testCreateElicitationWithoutElicitationCapabilities(String clientType) { |
357 | 356 | var clientBuilder = clientBuilders.get(clientType); |
358 | 357 |
|
359 | 358 | McpServerFeatures.AsyncToolSpecification tool = McpServerFeatures.AsyncToolSpecification.builder() |
360 | | - .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(EMPTY_JSON_SCHEMA).build()) |
| 359 | + .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(Map.of()).build()) |
361 | 360 | .callHandler((exchange, request) -> exchange.createElicitation(mock(ElicitRequest.class)) |
362 | 361 | .then(Mono.just(mock(CallToolResult.class)))) |
363 | 362 | .build(); |
@@ -401,7 +400,7 @@ void testCreateElicitationSuccess(String clientType) { |
401 | 400 | .build(); |
402 | 401 |
|
403 | 402 | McpServerFeatures.AsyncToolSpecification tool = McpServerFeatures.AsyncToolSpecification.builder() |
404 | | - .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(EMPTY_JSON_SCHEMA).build()) |
| 403 | + .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(Map.of()).build()) |
405 | 404 | .callHandler((exchange, request) -> { |
406 | 405 |
|
407 | 406 | var elicitationRequest = McpSchema.ElicitRequest.builder() |
@@ -459,7 +458,7 @@ void testCreateElicitationWithRequestTimeoutSuccess(String clientType) { |
459 | 458 | AtomicReference<ElicitResult> resultRef = new AtomicReference<>(); |
460 | 459 |
|
461 | 460 | McpServerFeatures.AsyncToolSpecification tool = McpServerFeatures.AsyncToolSpecification.builder() |
462 | | - .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(EMPTY_JSON_SCHEMA).build()) |
| 461 | + .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(Map.of()).build()) |
463 | 462 | .callHandler((exchange, request) -> { |
464 | 463 |
|
465 | 464 | var elicitationRequest = McpSchema.ElicitRequest.builder() |
@@ -530,7 +529,7 @@ void testCreateElicitationWithRequestTimeoutFail(String clientType) { |
530 | 529 | AtomicReference<ElicitResult> resultRef = new AtomicReference<>(); |
531 | 530 |
|
532 | 531 | McpServerFeatures.AsyncToolSpecification tool = McpServerFeatures.AsyncToolSpecification.builder() |
533 | | - .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(EMPTY_JSON_SCHEMA).build()) |
| 532 | + .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(Map.of()).build()) |
534 | 533 | .callHandler((exchange, request) -> { |
535 | 534 |
|
536 | 535 | var elicitationRequest = ElicitRequest.builder() |
@@ -628,7 +627,7 @@ void testRootsWithoutCapability(String clientType) { |
628 | 627 | var clientBuilder = clientBuilders.get(clientType); |
629 | 628 |
|
630 | 629 | McpServerFeatures.SyncToolSpecification tool = McpServerFeatures.SyncToolSpecification.builder() |
631 | | - .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(EMPTY_JSON_SCHEMA).build()) |
| 630 | + .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(Map.of()).build()) |
632 | 631 | .callHandler((exchange, request) -> { |
633 | 632 |
|
634 | 633 | exchange.listRoots(); // try to list roots |
@@ -770,7 +769,7 @@ void testToolCallSuccess(String clientType) { |
770 | 769 | .addContent(new McpSchema.TextContent("CALL RESPONSE; ctx=importantValue")) |
771 | 770 | .build(); |
772 | 771 | McpServerFeatures.SyncToolSpecification tool1 = McpServerFeatures.SyncToolSpecification.builder() |
773 | | - .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(EMPTY_JSON_SCHEMA).build()) |
| 772 | + .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(Map.of()).build()) |
774 | 773 | .callHandler((exchange, request) -> { |
775 | 774 |
|
776 | 775 | try { |
@@ -821,11 +820,7 @@ void testThrowingToolCallIsCaughtBeforeTimeout(String clientType) { |
821 | 820 | McpSyncServer mcpServer = prepareSyncServerBuilder() |
822 | 821 | .capabilities(ServerCapabilities.builder().tools(true).build()) |
823 | 822 | .tools(McpServerFeatures.SyncToolSpecification.builder() |
824 | | - .tool(Tool.builder() |
825 | | - .name("tool1") |
826 | | - .description("tool1 description") |
827 | | - .inputSchema(EMPTY_JSON_SCHEMA) |
828 | | - .build()) |
| 823 | + .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(Map.of()).build()) |
829 | 824 | .callHandler((exchange, request) -> { |
830 | 825 | // We trigger a timeout on blocking read, raising an exception |
831 | 826 | Mono.never().block(Duration.ofSeconds(1)); |
@@ -863,7 +858,7 @@ void testToolCallSuccessWithTransportContextExtraction(String clientType) { |
863 | 858 | .addContent(new McpSchema.TextContent("CALL RESPONSE; ctx=value")) |
864 | 859 | .build(); |
865 | 860 | McpServerFeatures.SyncToolSpecification tool1 = McpServerFeatures.SyncToolSpecification.builder() |
866 | | - .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(EMPTY_JSON_SCHEMA).build()) |
| 861 | + .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(Map.of()).build()) |
867 | 862 | .callHandler((exchange, request) -> { |
868 | 863 |
|
869 | 864 | McpTransportContext transportContext = exchange.transportContext(); |
@@ -919,7 +914,7 @@ void testToolListChangeHandlingSuccess(String clientType) { |
919 | 914 | .build(); |
920 | 915 |
|
921 | 916 | McpServerFeatures.SyncToolSpecification tool1 = McpServerFeatures.SyncToolSpecification.builder() |
922 | | - .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(EMPTY_JSON_SCHEMA).build()) |
| 917 | + .tool(Tool.builder().name("tool1").description("tool1 description").inputSchema(Map.of()).build()) |
923 | 918 | .callHandler((exchange, request) -> { |
924 | 919 | // perform a blocking call to a remote service |
925 | 920 | try { |
@@ -985,11 +980,7 @@ void testToolListChangeHandlingSuccess(String clientType) { |
985 | 980 |
|
986 | 981 | // Add a new tool |
987 | 982 | McpServerFeatures.SyncToolSpecification tool2 = McpServerFeatures.SyncToolSpecification.builder() |
988 | | - .tool(Tool.builder() |
989 | | - .name("tool2") |
990 | | - .description("tool2 description") |
991 | | - .inputSchema(EMPTY_JSON_SCHEMA) |
992 | | - .build()) |
| 983 | + .tool(Tool.builder().name("tool2").description("tool2 description").inputSchema(Map.of()).build()) |
993 | 984 | .callHandler((exchange, request) -> callResponse) |
994 | 985 | .build(); |
995 | 986 |
|
@@ -1040,7 +1031,7 @@ void testLoggingNotification(String clientType) throws InterruptedException { |
1040 | 1031 | .tool(Tool.builder() |
1041 | 1032 | .name("logging-test") |
1042 | 1033 | .description("Test logging notifications") |
1043 | | - .inputSchema(EMPTY_JSON_SCHEMA) |
| 1034 | + .inputSchema(Map.of()) |
1044 | 1035 | .build()) |
1045 | 1036 | .callHandler((exchange, request) -> { |
1046 | 1037 |
|
@@ -1157,7 +1148,7 @@ void testProgressNotification(String clientType) throws InterruptedException { |
1157 | 1148 | .tool(McpSchema.Tool.builder() |
1158 | 1149 | .name("progress-test") |
1159 | 1150 | .description("Test progress notifications") |
1160 | | - .inputSchema(EMPTY_JSON_SCHEMA) |
| 1151 | + .inputSchema(Map.of()) |
1161 | 1152 | .build()) |
1162 | 1153 | .callHandler((exchange, request) -> { |
1163 | 1154 |
|
@@ -1315,7 +1306,7 @@ void testPingSuccess(String clientType) { |
1315 | 1306 | .tool(Tool.builder() |
1316 | 1307 | .name("ping-async-test") |
1317 | 1308 | .description("Test ping async behavior") |
1318 | | - .inputSchema(EMPTY_JSON_SCHEMA) |
| 1309 | + .inputSchema(Map.of()) |
1319 | 1310 | .build()) |
1320 | 1311 | .callHandler((exchange, request) -> { |
1321 | 1312 |
|
|
0 commit comments