File tree Expand file tree Collapse file tree
mcp-core/src/main/java/io/modelcontextprotocol/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -589,20 +589,20 @@ public Mono<Void> removeTools(List<String> toolNames) {
589589 if (toolNames == null ) {
590590 return Mono .error (new IllegalArgumentException ("Tool names must not be null" ));
591591 }
592+ if (this .serverCapabilities .tools () == null ) {
593+ return Mono .error (new IllegalStateException ("Server must be configured with tool capabilities" ));
594+ }
592595 if (toolNames .isEmpty ()) {
593596 return Mono .empty ();
594597 }
595598
596599 Set <String > toolNamesToRemove = new HashSet <>();
597- for (String toolName : new ArrayList <>( toolNames ) ) {
600+ for (String toolName : toolNames ) {
598601 if (toolName == null ) {
599602 return Mono .error (new IllegalArgumentException ("Tool name must not be null" ));
600603 }
601604 toolNamesToRemove .add (toolName );
602605 }
603- if (this .serverCapabilities .tools () == null ) {
604- return Mono .error (new IllegalStateException ("Server must be configured with tool capabilities" ));
605- }
606606
607607 return Mono .defer (() -> {
608608 if (this .tools .removeIf (toolSpecification -> toolNamesToRemove .contains (toolSpecification .tool ().name ()))) {
Original file line number Diff line number Diff line change @@ -457,20 +457,21 @@ public Mono<Void> removeTools(List<String> toolNames) {
457457 if (toolNames == null ) {
458458 return Mono .error (new IllegalArgumentException ("Tool names must not be null" ));
459459 }
460+ if (this .serverCapabilities .tools () == null ) {
461+ return Mono .error (new IllegalStateException ("Server must be configured with tool capabilities" ));
462+ }
460463 if (toolNames .isEmpty ()) {
461464 return Mono .empty ();
462465 }
463466
464467 Set <String > toolNamesToRemove = new HashSet <>();
465- for (String toolName : new ArrayList <>( toolNames ) ) {
468+ for (String toolName : toolNames ) {
466469 if (toolName == null ) {
467470 return Mono .error (new IllegalArgumentException ("Tool name must not be null" ));
468471 }
469472 toolNamesToRemove .add (toolName );
470473 }
471- if (this .serverCapabilities .tools () == null ) {
472- return Mono .error (new IllegalStateException ("Server must be configured with tool capabilities" ));
473- }
474+
474475
475476 return Mono .defer (() -> {
476477 if (this .tools .removeIf (toolSpecification -> toolNamesToRemove .contains (toolSpecification .tool ().name ()))) {
You can’t perform that action at this time.
0 commit comments