Skip to content

Commit 4756128

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 152c562 commit 4756128

File tree

1 file changed

+1
-45
lines changed

1 file changed

+1
-45
lines changed

README.md

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -780,28 +780,6 @@ async def run():
780780

781781
# Call a tool
782782
result = await session.call_tool("tool-name", arguments={"arg1": "value"})
783-
# Parse the result (type: CallToolResult)
784-
for item in result.content:
785-
if isinstance(item, types.TextContent):
786-
# Extract text directly from TextContent
787-
print(f"Tool output (TextContent): {item.text}")
788-
elif isinstance(item, types.EmbeddedResource):
789-
# Check if the embedded resource contains text
790-
if isinstance(item.resource, types.TextResourceContents):
791-
print(
792-
f"Tool output (EmbeddedResource - Text): {item.resource.text}"
793-
)
794-
elif isinstance(item.resource, types.BlobResourceContents):
795-
print(
796-
f"Tool output (EmbeddedResource - Blob): URI {item.resource.uri}, MIME Type {item.resource.mimeType}"
797-
)
798-
elif isinstance(item, types.ImageContent):
799-
# Showing only a snippet of image data
800-
print(
801-
f"Tool output (ImageContent): MIME Type {item.mimeType}, Data (base64): {item.data[:30]}..."
802-
)
803-
else:
804-
print(f"Tool output (Unknown Content Type): {type(item)}")
805783

806784

807785
if __name__ == "__main__":
@@ -814,7 +792,7 @@ Clients can also connect using [Streamable HTTP transport](https://modelcontextp
814792

815793
```python
816794
from mcp.client.streamable_http import streamablehttp_client
817-
from mcp import ClientSession, types
795+
from mcp import ClientSession
818796

819797

820798
async def main():
@@ -830,28 +808,6 @@ async def main():
830808
await session.initialize()
831809
# Call a tool
832810
tool_result = await session.call_tool("echo", {"message": "hello"})
833-
# Parse the result (type: CallToolResult)
834-
for item in tool_result.content:
835-
if isinstance(item, types.TextContent):
836-
# Extract text directly from TextContent
837-
print(f"Tool output (TextContent): {item.text}")
838-
elif isinstance(item, types.EmbeddedResource):
839-
# Check if the embedded resource contains text
840-
if isinstance(item.resource, types.TextResourceContents):
841-
print(
842-
f"Tool output (EmbeddedResource - Text): {item.resource.text}"
843-
)
844-
elif isinstance(item.resource, types.BlobResourceContents):
845-
print(
846-
f"Tool output (EmbeddedResource - Blob): URI {item.resource.uri}, MIME Type {item.resource.mimeType}"
847-
)
848-
elif isinstance(item, types.ImageContent):
849-
# Showing only a snippet of image data
850-
print(
851-
f"Tool output (ImageContent): MIME Type {item.mimeType}, Data (base64): {item.data[:30]}..."
852-
)
853-
else:
854-
print(f"Tool output (Unknown Content Type): {type(item)}")
855811
```
856812

857813
### OAuth Authentication for Clients

0 commit comments

Comments
 (0)