Add request options bag to high level requests and include Meta (#970)
Co-authored-by: Stephen Toub <stoub@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
627de76ca6
commit
c447973972
2 changed files with 882 additions and 164 deletions
11
src/ModelContextProtocol.Core/Protocol/PingRequestParams.cs
Normal file
11
src/ModelContextProtocol.Core/Protocol/PingRequestParams.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
namespace ModelContextProtocol.Protocol;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the parameters used with a <see cref="RequestMethods.Ping"/> request to verify
|
||||
/// server connectivity.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The server responds with a <see cref="PingResult"/>.
|
||||
/// See the <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">schema</see> for details.
|
||||
/// </remarks>
|
||||
public sealed class PingRequestParams : RequestParams;
|
||||
|
|
@ -26,7 +26,7 @@ public abstract class RequestParams
|
|||
public JsonObject? Meta { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an opaque token that will be attached to any subsequent progress notifications.
|
||||
/// Gets the opaque token that will be attached to any subsequent progress notifications.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public ProgressToken? ProgressToken
|
||||
|
|
@ -48,21 +48,5 @@ public abstract class RequestParams
|
|||
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value is null)
|
||||
{
|
||||
Meta?.Remove("progressToken");
|
||||
}
|
||||
else
|
||||
{
|
||||
(Meta ??= [])["progressToken"] = value.Value.Token switch
|
||||
{
|
||||
string s => JsonValue.Create(s),
|
||||
long l => JsonValue.Create(l),
|
||||
_ => throw new InvalidOperationException("ProgressToken must be a string or a long.")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue