-
Notifications
You must be signed in to change notification settings - Fork 513
Introduce acceptance helpers to ElicitResult and client capability checks on IMcpServer #666
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?
Conversation
src/ModelContextProtocol.Core/ExtensionMethods/ElicitResultExtensions.cs
Outdated
Show resolved
Hide resolved
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.
I'm personally a fan of IsAccepted/IsDeclined/IsCanceled so you don't have to carefully read the doc comments or look up the spec to see what the possible values are. An alternative might be an enum, but this is certainly more flexible.
If we add SupportsElicitation, I think we should add SupportsSampling and SupportsRoots for completeness.
@halter73 Checking support of sampling and roots extension methods are added with ClientSupportsSampling and ClientSupportsRoots method names. Client prefix is suggested by @PederHP and it totally makes sense in this context. |
213cbe9
to
9c6314f
Compare
/// <remarks> | ||
/// When <see langword="true"/>, the server can call <see cref="McpServerExtensions.ElicitAsync"/> to request additional information from the user via the client. | ||
/// </remarks> | ||
public static bool ClientSupportsElicitation(this IMcpServer server) |
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.
These would be better as properties rather than as methods. Should we start thinking about using C# 14?
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.
I assume you're referring to extension members, right? if that's the case, I suggest we merge this PR as-is and then I can work on a follow up PR to convert all extension methods in whole solution to extension members for consistency.
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.
@stephentoub is it ok to resolve this conversation and proceed with what I suggested?
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.
I would say let's remove these methods for now and reconsider once C# 14 is generally available. There's also this ongoing PR that proposes to convert IMcpClient
et al to abstract interfaces so extensions might not even be necessary.
b46ee63
to
a3d2d36
Compare
…potential string comparison errors
rename SupportsElicitation to ClientSupportsElicitation
a3d2d36
to
b600f30
Compare
This PR has following additions on IMcpServer and ElicitResult.
Motivation and Context
Motivation is to make code more readable and less error-prone than direct string comparisons.
How Has This Been Tested?
All newly added functionality tested in unit tests.
Breaking Changes
There is no breaking change.
Types of changes
Checklist
Additional context