-
Notifications
You must be signed in to change notification settings - Fork 653
Expand file tree
/
Copy pathRequestParams.cs
More file actions
52 lines (46 loc) · 1.43 KB
/
RequestParams.cs
File metadata and controls
52 lines (46 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
namespace ModelContextProtocol.Protocol;
/// <summary>
/// Provides a base class for all request parameters.
/// </summary>
/// <remarks>
/// See the <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">schema</see> for details.
/// </remarks>
public abstract class RequestParams
{
/// <summary>Prevent external derivations.</summary>
private protected RequestParams()
{
}
/// <summary>
/// Gets or sets metadata reserved by MCP for protocol-level metadata.
/// </summary>
/// <remarks>
/// Implementations must not make assumptions about its contents.
/// </remarks>
[JsonPropertyName("_meta")]
public JsonObject? Meta { get; set; }
/// <summary>
/// Gets the opaque token that will be attached to any subsequent progress notifications.
/// </summary>
[JsonIgnore]
public ProgressToken? ProgressToken
{
get
{
if (Meta?["progressToken"] is JsonValue progressToken)
{
if (progressToken.TryGetValue(out string? stringValue))
{
return new ProgressToken(stringValue);
}
if (progressToken.TryGetValue(out long longValue))
{
return new ProgressToken(longValue);
}
}
return null;
}
}
}