Skip to content

User should set RootsListChanged capability #871

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lorenzocesconetto
Copy link
Contributor

SDK user will set whether it supports RootsListChanged.
To fall into the safe side, the capability defaults to False.

Motivation and Context

I was thinking of a more robust solution for this, but since it's the user providing the callback, I don't think there's much we can do here.

How Has This Been Tested?

Locally.

Breaking Changes

No. I added a new arg, but it's in the end of the args list and has a default value.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@lorenzocesconetto
Copy link
Contributor Author

@ihrpr this is a follow up from #802

@lorenzocesconetto lorenzocesconetto changed the title Pass responsibility to user User should set RootsListChanged capability Jun 3, 2025
Copy link
Contributor

@hesreallyhim hesreallyhim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup lgtm 👍

this could be a separate PR, but it might be nice to support "good" default callbacks as well, like if most users want to respond to "roots/list" with a paginated result of roots in some default way, we might consider providing such a facility. Same with roots/listChanged - if I want to support "listChanged" but am happy with some default response, why make each user write their own callback?

EDIT: Irrelevant edit removed.

@lorenzocesconetto
Copy link
Contributor Author

lorenzocesconetto commented Jun 3, 2025

@hesreallyhim yeah, agreed... I was thinking about implementing something nicer than this simple PR.

A suggestion could be:

  • The session takes an optional list of roots as an argument.
  • SDK implements a simple default callback that returns the list of roots upon request (user doesn't need to write his own callback).
  • Session implements an add_root method that automatically sends a RootsListChanged notification to the connected MCP server (this would be super nice, users would get RootsListChanged support for free).

I can implement this if @ihrpr or @Kludex are on-board (will wait for their blessing, I don't want to waste time implementing it if the core maintainers don't agree).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants