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