feat(fastmcp): add include_in_context parameter to resource decorator #1677
+107
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds a user-friendly
include_in_contextboolean parameter to the@resourcedecorator that automatically setspriority=1.0in annotations. This simplifies marking resources for context inclusion without requiring users to manually create and manageAnnotationsobjects.Closes #1657
Motivation
Currently, users must create an
Annotationsobject to set resource priority for context inclusion:This PR introduces a simpler API:
Implementation
include_in_context=True, automatically setspriority=1.0audienceChanges
FastMCP.resource()decorator to acceptinclude_in_contextparameterpriority=1.0when enabledTest Plan
include_in_context=Truesets priority to 1.0include_in_context=Falsedoesn't affect annotations