-
Notifications
You must be signed in to change notification settings - Fork 468
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
{ | ||
Throw.IfNull(result); | ||
return string.Equals(result.Action, "cancel", StringComparison.OrdinalIgnoreCase); | ||
} |
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.
If we want to do this, why not have them as JsonIgnore properties directly on ElicitResult?
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.
Great point. While I was writing SupportsElicitation method, I biased to use extension method. Having properties with JsonIgnore would makes more sense. I'll refactor it.
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 I've completed refactoring with your eye-opening question. Do you think this PR contributes to developer experience and you'd like to see it in the SDK?
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.
Thanks. We'll discuss it.
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.
/// <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 SupportsElicitation(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.
Maybe ClientSupportsElicitation? The convenience of not going through client capabilities is reasonable, but it feels weird to have a client capability be a direct pseudo-property on IMcpServer with the client link being entirely implicit.
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.
renamed with ClientSupportsElicitation
Throw.IfNull(server); | ||
return server.ClientCapabilities?.Elicitation is not null; | ||
} | ||
|
||
private static void ThrowIfSamplingUnsupported(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.
Same as above. Having the Client word would reduce risk of developer confusion.
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.
renamed
@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. |
…potential string comparison errors
rename SupportsElicitation to ClientSupportsElicitation
213cbe9
to
9c6314f
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