1212from mcp .server .fastmcp .resources .types import FunctionResource , Resource
1313from mcp .server .fastmcp .utilities .context_injection import find_context_parameter , inject_context
1414from mcp .server .fastmcp .utilities .func_metadata import func_metadata
15+ from mcp .types import Icon
1516
1617if TYPE_CHECKING :
1718 from mcp .server .fastmcp .server import Context
@@ -27,6 +28,7 @@ class ResourceTemplate(BaseModel):
2728 title : str | None = Field (description = "Human-readable title of the resource" , default = None )
2829 description : str | None = Field (description = "Description of what the resource does" )
2930 mime_type : str = Field (default = "text/plain" , description = "MIME type of the resource content" )
31+ icons : list [Icon ] | None = Field (default = None , description = "Optional list of icons for the resource template" )
3032 fn : Callable [..., Any ] = Field (exclude = True )
3133 parameters : dict [str , Any ] = Field (description = "JSON schema for function parameters" )
3234 context_kwarg : str | None = Field (None , description = "Name of the kwarg that should receive context" )
@@ -40,6 +42,7 @@ def from_function(
4042 title : str | None = None ,
4143 description : str | None = None ,
4244 mime_type : str | None = None ,
45+ icons : list [Icon ] | None = None ,
4346 context_kwarg : str | None = None ,
4447 ) -> ResourceTemplate :
4548 """Create a template from a function."""
@@ -67,6 +70,7 @@ def from_function(
6770 title = title ,
6871 description = description or fn .__doc__ or "" ,
6972 mime_type = mime_type or "text/plain" ,
73+ icons = icons ,
7074 fn = fn ,
7175 parameters = parameters ,
7276 context_kwarg = context_kwarg ,
@@ -103,7 +107,7 @@ async def create_resource(
103107 title = self .title ,
104108 description = self .description ,
105109 mime_type = self .mime_type ,
106- icons = None , # Resource templates don't support icons
110+ icons = self . icons ,
107111 fn = lambda : result , # Capture result in closure
108112 )
109113 except Exception as e :
0 commit comments