Add McpClient/Session methods using .Protocol types (#1063)

This commit is contained in:
Stephen Toub 2025-12-05 13:45:12 -05:00 • committed by GitHub
commit 4a84412331
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 1116 additions and 639 deletions

View file

@ -391,7 +391,7 @@ public sealed class ElicitRequestParams : RequestParams
return psd;
}
private static IList<EnumSchemaOption> DeserializeEnumOptions(ref Utf8JsonReader reader)
private static List<EnumSchemaOption> DeserializeEnumOptions(ref Utf8JsonReader reader)
{
if (reader.TokenType != JsonTokenType.StartArray)
{

View file

@ -13,6 +13,7 @@ public readonly struct ProgressToken : IEquatable<ProgressToken>
{
/// <summary>Initializes a new instance of the <see cref="ProgressToken"/> with a specified value.</summary>
/// <param name="value">The required ID value.</param>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is <see langword="null"/>.</exception>
public ProgressToken(string value)
{
Throw.IfNull(value);

View file

@ -12,8 +12,8 @@ namespace ModelContextProtocol.Protocol;
/// </summary>
/// <remarks>
/// <para>
/// References are commonly used with <see cref="McpClient.CompleteAsync"/> to request completion suggestions for arguments,
/// and with other methods that need to reference resources or prompts.
/// References are commonly used with <see cref="McpClient.CompleteAsync(Reference, string, string, ModelContextProtocol.RequestOptions?, CancellationToken)"/>
/// to request completion suggestions for arguments, and with other methods that need to reference resources or prompts.
/// </para>
/// <para>
/// See the <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">schema</see> for details.

View file

@ -13,6 +13,7 @@ public readonly struct RequestId : IEquatable<RequestId>
{
/// <summary>Initializes a new instance of the <see cref="RequestId"/> with a specified value.</summary>
/// <param name="value">The required ID value.</param>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is <see langword="null"/>.</exception>
public RequestId(string value)
{
Throw.IfNull(value);

View file

@ -94,6 +94,8 @@ public abstract partial class TransportBase : ITransport
throw new InvalidOperationException("Transport is not connected.");
}
cancellationToken.ThrowIfCancellationRequested();
if (_logger.IsEnabled(LogLevel.Debug))
{
var messageId = (message as JsonRpcMessageWithId)?.Id.ToString() ?? "(no id)";