Add Roots support to the MCP client and server #2895
Draft
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.
Description
This adds roots support to the MCP client and server. It supports setting client roots when creating the client, but not modifying the roots once the client plugin is created. That will have to come later: changing the roots means that the available tools/prompts/resources might also change, and I didn't want to build dynamically changing tools because I wasn't clear on exactly how that was done. I did add support for the server to request the roots from the client (because some do that even if the roots don't change), which means that the client now registers handlers too.
Tests