Add support for URL mode elicitation (#1021)
This commit is contained in:
parent
c447973972
commit
ae17ba0b4b
2 changed files with 1241 additions and 92 deletions
|
|
@ -104,7 +104,19 @@ internal sealed partial class McpClientImpl : McpClient
|
|||
McpJsonUtilities.JsonContext.Default.ElicitResult);
|
||||
|
||||
_options.Capabilities ??= new();
|
||||
_options.Capabilities.Elicitation ??= new();
|
||||
if (_options.Capabilities.Elicitation is null)
|
||||
{
|
||||
// Default to supporting only form mode if not explicitly configured
|
||||
_options.Capabilities.Elicitation = new()
|
||||
{
|
||||
Form = new(),
|
||||
};
|
||||
}
|
||||
else if (_options.Capabilities.Elicitation.Form is null && _options.Capabilities.Elicitation.Url is null)
|
||||
{
|
||||
// If ElicitationCapability is set but both modes are null, default to form mode for backward compatibility
|
||||
_options.Capabilities.Elicitation.Form = new();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -166,6 +166,10 @@ internal sealed partial class StreamableHttpClientSessionTransport : TransportBa
|
|||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogTransportShutdownFailed(Name, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_connectionCts.Dispose();
|
||||
|
|
@ -268,15 +272,8 @@ internal sealed partial class StreamableHttpClientSessionTransport : TransportBa
|
|||
using var deleteRequest = new HttpRequestMessage(HttpMethod.Delete, _options.Endpoint);
|
||||
CopyAdditionalHeaders(deleteRequest.Headers, _options.AdditionalHeaders, SessionId, _negotiatedProtocolVersion);
|
||||
|
||||
try
|
||||
{
|
||||
// Do not validate we get a successful status code, because server support for the DELETE request is optional
|
||||
(await _httpClient.SendAsync(deleteRequest, message: null, CancellationToken.None).ConfigureAwait(false)).Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogTransportShutdownFailed(Name, ex);
|
||||
}
|
||||
// Do not validate we get a successful status code, because server support for the DELETE request is optional
|
||||
(await _httpClient.SendAsync(deleteRequest, message: null, CancellationToken.None).ConfigureAwait(false)).Dispose();
|
||||
}
|
||||
|
||||
private void LogJsonException(JsonException ex, string data)
|
||||
|
|
|
|||
Loading…
Reference in a new issue