-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: enables context injection into resources #413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: enables context injection into resources #413
Conversation
29732d5
to
7a3ea56
Compare
7a3ea56
to
c78d1ac
Compare
context injection into prompts would be great also |
It would be fantastic with this feature! Since most of my endpoints use context, I currently have to wrap them all as tools. |
4445683
to
0790305
Compare
This PR doesn't seem to be enough. We can't read from the |
There seems to be some complexity in how that interacts with the concept of concrete/direct resources vs resource templates. In particular, a resource function might accept only a Context param (for example, if it lists all objects that a user can access). I think this PR would cause those to appear as nullary (0-arg) resource templates, which seem to be an edge case for clients (e.g. at first glance, they don't seem to work properly in the MCP Inspector). Reading through the code, it appears that concrete resources are already lazy - so we could consider Context-only resources as concrete/direct and thread through the context in the read method. |
rebase of #248 (copied below)
closes #244
Motivation and Context
According to the readme it should be possible to pass a
Context
to a resource (like it is for tools), but that's currently throwing an error (#244)How Has This Been Tested?
How Has This Been Tested?
Added tests, and confirmed with inspector that the below demo server works as intended:
Breaking Changes
Types of changes
Checklist
Additional context
I tried to follow a similar structure to the way context is injected in tools