File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
examples/servers/simple-resource/mcp_simple_resource Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 22import click
33import mcp .types as types
44from mcp .server .lowlevel import Server
5+ from mcp .server .lowlevel .helper_types import ReadResourceContents
56from pydantic import AnyUrl , FileUrl
67from starlette .requests import Request
78
@@ -46,15 +47,15 @@ async def list_resources() -> list[types.Resource]:
4647 ]
4748
4849 @app .read_resource ()
49- async def read_resource (uri : AnyUrl ) -> str | bytes :
50+ async def read_resource (uri : AnyUrl ):
5051 if uri .path is None :
5152 raise ValueError (f"Invalid resource path: { uri } " )
5253 name = uri .path .replace (".txt" , "" ).lstrip ("/" )
5354
5455 if name not in SAMPLE_RESOURCES :
5556 raise ValueError (f"Unknown resource: { uri } " )
5657
57- return SAMPLE_RESOURCES [name ]["content" ]
58+ return [ ReadResourceContents ( content = SAMPLE_RESOURCES [name ]["content" ], mime_type = "text/plain" ) ]
5859
5960 if transport == "sse" :
6061 from mcp .server .sse import SseServerTransport
You can’t perform that action at this time.
0 commit comments