4242from mcp .server .streamable_http_manager import StreamableHTTPSessionManager
4343from mcp .server .transport_security import TransportSecuritySettings
4444from mcp .shared .context import LifespanContextT , RequestContext , RequestT
45- from mcp .types import AnyFunction , ContentBlock , GetPromptResult , ToolAnnotations
45+ from mcp .types import AnyFunction , ContentBlock , GetPromptResult , Icon , ToolAnnotations
4646from mcp .types import Prompt as MCPPrompt
4747from mcp .types import PromptArgument as MCPPromptArgument
4848from mcp .types import Resource as MCPResource
@@ -123,6 +123,8 @@ def __init__(
123123 self ,
124124 name : str | None = None ,
125125 instructions : str | None = None ,
126+ website_url : str | None = None ,
127+ icons : list [Icon ] | None = None ,
126128 auth_server_provider : OAuthAuthorizationServerProvider [Any , Any , Any ] | None = None ,
127129 token_verifier : TokenVerifier | None = None ,
128130 event_store : EventStore | None = None ,
@@ -169,6 +171,8 @@ def __init__(
169171 self ._mcp_server = MCPServer (
170172 name = name or "FastMCP" ,
171173 instructions = instructions ,
174+ website_url = website_url ,
175+ icons = icons ,
172176 # TODO(Marcelo): It seems there's a type mismatch between the lifespan type from an FastMCP and Server.
173177 # We need to create a Lifespan type that is a generic on the server type, like Starlette does.
174178 lifespan = (lifespan_wrapper (self , self .settings .lifespan ) if self .settings .lifespan else default_lifespan ), # type: ignore
@@ -276,6 +280,7 @@ async def list_tools(self) -> list[MCPTool]:
276280 inputSchema = info .parameters ,
277281 outputSchema = info .output_schema ,
278282 annotations = info .annotations ,
283+ icons = info .icons ,
279284 )
280285 for info in tools
281286 ]
@@ -307,6 +312,7 @@ async def list_resources(self) -> list[MCPResource]:
307312 title = resource .title ,
308313 description = resource .description ,
309314 mimeType = resource .mime_type ,
315+ icons = resource .icons ,
310316 )
311317 for resource in resources
312318 ]
@@ -344,6 +350,7 @@ def add_tool(
344350 title : str | None = None ,
345351 description : str | None = None ,
346352 annotations : ToolAnnotations | None = None ,
353+ icons : list [Icon ] | None = None ,
347354 structured_output : bool | None = None ,
348355 ) -> None :
349356 """Add a tool to the server.
@@ -368,6 +375,7 @@ def add_tool(
368375 title = title ,
369376 description = description ,
370377 annotations = annotations ,
378+ icons = icons ,
371379 structured_output = structured_output ,
372380 )
373381
@@ -377,6 +385,7 @@ def tool(
377385 title : str | None = None ,
378386 description : str | None = None ,
379387 annotations : ToolAnnotations | None = None ,
388+ icons : list [Icon ] | None = None ,
380389 structured_output : bool | None = None ,
381390 ) -> Callable [[AnyFunction ], AnyFunction ]:
382391 """Decorator to register a tool.
@@ -423,6 +432,7 @@ def decorator(fn: AnyFunction) -> AnyFunction:
423432 title = title ,
424433 description = description ,
425434 annotations = annotations ,
435+ icons = icons ,
426436 structured_output = structured_output ,
427437 )
428438 return fn
@@ -463,6 +473,7 @@ def resource(
463473 title : str | None = None ,
464474 description : str | None = None ,
465475 mime_type : str | None = None ,
476+ icons : list [Icon ] | None = None ,
466477 ) -> Callable [[AnyFunction ], AnyFunction ]:
467478 """Decorator to register a function as a resource.
468479
@@ -531,6 +542,7 @@ def decorator(fn: AnyFunction) -> AnyFunction:
531542 title = title ,
532543 description = description ,
533544 mime_type = mime_type ,
545+ # Note: Resource templates don't support icons
534546 )
535547 else :
536548 # Register as regular resource
@@ -541,6 +553,7 @@ def decorator(fn: AnyFunction) -> AnyFunction:
541553 title = title ,
542554 description = description ,
543555 mime_type = mime_type ,
556+ icons = icons ,
544557 )
545558 self .add_resource (resource )
546559 return fn
@@ -556,7 +569,11 @@ def add_prompt(self, prompt: Prompt) -> None:
556569 self ._prompt_manager .add_prompt (prompt )
557570
558571 def prompt (
559- self , name : str | None = None , title : str | None = None , description : str | None = None
572+ self ,
573+ name : str | None = None ,
574+ title : str | None = None ,
575+ description : str | None = None ,
576+ icons : list [Icon ] | None = None ,
560577 ) -> Callable [[AnyFunction ], AnyFunction ]:
561578 """Decorator to register a prompt.
562579
@@ -600,7 +617,7 @@ async def analyze_file(path: str) -> list[Message]:
600617 )
601618
602619 def decorator (func : AnyFunction ) -> AnyFunction :
603- prompt = Prompt .from_function (func , name = name , title = title , description = description )
620+ prompt = Prompt .from_function (func , name = name , title = title , description = description , icons = icons )
604621 self .add_prompt (prompt )
605622 return func
606623
@@ -971,6 +988,7 @@ async def list_prompts(self) -> list[MCPPrompt]:
971988 )
972989 for arg in (prompt .arguments or [])
973990 ],
991+ icons = prompt .icons ,
974992 )
975993 for prompt in prompts
976994 ]
0 commit comments