Introduce acceptance helpers to ElicitResult and client capability checks on IMcpServer#666
Conversation
src/ModelContextProtocol.Core/ExtensionMethods/ElicitResultExtensions.cs
Outdated
Show resolved
Hide resolved
halter73
left a comment
There was a problem hiding this comment.
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.
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.
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.
@stephentoub is it ok to resolve this conversation and proceed with what I suggested?
There was a problem hiding this comment.
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