File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 55from mcp .server .fastmcp import Context , FastMCP , Image
66from mcp .server .session import ServerSession
77from mcp .types import (
8+ Annotations ,
89 BlobResourceContents ,
910 CreateMessageResult ,
1011 EmbeddedResource ,
@@ -120,7 +121,11 @@ async def get_product_name_link() -> ResourceLink:
120121 )
121122
122123
123- @mcp .resource ('resource://product_name.txt' , mime_type = 'text/plain' )
124+ @mcp .resource (
125+ 'resource://product_name.txt' ,
126+ mime_type = 'text/plain' ,
127+ annotations = Annotations (audience = ['user' , 'assistant' ], priority = 0.5 ),
128+ )
124129async def product_name_resource () -> str :
125130 return Path (__file__ ).parent .joinpath ('assets/product_name.txt' ).read_text ()
126131
Original file line number Diff line number Diff line change @@ -330,14 +330,20 @@ async def test_stdio_server_list_resources(run_context: RunContext[int]):
330330 assert resources [0 ].uri == snapshot ('resource://kiwi.png' )
331331 assert resources [0 ].mime_type == snapshot ('image/png' )
332332 assert resources [0 ].name == snapshot ('kiwi_resource' )
333+ assert resources [0 ].annotations is None
333334
334335 assert resources [1 ].uri == snapshot ('resource://marcelo.mp3' )
335336 assert resources [1 ].mime_type == snapshot ('audio/mpeg' )
336337 assert resources [1 ].name == snapshot ('marcelo_resource' )
338+ assert resources [1 ].annotations is None
337339
338340 assert resources [2 ].uri == snapshot ('resource://product_name.txt' )
339341 assert resources [2 ].mime_type == snapshot ('text/plain' )
340342 assert resources [2 ].name == snapshot ('product_name_resource' )
343+ # Test ResourceAnnotations
344+ assert resources [2 ].annotations is not None
345+ assert resources [2 ].annotations .audience == snapshot (['user' , 'assistant' ])
346+ assert resources [2 ].annotations .priority == snapshot (0.5 )
341347
342348
343349async def test_stdio_server_list_resource_templates (run_context : RunContext [int ]):
You can’t perform that action at this time.
0 commit comments