Skip to content

Conversation

pja-ant
Copy link
Contributor

@pja-ant pja-ant commented Sep 1, 2025

Returning str | bytes from read_resource functions is deprecated. Updating this example to use Iterable[ReadResourceContents].

🤖 Generated with Claude Code

Motivation and Context

Examples should use the preferred APIs to set a good example and help users understand how to use the APIs. See e.g. #1320

How Has This Been Tested?

npx -y @modelcontextprotocol/inspector uv run mcp-simple-resource

Fetched all resources via inspector.

Breaking Changes

N/A

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

N/A

…turn type

Changed the read_resource handler to return Iterable[ReadResourceContents]
instead of a plain string, following the recommended pattern and avoiding
deprecation warnings.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@pja-ant pja-ant requested a review from a team as a code owner September 1, 2025 16:47
@pja-ant pja-ant requested a review from Kludex September 1, 2025 16:47
Copy link
Contributor

@ihrpr ihrpr 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!

This example is low-level server, maybe worth updating it to highlevel (fastmcp which will be renamed)

@ihrpr ihrpr merged commit 356dfa6 into main Sep 1, 2025
21 checks passed
@ihrpr ihrpr deleted the pja-ant/improve-read_resource-docs branch September 1, 2025 16:58
@pja-ant
Copy link
Contributor Author

pja-ant commented Sep 2, 2025

Thank you!

This example is low-level server, maybe worth updating it to highlevel (fastmcp which will be renamed)

It seems that samples are currently split into examples/fastmcp for FastMCP samples and examples/server for low-level server samples, so it seems intentional that this is using the low-level server? Happy to make the change, but seems intentional that it is this way?

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