Skip to content

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

Merged
merged 4 commits into from
Jul 17, 2025

Conversation

functicons
Copy link
Contributor

@functicons functicons commented May 27, 2025

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.

Motivation and Context

How Has This Been Tested?

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@functicons functicons force-pushed the main branch 5 times, most recently from d413cd7 to e896ce2 Compare June 3, 2025 00:39
felixweinberger added a commit to functicons/mcp-python-sdk that referenced this pull request Jul 17, 2025
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`.
@felixweinberger felixweinberger force-pushed the main branch 3 times, most recently from 1f979a7 to 93d8496 Compare July 17, 2025 11:39
- 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.
Copy link
Contributor

@felixweinberger felixweinberger left a 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.

@felixweinberger felixweinberger merged commit dd79297 into modelcontextprotocol:main Jul 17, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants