@@ -376,6 +376,7 @@ async def list_resources(self) -> list[MCPResource]:
376376 mimeType = resource .mime_type ,
377377 icons = resource .icons ,
378378 annotations = resource .annotations ,
379+ _meta = resource .meta ,
379380 )
380381 for resource in resources
381382 ]
@@ -391,6 +392,7 @@ async def list_resource_templates(self) -> list[MCPResourceTemplate]:
391392 mimeType = template .mime_type ,
392393 icons = template .icons ,
393394 annotations = template .annotations ,
395+ _meta = template .meta ,
394396 )
395397 for template in templates
396398 ]
@@ -405,7 +407,7 @@ async def read_resource(self, uri: AnyUrl | str) -> Iterable[ReadResourceContent
405407
406408 try :
407409 content = await resource .read ()
408- return [ReadResourceContents (content = content , mime_type = resource .mime_type )]
410+ return [ReadResourceContents (content = content , mime_type = resource .mime_type , meta = resource . meta )]
409411 except Exception as e : # pragma: no cover
410412 logger .exception (f"Error reading resource { uri } " )
411413 raise ResourceError (str (e ))
@@ -557,6 +559,7 @@ def resource(
557559 mime_type : str | None = None ,
558560 icons : list [Icon ] | None = None ,
559561 annotations : Annotations | None = None ,
562+ meta : dict [str , Any ] | None = None ,
560563 ) -> Callable [[AnyFunction ], AnyFunction ]:
561564 """Decorator to register a function as a resource.
562565
@@ -575,6 +578,7 @@ def resource(
575578 title: Optional human-readable title for the resource
576579 description: Optional description of the resource
577580 mime_type: Optional MIME type for the resource
581+ meta: Optional metadata dictionary for the resource
578582
579583 Example:
580584 @server.resource("resource://my-resource")
@@ -633,6 +637,7 @@ def decorator(fn: AnyFunction) -> AnyFunction:
633637 mime_type = mime_type ,
634638 icons = icons ,
635639 annotations = annotations ,
640+ meta = meta ,
636641 )
637642 else :
638643 # Register as regular resource
@@ -645,6 +650,7 @@ def decorator(fn: AnyFunction) -> AnyFunction:
645650 mime_type = mime_type ,
646651 icons = icons ,
647652 annotations = annotations ,
653+ meta = meta ,
648654 )
649655 self .add_resource (resource )
650656 return fn
0 commit comments