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:
David Soria Parra
2025-01-24 16:59:58 +00:00
parent 8ff4b5e9d3
commit f90cf6a2a5
2 changed files with 3 additions and 3 deletions

View File

@@ -33,7 +33,7 @@ This document contains critical information about working with this codebase. Fo
- For commits related to a Github issue, add - For commits related to a Github issue, add
```bash ```bash
git commit --trailer "Github-Issue:<number>" git commit --trailer "Github-Issue:#<number>"
``` ```
- NEVER ever mention a `co-authored-by` or similar aspects. In particular, never - NEVER ever mention a `co-authored-by` or similar aspects. In particular, never
mention the tool used to create the commit message or PR. mention the tool used to create the commit message or PR.

View File

@@ -218,7 +218,7 @@ async def long_task(files: list[str], ctx: Context) -> str:
for i, file in enumerate(files): for i, file in enumerate(files):
ctx.info(f"Processing {file}") ctx.info(f"Processing {file}")
await ctx.report_progress(i, len(files)) 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" return "Processing complete"
``` ```
@@ -436,7 +436,7 @@ async def run():
tools = await session.list_tools() tools = await session.list_tools()
# Read a resource # Read a resource
resource = await session.read_resource("file://some/path") content, mime_type = await session.read_resource("file://some/path")
# Call a tool # Call a tool
result = await session.call_tool("tool-name", arguments={"arg1": "value"}) result = await session.call_tool("tool-name", arguments={"arg1": "value"})