6666 * Example of creating a basic synchronous server: <pre>{@code
6767 * McpServer.sync(transportProvider)
6868 * .serverInfo("my-server", "1.0.0")
69- * .tool (Tool.builder().name("calculator").title("Performs calculations").inputSchema(schema).build(),
70- * (exchange, args ) -> CallToolResult.builder()
71- * .content(List.of(new McpSchema.TextContent("Result: " + calculate(args ))))
69+ * .toolCall (Tool.builder().name("calculator").title("Performs calculations").inputSchema(schema).build(),
70+ * (exchange, request ) -> CallToolResult.builder()
71+ * .content(List.of(new McpSchema.TextContent("Result: " + calculate(request.arguments() ))))
7272 * .isError(false)
7373 * .build())
7474 * .build();
7777 * Example of creating a basic asynchronous server: <pre>{@code
7878 * McpServer.async(transportProvider)
7979 * .serverInfo("my-server", "1.0.0")
80- * .tool (Tool.builder().name("calculator").title("Performs calculations").inputSchema(schema).build(),
81- * (exchange, args ) -> Mono.fromSupplier(() -> calculate(args ))
80+ * .toolCall (Tool.builder().name("calculator").title("Performs calculations").inputSchema(schema).build(),
81+ * (exchange, request ) -> Mono.fromSupplier(() -> calculate(request.arguments() ))
8282 * .map(result -> CallToolResult.builder()
8383 * .content(List.of(new McpSchema.TextContent("Result: " + result)))
8484 * .isError(false)
@@ -441,46 +441,6 @@ public AsyncSpecification<S> capabilities(McpSchema.ServerCapabilities serverCap
441441 return this ;
442442 }
443443
444- /**
445- * Adds a single tool with its implementation handler to the server. This is a
446- * convenience method for registering individual tools without creating a
447- * {@link McpServerFeatures.AsyncToolSpecification} explicitly.
448- *
449- * <p>
450- * Example usage: <pre>{@code
451- * .tool(
452- * Tool.builder().name("calculator").title("Performs calculations").inputSchema(schema).build(),
453- * (exchange, args) -> Mono.fromSupplier(() -> calculate(args))
454- * .map(result -> CallToolResult.builder()
455- * .content(List.of(new McpSchema.TextContent("Result: " + result)))
456- * .isError(false)
457- * .build()))
458- * )
459- * }</pre>
460- * @param tool The tool definition including name, description, and schema. Must
461- * not be null.
462- * @param handler The function that implements the tool's logic. Must not be null.
463- * The function's first argument is an {@link McpAsyncServerExchange} upon which
464- * the server can interact with the connected client. The second argument is the
465- * map of arguments passed to the tool.
466- * @return This builder instance for method chaining
467- * @throws IllegalArgumentException if tool or handler is null
468- * @deprecated Use {@link #toolCall(McpSchema.Tool, BiFunction)} instead for tool
469- * calls that require a request object.
470- */
471- @ Deprecated
472- public AsyncSpecification <S > tool (McpSchema .Tool tool ,
473- BiFunction <McpAsyncServerExchange , Map <String , Object >, Mono <CallToolResult >> handler ) {
474- Assert .notNull (tool , "Tool must not be null" );
475- Assert .notNull (handler , "Handler must not be null" );
476- validateToolName (tool .name ());
477- assertNoDuplicateTool (tool .name ());
478-
479- this .tools .add (new McpServerFeatures .AsyncToolSpecification (tool , handler ));
480-
481- return this ;
482- }
483-
484444 /**
485445 * Adds a single tool with its implementation handler to the server. This is a
486446 * convenience method for registering individual tools without creating a
@@ -1064,45 +1024,6 @@ public SyncSpecification<S> capabilities(McpSchema.ServerCapabilities serverCapa
10641024 return this ;
10651025 }
10661026
1067- /**
1068- * Adds a single tool with its implementation handler to the server. This is a
1069- * convenience method for registering individual tools without creating a
1070- * {@link McpServerFeatures.SyncToolSpecification} explicitly.
1071- *
1072- * <p>
1073- * Example usage: <pre>{@code
1074- * .tool(
1075- * Tool.builder().name("calculator").title("Performs calculations".inputSchema(schema).build(),
1076- * (exchange, args) -> CallToolResult.builder()
1077- * .content(List.of(new McpSchema.TextContent("Result: " + calculate(args))))
1078- * .isError(false)
1079- * .build())
1080- * )
1081- * }</pre>
1082- * @param tool The tool definition including name, description, and schema. Must
1083- * not be null.
1084- * @param handler The function that implements the tool's logic. Must not be null.
1085- * The function's first argument is an {@link McpSyncServerExchange} upon which
1086- * the server can interact with the connected client. The second argument is the
1087- * list of arguments passed to the tool.
1088- * @return This builder instance for method chaining
1089- * @throws IllegalArgumentException if tool or handler is null
1090- * @deprecated Use {@link #toolCall(McpSchema.Tool, BiFunction)} instead for tool
1091- * calls that require a request object.
1092- */
1093- @ Deprecated
1094- public SyncSpecification <S > tool (McpSchema .Tool tool ,
1095- BiFunction <McpSyncServerExchange , Map <String , Object >, McpSchema .CallToolResult > handler ) {
1096- Assert .notNull (tool , "Tool must not be null" );
1097- Assert .notNull (handler , "Handler must not be null" );
1098- validateToolName (tool .name ());
1099- assertNoDuplicateTool (tool .name ());
1100-
1101- this .tools .add (new McpServerFeatures .SyncToolSpecification (tool , handler ));
1102-
1103- return this ;
1104- }
1105-
11061027 /**
11071028 * Adds a single tool with its implementation handler to the server. This is a
11081029 * convenience method for registering individual tools without creating a
@@ -1123,7 +1044,7 @@ public SyncSpecification<S> toolCall(McpSchema.Tool tool,
11231044 validateToolName (tool .name ());
11241045 assertNoDuplicateTool (tool .name ());
11251046
1126- this .tools .add (new McpServerFeatures .SyncToolSpecification (tool , null , handler ));
1047+ this .tools .add (new McpServerFeatures .SyncToolSpecification (tool , handler ));
11271048
11281049 return this ;
11291050 }
0 commit comments