mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2025-12-24 01:04:20 +01:00
docs: update read_resource examples to handle mime type
Update README examples to show proper handling of the new read_resource() return value that includes mime type information. Github-Issue:#152
This commit is contained in:
@@ -218,7 +218,7 @@ async def long_task(files: list[str], ctx: Context) -> str:
|
||||
for i, file in enumerate(files):
|
||||
ctx.info(f"Processing {file}")
|
||||
await ctx.report_progress(i, len(files))
|
||||
data = await ctx.read_resource(f"file://{file}")
|
||||
data, mime_type = await ctx.read_resource(f"file://{file}")
|
||||
return "Processing complete"
|
||||
```
|
||||
|
||||
@@ -436,7 +436,7 @@ async def run():
|
||||
tools = await session.list_tools()
|
||||
|
||||
# Read a resource
|
||||
resource = await session.read_resource("file://some/path")
|
||||
content, mime_type = await session.read_resource("file://some/path")
|
||||
|
||||
# Call a tool
|
||||
result = await session.call_tool("tool-name", arguments={"arg1": "value"})
|
||||
|
||||
Reference in New Issue
Block a user