-
Notifications
You must be signed in to change notification settings - Fork 9.1k
feat: add MCP roots protocol support to everything server #2573
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
feat: add MCP roots protocol support to everything server #2573
Conversation
- Add roots capability declaration with listChanged: true - Implement roots/list_changed notification handler - Add initialization handler to request initial roots from client - Add new listRoots tool to demonstrate roots functionality - Add comprehensive logging for roots protocol events - Update README.md with roots documentation Resolves #2552 The everything server now demonstrates all MCP features including the roots protocol. This provides a complete reference implementation for client developers to test their roots protocol implementation against, even though this server doesn't access files directly.
|
Hi @AjayKumbham thanks for the PR! I'm curious, when you validated manually were you able to do that with Inspector or some other way? |
|
Hi @olaservo! Great question about the validation. I did quite a bit of testing, though I'll admit I didn't initially test the full roots protocol flow with a real MCP client. Here's what I was able to validate: Basic functionality testing:
Code correctness:
End-to-end protocol testing: ✅ Server correctly declares So I'm confident the implementation is solid and follows the MCP specification correctly. The server demonstrates the complete roots capability as intended in the original issue, even though it doesn't actually access files. |
|
Hi @olaservo, thanks for keeping this branch updated. All checks are passing and the branch is up to date. Could you please review this PR when you get a chance, so it can move forward? Let me know if there’s anything else needed from my side. |
olaservo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! One thing I'd like to add is clearer messaging around the case where the client doesn't support the roots capability vs no roots being configured.
So for example, if you set a variable earlier on when checking the capability, you could return a message like this if roots are not supported:
if (!clientSupportsRoots) {
return {
content: [
{
type: "text",
text: "The MCP client does not support the roots protocol.\n\n" +
"This means the server cannot access information about the client's workspace directories or file system roots."
}
]
};
}
…uration - Add clientSupportsRoots tracking variable - Set clientSupportsRoots during initialization based on client capabilities - Update listRoots tool to provide clearer messaging: - Specific message when client doesn't support roots protocol - Different message when client supports roots but none are configured - Improves user experience by clearly explaining the different scenarios Addresses feedback from @olaservo in PR review
…ub.com/AjayKumbham/servers into add-roots-support-to-everything-server
|
Thanks for the suggestion @olaservo, this makes it much clearer for users to understand what's happening and provides better guidance for troubleshooting. I tested both scenarios and the messaging works as expected. |
olaservo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, like Cliff mentioned you need to check for this capability in the client capabilities, not the server. Sorry for not catching this sooner! 😅
|
Thanks @cliffhall and @olaservo for catching that! You're absolutely right - roots is a client capability, not a server capability. I've removed roots: { listChanged: true } from the server capabilities. The client capability checking was already correctly implemented with clientCapabilities?.roots to determine if the client supports the roots protocol. The fix is now complete and follows the proper MCP specification where servers declare their own capabilities and check client capabilities to know what features they can use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AjayKumbham We should only expose the LIST_ROOTS tool if the client advertises support for the roots capability.
I tested the following change suggestions by commenting out roots capability in the inspector. No error, and listRoots was not shown in the tool list
Co-authored-by: Cliff Hall <cliff@futurescale.com>
Co-authored-by: Cliff Hall <cliff@futurescale.com>
Co-authored-by: Cliff Hall <cliff@futurescale.com>
cliffhall
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally with and without roots capability in the Inspector. Operated as expected.
|
Thanks @cliffhall and @olaservo for the thorough review and guidance! Appreciate you catching the capability handling details - learned a lot about the MCP protocol through this process. Glad we could get complete roots protocol support into the everything server! 🎉 |
Description
This PR adds MCP roots protocol support to the everything server to provide complete MCP feature coverage. The implementation includes:
listChanged: trueroots/list_changednotification handlerlistRootstool to demonstrate roots functionalityServer Details
Motivation and Context
Resolves #2552
The everything server is designed to demonstrate all MCP protocol features for client developers to test against. However, it was missing roots protocol support, which is an important MCP capability that allows clients to specify which directories servers can access. This change ensures the everything server truly covers "everything" in the MCP specification.
While this server doesn't actually access files, implementing roots support provides:
How Has This Been Tested?
npm run buildThe implementation follows the established patterns from the filesystem server's roots implementation, ensuring consistency with the existing codebase.
Breaking Changes
No breaking changes. This is purely additive functionality that doesn't affect existing server behavior or client configurations.
Types of changes
Checklist
Additional context
The implementation is based on the filesystem server's roots handling but adapted for the everything server's demonstration purposes. Key design decisions:
The
listRootstool provides a practical way for developers to verify that their MCP client's roots implementation is working correctly, even though this server doesn't perform file operations.