Skip to content

Commit 595b4b6

Browse files
committed
Address PR review feedback
1 parent 8bc7a06 commit 595b4b6

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

src/ModelContextProtocol.Core/Client/McpClient.Methods.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public async ValueTask<IList<McpClientTool>> ListToolsAsync(
119119
tools ??= new List<McpClientTool>(toolResults.Tools.Count);
120120
foreach (var tool in toolResults.Tools)
121121
{
122-
tools.Add(new McpClientTool(this, tool, serializerOptions));
122+
tools.Add(new McpClientTool(this, tool, options?.JsonSerializerOptions));
123123
}
124124

125125
cursor = toolResults.NextCursor;
@@ -139,9 +139,6 @@ public async IAsyncEnumerable<McpClientTool> EnumerateToolsAsync(
139139
RequestOptions? options = null,
140140
[EnumeratorCancellation] CancellationToken cancellationToken = default)
141141
{
142-
var serializerOptions = options?.JsonSerializerOptions ?? McpJsonUtilities.DefaultOptions;
143-
serializerOptions.MakeReadOnly();
144-
145142
string? cursor = null;
146143
do
147144
{
@@ -154,7 +151,7 @@ public async IAsyncEnumerable<McpClientTool> EnumerateToolsAsync(
154151

155152
foreach (var tool in toolResults.Tools)
156153
{
157-
yield return new McpClientTool(this, tool, serializerOptions);
154+
yield return new McpClientTool(this, tool, options?.JsonSerializerOptions);
158155
}
159156

160157
cursor = toolResults.NextCursor;
@@ -588,12 +585,7 @@ async ValueTask<CallToolResult> SendRequestWithProgressAsync(
588585
}).ConfigureAwait(false);
589586

590587
var metaWithProgress = meta is not null ? new JsonObject(meta) : new JsonObject();
591-
metaWithProgress["progressToken"] = progressToken.Token switch
592-
{
593-
string s => JsonValue.Create(s),
594-
long l => JsonValue.Create(l),
595-
_ => throw new InvalidOperationException("ProgressToken must be a string or long")
596-
};
588+
metaWithProgress["progressToken"] = progressToken.ToString();
597589

598590
return await SendRequestAsync(
599591
RequestMethods.ToolsCall,

src/ModelContextProtocol.Core/RequestOptions.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ public sealed class RequestOptions
1414
/// </summary>
1515
private JsonObject? _meta;
1616

17+
/// <summary>
18+
/// Initializes a new instance of the <see cref="RequestOptions"/> class.
19+
/// </summary>
20+
public RequestOptions()
21+
{
22+
}
23+
1724
/// <summary>
1825
/// Optional metadata to include in the request.
1926
/// When getting, automatically includes the progress token if set.
@@ -52,11 +59,4 @@ public JsonObject? Meta
5259
/// The progress token for tracking long-running operations.
5360
/// </summary>
5461
public ProgressToken? ProgressToken { get; set; }
55-
56-
/// <summary>
57-
/// Initializes a new instance of the <see cref="RequestOptions"/> class.
58-
/// </summary>
59-
public RequestOptions()
60-
{
61-
}
6262
}

0 commit comments

Comments
 (0)