Skip to content

Commit fccab7c

Browse files
committed
Add tests for RequestOptions and fix buggy Meta setter
1 parent 06af40e commit fccab7c

File tree

2 files changed

+452
-3
lines changed

2 files changed

+452
-3
lines changed

src/ModelContextProtocol.Core/RequestOptions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public JsonObject? Meta
3434
}
3535
set
3636
{
37-
// Preserve the progress token if set.
37+
// Capture the existing progressToken value if set.
3838
var progressToken = _meta?["progressToken"];
3939
if (value is null)
4040
{
@@ -52,7 +52,9 @@ public JsonObject? Meta
5252
}
5353
else
5454
{
55-
if (progressToken is not null) {
55+
if (value["progressToken"] is null && progressToken is not null) {
56+
// Remove existing progressToken so it can be set into the new meta.
57+
_meta?.Remove("progressToken");
5658
value["progressToken"] = progressToken;
5759
}
5860
_meta = value;
@@ -85,7 +87,6 @@ public ProgressToken? ProgressToken {
8587
_meta ??= new JsonObject();
8688
_meta["progressToken"] = token switch
8789
{
88-
null => _meta.Remove("progressToken"),
8990
string s => s,
9091
long l => l,
9192
_ => throw new InvalidOperationException("ProgressToken must be a string or long"),

0 commit comments

Comments
 (0)