@@ -358,6 +358,7 @@ async def list_resources(self) -> list[MCPResource]:
358358 mimeType = resource .mime_type ,
359359 icons = resource .icons ,
360360 annotations = resource .annotations ,
361+ _meta = resource .meta ,
361362 )
362363 for resource in resources
363364 ]
@@ -373,6 +374,7 @@ async def list_resource_templates(self) -> list[MCPResourceTemplate]:
373374 mimeType = template .mime_type ,
374375 icons = template .icons ,
375376 annotations = template .annotations ,
377+ _meta = template .meta ,
376378 )
377379 for template in templates
378380 ]
@@ -387,7 +389,7 @@ async def read_resource(self, uri: AnyUrl | str) -> Iterable[ReadResourceContent
387389
388390 try :
389391 content = await resource .read ()
390- return [ReadResourceContents (content = content , mime_type = resource .mime_type )]
392+ return [ReadResourceContents (content = content , mime_type = resource .mime_type , meta = resource . meta )]
391393 except Exception as e : # pragma: no cover
392394 logger .exception (f"Error reading resource { uri } " )
393395 raise ResourceError (str (e ))
@@ -539,6 +541,7 @@ def resource(
539541 mime_type : str | None = None ,
540542 icons : list [Icon ] | None = None ,
541543 annotations : Annotations | None = None ,
544+ meta : dict [str , Any ] | None = None ,
542545 ) -> Callable [[AnyFunction ], AnyFunction ]:
543546 """Decorator to register a function as a resource.
544547
@@ -557,6 +560,7 @@ def resource(
557560 title: Optional human-readable title for the resource
558561 description: Optional description of the resource
559562 mime_type: Optional MIME type for the resource
563+ meta: Optional metadata dictionary for the resource
560564
561565 Example:
562566 @server.resource("resource://my-resource")
@@ -615,6 +619,7 @@ def decorator(fn: AnyFunction) -> AnyFunction:
615619 mime_type = mime_type ,
616620 icons = icons ,
617621 annotations = annotations ,
622+ meta = meta ,
618623 )
619624 else :
620625 # Register as regular resource
@@ -627,6 +632,7 @@ def decorator(fn: AnyFunction) -> AnyFunction:
627632 mime_type = mime_type ,
628633 icons = icons ,
629634 annotations = annotations ,
635+ meta = meta ,
630636 )
631637 self .add_resource (resource )
632638 return fn
0 commit comments