@@ -727,6 +727,92 @@ await client.SendNotificationAsync(
727727 await Assert . ThrowsAnyAsync < OperationCanceledException > ( async ( ) => await invokeTask ) ;
728728 }
729729
730+ [ Fact ]
731+ public async Task Can_Retrieve_Tool_Icons ( )
732+ {
733+ // Create a server with a tool that has icons
734+ var services = new ServiceCollection ( ) ;
735+ var builder = services . AddMcpServer ( ) ;
736+
737+ var toolWithIcons = McpServerTool . Create ( [ McpServerTool ( IconSource = "https://example.com/tool-icon.png" ) ] ( ) => "result" ) ;
738+ builder . WithTools ( [ toolWithIcons ] ) ;
739+
740+ await using var serviceProvider = services . BuildServiceProvider ( ) ;
741+ var options = serviceProvider . GetRequiredService < IOptions < McpServerOptions > > ( ) . Value ;
742+ var loggerFactory = serviceProvider . GetRequiredService < ILoggerFactory > ( ) ;
743+
744+ var stdinPipe = new Pipe ( ) ;
745+ var stdoutPipe = new Pipe ( ) ;
746+
747+ await using var transport = new StreamServerTransport ( stdinPipe . Reader . AsStream ( ) , stdoutPipe . Writer . AsStream ( ) ) ;
748+ await using var server = McpServer . Create ( transport , options , loggerFactory , serviceProvider ) ;
749+ var serverRunTask = server . RunAsync ( TestContext . Current . CancellationToken ) ;
750+
751+ await using var client = await McpClient . ConnectAsync (
752+ new StreamClientTransport ( stdoutPipe . Reader . AsStream ( ) , stdinPipe . Writer . AsStream ( ) ) ,
753+ new McpClientInfo { Name = "test-client" , Version = "1.0.0" } ,
754+ cancellationToken : TestContext . Current . CancellationToken ) ;
755+
756+ // List tools and verify icons are present
757+ var tools = await client . ListToolsAsync ( cancellationToken : TestContext . Current . CancellationToken ) ;
758+
759+ var toolWithIconsResult = tools . FirstOrDefault ( ) ;
760+ Assert . NotNull ( toolWithIconsResult ) ;
761+ Assert . NotNull ( toolWithIconsResult . Icons ) ;
762+ Assert . Single ( toolWithIconsResult . Icons ) ;
763+ Assert . Equal ( "https://example.com/tool-icon.png" , toolWithIconsResult . Icons [ 0 ] . Source ) ;
764+ }
765+
766+ [ Fact ]
767+ public async Task Can_Retrieve_Implementation_Icons_And_WebsiteUrl ( )
768+ {
769+ // Create a server with implementation icons and website URL
770+ var services = new ServiceCollection ( ) ;
771+ var builder = services . AddMcpServer ( options =>
772+ {
773+ options . ServerInfo = new Implementation
774+ {
775+ Name = "test-server" ,
776+ Version = "1.0.0" ,
777+ Icons = new List < Icon >
778+ {
779+ new ( ) { Source = "https://example.com/server-icon.png" , MimeType = "image/png" , Sizes = new List < string > { "64x64" } }
780+ } ,
781+ WebsiteUrl = "https://example.com/docs"
782+ } ;
783+ } ) ;
784+
785+ await using var serviceProvider = services . BuildServiceProvider ( ) ;
786+ var options = serviceProvider . GetRequiredService < IOptions < McpServerOptions > > ( ) . Value ;
787+ var loggerFactory = serviceProvider . GetRequiredService < ILoggerFactory > ( ) ;
788+
789+ var stdinPipe = new Pipe ( ) ;
790+ var stdoutPipe = new Pipe ( ) ;
791+
792+ await using var transport = new StreamServerTransport ( stdinPipe . Reader . AsStream ( ) , stdoutPipe . Writer . AsStream ( ) ) ;
793+ await using var server = McpServer . Create ( transport , options , loggerFactory , serviceProvider ) ;
794+ var serverRunTask = server . RunAsync ( TestContext . Current . CancellationToken ) ;
795+
796+ await using var client = await McpClient . ConnectAsync (
797+ new StreamClientTransport ( stdoutPipe . Reader . AsStream ( ) , stdinPipe . Writer . AsStream ( ) ) ,
798+ new McpClientInfo { Name = "test-client" , Version = "1.0.0" } ,
799+ cancellationToken : TestContext . Current . CancellationToken ) ;
800+
801+ // Verify server info contains icons and website URL
802+ var serverInfo = client . ServerInfo ;
803+ Assert . NotNull ( serverInfo ) ;
804+ Assert . Equal ( "test-server" , serverInfo . Name ) ;
805+ Assert . Equal ( "1.0.0" , serverInfo . Version ) ;
806+ Assert . NotNull ( serverInfo . Icons ) ;
807+ Assert . Single ( serverInfo . Icons ) ;
808+ Assert . Equal ( "https://example.com/server-icon.png" , serverInfo . Icons [ 0 ] . Source ) ;
809+ Assert . Equal ( "image/png" , serverInfo . Icons [ 0 ] . MimeType ) ;
810+ Assert . NotNull ( serverInfo . Icons [ 0 ] . Sizes ) ;
811+ Assert . Single ( serverInfo . Icons [ 0 ] . Sizes ) ;
812+ Assert . Equal ( "64x64" , serverInfo . Icons [ 0 ] . Sizes [ 0 ] ) ;
813+ Assert . Equal ( "https://example.com/docs" , serverInfo . WebsiteUrl ) ;
814+ }
815+
730816 [ McpServerToolType ]
731817 public sealed class EchoTool ( ObjectWithId objectFromDI )
732818 {
0 commit comments