Skip to content

Refactor resource behavior and add meta support#2611

Merged
jlowin merged 2 commits intomainfrom
revert-2609-revert-2598-resource-content-canonical
Dec 15, 2025
Merged

Refactor resource behavior and add meta support#2611
jlowin merged 2 commits intomainfrom
revert-2609-revert-2598-resource-content-canonical

Conversation

@jlowin
Copy link
Copy Markdown
Member

@jlowin jlowin commented Dec 13, 2025

Important: this was already merged in #2598 and reverted in #2609 because I want to hold it for 2.15.0. This is the new PR with the same logic.


Resources can now include metadata via ResourceContent.meta, giving resource authors a way to pass structured information alongside content.

@mcp.resource("data://report")
def get_report() -> ResourceContent:
    return ResourceContent(
        content="Report data...",
        mime_type="text/plain",
        meta={"generated_at": "2024-01-15", "version": 2}
    )

Internally, this represents a significant refactor of resource result handling, with ResourceContent now the canonical type for all resource reads. Custom resources returning str or bytes from read() continue to work with a deprecation warning when enabled.

@jlowin jlowin added the DON'T MERGE PR is not ready for merging. Used by authors to prevent premature merging. label Dec 13, 2025
@jlowin jlowin added this to the 2.15 milestone Dec 13, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 13, 2025

Warning

Rate limit exceeded

@jlowin has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 56 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 2f561ec and c5640e1.

⛔ Files ignored due to path filters (6)
  • tests/resources/test_file_resources.py is excluded by none and included by none
  • tests/resources/test_function_resources.py is excluded by none and included by none
  • tests/resources/test_resource_manager.py is excluded by none and included by none
  • tests/resources/test_resource_template.py is excluded by none and included by none
  • tests/server/middleware/test_tool_injection.py is excluded by none and included by none
  • tests/server/test_server.py is excluded by none and included by none
📒 Files selected for processing (13)
  • docs/servers/resources.mdx (1 hunks)
  • src/fastmcp/resources/__init__.py (2 hunks)
  • src/fastmcp/resources/resource.py (4 hunks)
  • src/fastmcp/resources/resource_manager.py (3 hunks)
  • src/fastmcp/resources/types.py (5 hunks)
  • src/fastmcp/server/context.py (2 hunks)
  • src/fastmcp/server/middleware/caching.py (5 hunks)
  • src/fastmcp/server/middleware/middleware.py (2 hunks)
  • src/fastmcp/server/middleware/tool_injection.py (2 hunks)
  • src/fastmcp/server/openapi/components.py (3 hunks)
  • src/fastmcp/server/proxy.py (8 hunks)
  • src/fastmcp/server/server.py (8 hunks)
  • src/fastmcp/server/tasks/converters.py (3 hunks)
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch revert-2609-revert-2598-resource-content-canonical

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@marvin-context-protocol marvin-context-protocol Bot added enhancement Improvement to existing functionality. For issues and smaller PR improvements. server Related to FastMCP server implementation or server-side functionality. labels Dec 13, 2025
@jlowin jlowin added feature Major new functionality. Reserved for 2-4 significant PRs per release. Not for issues. and removed enhancement Improvement to existing functionality. For issues and smaller PR improvements. DON'T MERGE PR is not ready for merging. Used by authors to prevent premature merging. labels Dec 13, 2025
@jlowin jlowin merged commit 5f3bb05 into main Dec 15, 2025
13 checks passed
@jlowin jlowin deleted the revert-2609-revert-2598-resource-content-canonical branch December 15, 2025 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Major new functionality. Reserved for 2-4 significant PRs per release. Not for issues. server Related to FastMCP server implementation or server-side functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant