@@ -208,12 +208,6 @@ private AsyncSpecification(McpServerTransportProvider transportProvider) {
208208 this .transportProvider = transportProvider ;
209209 }
210210
211- private void AssertNotDupplicateTool (String toolName ) {
212- if (this .tools .stream ().anyMatch (toolSpec -> toolSpec .tool ().name ().equals (toolName ))) {
213- throw new IllegalArgumentException ("Tool with name '" + toolName + "' is already registered." );
214- }
215- }
216-
217211 /**
218212 * Sets the URI template manager factory to use for creating URI templates. This
219213 * allows for custom URI template parsing and variable extraction.
@@ -335,7 +329,7 @@ public AsyncSpecification tool(McpSchema.Tool tool,
335329 BiFunction <McpAsyncServerExchange , Map <String , Object >, Mono <CallToolResult >> handler ) {
336330 Assert .notNull (tool , "Tool must not be null" );
337331 Assert .notNull (handler , "Handler must not be null" );
338- AssertNotDupplicateTool (tool .name ());
332+ assertNoDuplicateTool (tool .name ());
339333
340334 this .tools .add (new McpServerFeatures .AsyncToolSpecification (tool , handler ).toToolCall ());
341335
@@ -360,7 +354,7 @@ public AsyncSpecification toolCall(McpSchema.Tool tool,
360354
361355 Assert .notNull (tool , "Tool must not be null" );
362356 Assert .notNull (handler , "Handler must not be null" );
363- AssertNotDupplicateTool (tool .name ());
357+ assertNoDuplicateTool (tool .name ());
364358
365359 this .tools .add (new McpServerFeatures .AsyncToolCallSpecification (tool , handler ));
366360
@@ -384,7 +378,7 @@ public AsyncSpecification tools(List<McpServerFeatures.AsyncToolSpecification> t
384378 Assert .notNull (toolSpecifications , "Tool handlers list must not be null" );
385379
386380 for (var tool : toolSpecifications ) {
387- AssertNotDupplicateTool (tool .tool ().name ());
381+ assertNoDuplicateTool (tool .tool ().name ());
388382 this .tools .add (tool .toToolCall ());
389383 }
390384
@@ -406,7 +400,7 @@ public AsyncSpecification toolCalls(List<McpServerFeatures.AsyncToolCallSpecific
406400 Assert .notNull (toolCallSpecifications , "Tool handlers list must not be null" );
407401
408402 for (var tool : toolCallSpecifications ) {
409- AssertNotDupplicateTool (tool .tool ().name ());
403+ assertNoDuplicateTool (tool .tool ().name ());
410404 this .tools .add (tool );
411405 }
412406 return this ;
@@ -435,7 +429,7 @@ public AsyncSpecification tools(McpServerFeatures.AsyncToolSpecification... tool
435429 Assert .notNull (toolSpecifications , "Tool handlers list must not be null" );
436430
437431 for (McpServerFeatures .AsyncToolSpecification tool : toolSpecifications ) {
438- AssertNotDupplicateTool (tool .tool ().name ());
432+ assertNoDuplicateTool (tool .tool ().name ());
439433 this .tools .add (tool .toToolCall ());
440434 }
441435 return this ;
@@ -452,12 +446,18 @@ public AsyncSpecification toolCalls(McpServerFeatures.AsyncToolCallSpecification
452446 Assert .notNull (toolCallSpecifications , "Tool handlers list must not be null" );
453447
454448 for (McpServerFeatures .AsyncToolCallSpecification tool : toolCallSpecifications ) {
455- AssertNotDupplicateTool (tool .tool ().name ());
449+ assertNoDuplicateTool (tool .tool ().name ());
456450 this .tools .add (tool );
457451 }
458452 return this ;
459453 }
460454
455+ private void assertNoDuplicateTool (String toolName ) {
456+ if (this .tools .stream ().anyMatch (toolSpec -> toolSpec .tool ().name ().equals (toolName ))) {
457+ throw new IllegalArgumentException ("Tool with name '" + toolName + "' is already registered." );
458+ }
459+ }
460+
461461 /**
462462 * Registers multiple resources with their handlers using a Map. This method is
463463 * useful when resources are dynamically generated or loaded from a configuration
@@ -785,12 +785,6 @@ private SyncSpecification(McpServerTransportProvider transportProvider) {
785785 this .transportProvider = transportProvider ;
786786 }
787787
788- private void AssertNotDupplicateTool (String toolName ) {
789- if (this .tools .stream ().anyMatch (toolSpec -> toolSpec .tool ().name ().equals (toolName ))) {
790- throw new IllegalArgumentException ("Tool with name '" + toolName + "' is already registered." );
791- }
792- }
793-
794788 /**
795789 * Sets the URI template manager factory to use for creating URI templates. This
796790 * allows for custom URI template parsing and variable extraction.
@@ -911,7 +905,7 @@ public SyncSpecification tool(McpSchema.Tool tool,
911905 BiFunction <McpSyncServerExchange , Map <String , Object >, McpSchema .CallToolResult > handler ) {
912906 Assert .notNull (tool , "Tool must not be null" );
913907 Assert .notNull (handler , "Handler must not be null" );
914- AssertNotDupplicateTool (tool .name ());
908+ assertNoDuplicateTool (tool .name ());
915909
916910 this .tools .add (new McpServerFeatures .SyncToolSpecification (tool , handler ).toToolCall ());
917911
@@ -935,7 +929,7 @@ public SyncSpecification toolCall(McpSchema.Tool tool,
935929 BiFunction <McpSyncServerExchange , McpSchema .CallToolRequest , McpSchema .CallToolResult > handler ) {
936930 Assert .notNull (tool , "Tool must not be null" );
937931 Assert .notNull (handler , "Handler must not be null" );
938- AssertNotDupplicateTool (tool .name ());
932+ assertNoDuplicateTool (tool .name ());
939933
940934 this .tools .add (new McpServerFeatures .SyncToolCallSpecification (tool , handler ));
941935
@@ -960,7 +954,7 @@ public SyncSpecification tools(List<McpServerFeatures.SyncToolSpecification> too
960954
961955 for (var tool : toolSpecifications ) {
962956 String toolName = tool .tool ().name ();
963- AssertNotDupplicateTool (toolName ); // Check against existing tools
957+ assertNoDuplicateTool (toolName ); // Check against existing tools
964958 this .tools .add (tool .toToolCall ()); // Add the tool call specification
965959 // directly
966960 }
@@ -981,7 +975,7 @@ public SyncSpecification toolCalls(List<McpServerFeatures.SyncToolCallSpecificat
981975 Assert .notNull (toolCallSpecifications , "Tool handlers list must not be null" );
982976
983977 for (var tool : toolCallSpecifications ) {
984- AssertNotDupplicateTool (tool .tool ().name ());
978+ assertNoDuplicateTool (tool .tool ().name ());
985979 this .tools .add (tool );
986980 }
987981
@@ -1013,7 +1007,7 @@ public SyncSpecification tools(McpServerFeatures.SyncToolSpecification... toolSp
10131007 Assert .notNull (toolSpecifications , "Tool handlers list must not be null" );
10141008
10151009 for (McpServerFeatures .SyncToolSpecification tool : toolSpecifications ) {
1016- AssertNotDupplicateTool (tool .tool ().name ());
1010+ assertNoDuplicateTool (tool .tool ().name ());
10171011 this .tools .add (tool .toToolCall ());
10181012 }
10191013 return this ;
@@ -1031,12 +1025,18 @@ public SyncSpecification toolCalls(McpServerFeatures.SyncToolCallSpecification..
10311025 Assert .notNull (toolCallSpecifications , "Tool handlers list must not be null" );
10321026
10331027 for (McpServerFeatures .SyncToolCallSpecification tool : toolCallSpecifications ) {
1034- AssertNotDupplicateTool (tool .tool ().name ());
1028+ assertNoDuplicateTool (tool .tool ().name ());
10351029 this .tools .add (tool );
10361030 }
10371031 return this ;
10381032 }
10391033
1034+ private void assertNoDuplicateTool (String toolName ) {
1035+ if (this .tools .stream ().anyMatch (toolSpec -> toolSpec .tool ().name ().equals (toolName ))) {
1036+ throw new IllegalArgumentException ("Tool with name '" + toolName + "' is already registered." );
1037+ }
1038+ }
1039+
10401040 /**
10411041 * Registers multiple resources with their handlers using a Map. This method is
10421042 * useful when resources are dynamically generated or loaded from a configuration
0 commit comments