python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

Add support for _meta attributes in resource contents

Open calvingiles opened this issue 1 month ago • 1 comments

This change enables MCP servers to include metadata in resource content using the _meta field, which is part of the MCP specification. This allows servers to provide additional context about resources, such as domain information or other custom metadata.

Changes:

  • Added meta field to ReadResourceContents helper class
  • Added _meta field to Resource base class with proper alias
  • Updated lowlevel server handler to pass through _meta when creating TextResourceContents and BlobResourceContents
  • Updated FastMCP server to pass resource._meta to ReadResourceContents
  • Added comprehensive tests for _meta support in both lowlevel and FastMCP resources

The implementation maintains backward compatibility - resources without _meta continue to work as before with meta=None.

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

calvingiles avatar Nov 18 '25 06:11 calvingiles

related: https://github.com/modelcontextprotocol/python-sdk/pull/1476

maxisbey avatar Nov 20 '25 14:11 maxisbey

Before this is merged, is there any workaround?

serranoarevalo avatar Dec 09 '25 23:12 serranoarevalo