-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Docs: Update CallToolResult parsing in README #812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d413cd7
to
e896ce2
Compare
Instead of inline parsing examples in basic client code, this commit adds a dedicated 'Parsing Tool Results' section under Advanced Usage that comprehensively documents: - The structure of CallToolResult (content, structuredContent, isError) - How to parse different content types (TextContent, ImageContent, EmbeddedResource, ResourceLink) - Structured output handling for tools with outputSchema - Proper error handling using the isError field This provides a cleaner, more comprehensive reference for developers working with tool results in MCP. Github-Issue: modelcontextprotocol#812
The example in README.md for parsing the result of `session.call_tool` has been updated to reflect the structure of `CallToolResult`. This change aligns the README example with the type definitions in `mcp/types.py`.
1f979a7
to
93d8496
Compare
- Add new section under Advanced Usage for parsing CallToolResult objects - Create comprehensive example showing all content types (text, structured, embedded resources, images, errors) - Move parsing documentation to a dedicated section instead of inline examples - Improve discoverability and clarity of tool result parsing patterns
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this contribution!
I think adding some parsing examples like this to docs makes sense - but I don't think we should be modifying existing code snippets + duplicate it in multiple places.
I've instead created a new section part of Advanced Usage
specifically for parsing tool results of different types as an example and pushed that to this PR.
Co-authored-by: Felix Weinberger <fweinberger@anthropic.com>
The example in README.md for parsing the result of
session.call_tool
has been updated to reflect the structure ofCallToolResult
.This change aligns the README example with the type definitions in
mcp/types.py
.Motivation and Context
How Has This Been Tested?
Breaking Changes
Types of changes
Checklist
Additional context