@@ -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 ,
0 commit comments