You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: implement context injection for resources and prompts in FastMCP
This adds automatic context injection support for both resources and prompts
in the FastMCP framework, allowing these handlers to receive the request
context without explicitly passing it as an argument.
Changes:
- Add context parameter detection in ResourceTemplate and Prompt classes
- Use func_metadata utility to generate schemas while excluding Context params
- Pass context through resource_manager.get_resource() and prompt.render()
- Update server validation to exclude Context params from URI parameter checks
- Add comprehensive test coverage for context injection scenarios
The implementation follows the same pattern already used for tools,
ensuring consistency across all FastMCP handler types.
0 commit comments