@@ -705,10 +705,7 @@ public void SupportsIconsInCreateOptions()
705
705
[ Fact ]
706
706
public void SupportsIconSourceInAttribute ( )
707
707
{
708
- MethodInfo ? method = typeof ( IconTestClass ) . GetMethod ( nameof ( IconTestClass . ToolWithIconSource ) ) ;
709
- Assert . NotNull ( method ) ;
710
-
711
- McpServerTool tool = McpServerTool . Create ( method , new IconTestClass ( ) ) ;
708
+ McpServerTool tool = McpServerTool . Create ( [ McpServerTool ( IconSource = "https://example.com/tool-icon.png" ) ] ( ) => "result" ) ;
712
709
713
710
Assert . NotNull ( tool . ProtocolTool . Icons ) ;
714
711
Assert . Single ( tool . ProtocolTool . Icons ) ;
@@ -720,15 +717,12 @@ public void SupportsIconSourceInAttribute()
720
717
[ Fact ]
721
718
public void CreateOptionsIconsOverrideAttributeIconSource ( )
722
719
{
723
- MethodInfo ? method = typeof ( IconTestClass ) . GetMethod ( nameof ( IconTestClass . ToolWithIconSource ) ) ;
724
- Assert . NotNull ( method ) ;
725
-
726
720
var optionsIcons = new List < Icon >
727
721
{
728
722
new ( ) { Source = "https://example.com/override-icon.svg" , MimeType = "image/svg+xml" }
729
723
} ;
730
724
731
- McpServerTool tool = McpServerTool . Create ( method , new IconTestClass ( ) , new McpServerToolCreateOptions
725
+ McpServerTool tool = McpServerTool . Create ( [ McpServerTool ( IconSource = "https://example.com/tool-icon.png" ) ] ( ) => "result" , new McpServerToolCreateOptions
732
726
{
733
727
Icons = optionsIcons
734
728
} ) ;
@@ -742,23 +736,11 @@ public void CreateOptionsIconsOverrideAttributeIconSource()
742
736
[ Fact ]
743
737
public void SupportsToolWithoutIcons ( )
744
738
{
745
- MethodInfo ? method = typeof ( IconTestClass ) . GetMethod ( nameof ( IconTestClass . ToolWithoutIcon ) ) ;
746
- Assert . NotNull ( method ) ;
747
-
748
- McpServerTool tool = McpServerTool . Create ( method , new IconTestClass ( ) ) ;
739
+ McpServerTool tool = McpServerTool . Create ( [ McpServerTool ] ( ) => "result" ) ;
749
740
750
741
Assert . Null ( tool . ProtocolTool . Icons ) ;
751
742
}
752
743
753
- private class IconTestClass
754
- {
755
- [ McpServerTool ( IconSource = "https://example.com/tool-icon.png" ) ]
756
- public string ToolWithIconSource ( ) => "result" ;
757
-
758
- [ McpServerTool ]
759
- public string ToolWithoutIcon ( ) => "result" ;
760
- }
761
-
762
744
[ JsonSourceGenerationOptions ( PropertyNamingPolicy = JsonKnownNamingPolicy . CamelCase ) ]
763
745
[ JsonSerializable ( typeof ( DisposableToolType ) ) ]
764
746
[ JsonSerializable ( typeof ( AsyncDisposableToolType ) ) ]
0 commit comments