Skip to content

Commit 39a9ee6

Browse files
committed
Address PR review feedback
1 parent f0a9ead commit 39a9ee6

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
@@ -121,7 +121,7 @@ public async ValueTask<IList<McpClientTool>> ListToolsAsync(
121121
tools ??= new List<McpClientTool>(toolResults.Tools.Count);
122122
foreach (var tool in toolResults.Tools)
123123
{
124-
tools.Add(new McpClientTool(this, tool, serializerOptions));
124+
tools.Add(new McpClientTool(this, tool, options?.JsonSerializerOptions));
125125
}
126126

127127
cursor = toolResults.NextCursor;
@@ -141,9 +141,6 @@ public async IAsyncEnumerable<McpClientTool> EnumerateToolsAsync(
141141
RequestOptions? options = null,
142142
[EnumeratorCancellation] CancellationToken cancellationToken = default)
143143
{
144-
var serializerOptions = options?.JsonSerializerOptions ?? McpJsonUtilities.DefaultOptions;
145-
serializerOptions.MakeReadOnly();
146-
147144
string? cursor = null;
148145
do
149146
{
@@ -156,7 +153,7 @@ public async IAsyncEnumerable<McpClientTool> EnumerateToolsAsync(
156153

157154
foreach (var tool in toolResults.Tools)
158155
{
159-
yield return new McpClientTool(this, tool, serializerOptions);
156+
yield return new McpClientTool(this, tool, options?.JsonSerializerOptions);
160157
}
161158

162159
cursor = toolResults.NextCursor;
@@ -590,12 +587,7 @@ async ValueTask<CallToolResult> SendRequestWithProgressAsync(
590587
}).ConfigureAwait(false);
591588

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

600592
return await SendRequestAsync(
601593
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)