1010
1111async def test_icons_and_website_url ():
1212 """Test that icons and websiteUrl are properly returned in API calls."""
13-
13+
1414 # Create test icon
1515 test_icon = Icon (
1616 src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==" ,
1717 mimeType = "image/png" ,
18- sizes = "1x1"
18+ sizes = "1x1" ,
1919 )
20-
20+
2121 # Create server with website URL and icon
22- mcp = FastMCP (
23- "TestServer" ,
24- website_url = "https://example.com" ,
25- icons = [test_icon ]
26- )
27-
22+ mcp = FastMCP ("TestServer" , website_url = "https://example.com" , icons = [test_icon ])
23+
2824 # Create tool with icon
2925 @mcp .tool (icons = [test_icon ])
3026 def test_tool (message : str ) -> str :
3127 """A test tool with an icon."""
3228 return message
33-
29+
3430 # Create resource with icon
3531 @mcp .resource ("test://resource" , icons = [test_icon ])
3632 def test_resource () -> str :
3733 """A test resource with an icon."""
3834 return "test content"
39-
35+
4036 # Create prompt with icon
4137 @mcp .prompt ("test_prompt" , icons = [test_icon ])
4238 def test_prompt (text : str ) -> str :
4339 """A test prompt with an icon."""
4440 return text
45-
41+
4642 # Test server metadata includes websiteUrl and icons
4743 assert mcp .name == "TestServer"
4844 assert mcp .website_url == "https://example.com"
@@ -51,7 +47,7 @@ def test_prompt(text: str) -> str:
5147 assert mcp .icons [0 ].src == test_icon .src
5248 assert mcp .icons [0 ].mimeType == test_icon .mimeType
5349 assert mcp .icons [0 ].sizes == test_icon .sizes
54-
50+
5551 # Test tool includes icon
5652 tools = await mcp .list_tools ()
5753 assert len (tools ) == 1
@@ -60,7 +56,7 @@ def test_prompt(text: str) -> str:
6056 assert tool .icons is not None
6157 assert len (tool .icons ) == 1
6258 assert tool .icons [0 ].src == test_icon .src
63-
59+
6460 # Test resource includes icon
6561 resources = await mcp .list_resources ()
6662 assert len (resources ) == 1
@@ -69,7 +65,7 @@ def test_prompt(text: str) -> str:
6965 assert resource .icons is not None
7066 assert len (resource .icons ) == 1
7167 assert resource .icons [0 ].src == test_icon .src
72-
68+
7369 # Test prompt includes icon
7470 prompts = await mcp .list_prompts ()
7571 assert len (prompts ) == 1
@@ -82,20 +78,20 @@ def test_prompt(text: str) -> str:
8278
8379async def test_multiple_icons ():
8480 """Test that multiple icons can be added to tools, resources, and prompts."""
85-
81+
8682 # Create multiple test icons
8783 icon1 = Icon (src = "data:image/png;base64,icon1" , mimeType = "image/png" , sizes = "16x16" )
8884 icon2 = Icon (src = "data:image/png;base64,icon2" , mimeType = "image/png" , sizes = "32x32" )
8985 icon3 = Icon (src = "data:image/png;base64,icon3" , mimeType = "image/png" , sizes = "64x64" )
90-
86+
9187 mcp = FastMCP ("MultiIconServer" )
92-
88+
9389 # Create tool with multiple icons
9490 @mcp .tool (icons = [icon1 , icon2 , icon3 ])
9591 def multi_icon_tool () -> str :
9692 """A tool with multiple icons."""
9793 return "success"
98-
94+
9995 # Test tool has all icons
10096 tools = await mcp .list_tools ()
10197 assert len (tools ) == 1
@@ -109,19 +105,19 @@ def multi_icon_tool() -> str:
109105
110106async def test_no_icons_or_website ():
111107 """Test that server works without icons or websiteUrl."""
112-
108+
113109 mcp = FastMCP ("BasicServer" )
114-
110+
115111 @mcp .tool ()
116112 def basic_tool () -> str :
117113 """A basic tool without icons."""
118114 return "success"
119-
115+
120116 # Test server metadata has no websiteUrl or icons
121117 assert mcp .name == "BasicServer"
122118 assert mcp .website_url is None
123119 assert mcp .icons is None
124-
120+
125121 # Test tool has no icons
126122 tools = await mcp .list_tools ()
127123 assert len (tools ) == 1
0 commit comments