Skip to content

Commit 607976e

Browse files
Update README snippets
1 parent 3459880 commit 607976e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,9 +886,10 @@ async def generate_poem(topic: str, ctx: Context[ServerSession, None]) -> str:
886886
max_tokens=100,
887887
)
888888

889-
if result.content.type == "text":
890-
return result.content.text
891-
return str(result.content)
889+
content = result.content[0] if isinstance(result.content, list) else result.content
890+
if content.type == "text":
891+
return content.text
892+
return str(content)
892893
```
893894

894895
_Full example: [examples/snippets/servers/sampling.py](https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/snippets/servers/sampling.py)_

0 commit comments

Comments
 (0)