Skip to content

Commit e72d176

Browse files
Remove redundant inline parsing examples
The original author's inline parsing examples are now redundant since we have a dedicated 'Parsing Tool Results' section under Advanced Usage. This commit removes all the duplicated content, keeping the documentation clean and focused.
1 parent 92e082b commit e72d176

File tree

1 file changed

+1
-49
lines changed

1 file changed

+1
-49
lines changed

README.md

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,28 +1411,6 @@ async def run():
14111411

14121412
# Call a tool (add tool from fastmcp_quickstart)
14131413
result = await session.call_tool("add", arguments={"a": 5, "b": 3})
1414-
# Parse the result (type: CallToolResult)
1415-
for item in result.content:
1416-
if isinstance(item, types.TextContent):
1417-
# Extract text directly from TextContent
1418-
print(f"Tool output (TextContent): {item.text}")
1419-
elif isinstance(item, types.EmbeddedResource):
1420-
# Check if the embedded resource contains text
1421-
if isinstance(item.resource, types.TextResourceContents):
1422-
print(
1423-
f"Tool output (EmbeddedResource - Text): {item.resource.text}"
1424-
)
1425-
elif isinstance(item.resource, types.BlobResourceContents):
1426-
print(
1427-
f"Tool output (EmbeddedResource - Blob): URI {item.resource.uri}, MIME Type {item.resource.mimeType}"
1428-
)
1429-
elif isinstance(item, types.ImageContent):
1430-
# Showing only a snippet of image data
1431-
print(
1432-
f"Tool output (ImageContent): MIME Type {item.mimeType}, Data (base64): {item.data[:30]}..."
1433-
)
1434-
else:
1435-
print(f"Tool output (Unknown Content Type): {type(item)}")
14361414

14371415

14381416
def main():
@@ -1458,7 +1436,7 @@ Run from the repository root:
14581436

14591437
import asyncio
14601438

1461-
from mcp import ClientSession, types
1439+
from mcp import ClientSession
14621440
from mcp.client.streamable_http import streamablehttp_client
14631441

14641442

@@ -1479,32 +1457,6 @@ async def main():
14791457

14801458
# Call a tool
14811459
tool_result = await session.call_tool("echo", {"message": "hello"})
1482-
# Parse the result (type: CallToolResult)
1483-
for item in tool_result.content:
1484-
if isinstance(item, types.TextContent):
1485-
# Extract text directly from TextContent
1486-
print(f"Tool output (TextContent): {item.text}")
1487-
elif isinstance(item, types.EmbeddedResource):
1488-
# Check if the embedded resource contains text
1489-
if isinstance(item.resource, types.TextResourceContents):
1490-
print(
1491-
f"Tool output (EmbeddedResource - Text): {item.resource.text}"
1492-
)
1493-
elif isinstance(item.resource, types.BlobResourceContents):
1494-
print(
1495-
f"Tool output (EmbeddedResource - Blob): URI {item.resource.uri}, MIME Type {item.resource.mimeType}"
1496-
)
1497-
elif isinstance(item, types.ImageContent):
1498-
# Showing only a snippet of image data
1499-
print(
1500-
f"Tool output (ImageContent): MIME Type {item.mimeType}, Data (base64): {item.data[:30]}..."
1501-
)
1502-
else:
1503-
print(f"Tool output (Unknown Content Type): {type(item)}")
1504-
1505-
1506-
if __name__ == "__main__":
1507-
asyncio.run(main())
15081460
```
15091461

15101462
_Full example: [examples/snippets/clients/streamable_basic.py](https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/snippets/clients/streamable_basic.py)_

0 commit comments

Comments
 (0)