Skip to content

Commit 62b1d2e

Browse files
committed
Change McpClientTool.CallAsync to accept RequestOptions
1 parent c34bd43 commit 62b1d2e

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/ModelContextProtocol.Core/Client/McpClientTool.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ internal McpClientTool(
128128
protected async override ValueTask<object?> InvokeCoreAsync(
129129
AIFunctionArguments arguments, CancellationToken cancellationToken)
130130
{
131-
CallToolResult result = await CallAsync(arguments, _progress, JsonSerializerOptions, cancellationToken).ConfigureAwait(false);
131+
var options = JsonSerializerOptions is null ? null : new RequestOptions()
132+
{
133+
JsonSerializerOptions = JsonSerializerOptions,
134+
};
135+
CallToolResult result = await CallAsync(arguments, _progress, options, cancellationToken).ConfigureAwait(false);
132136

133137
// We want to translate the result content into AIContent, using AIContent as the exchange types, so
134138
// that downstream IChatClients can specialize handling based on the content (e.g. sending image content
@@ -163,8 +167,8 @@ result.StructuredContent is null &&
163167
/// value will result in a progress token being included in the call, and any resulting progress notifications during the operation
164168
/// routed to this instance.
165169
/// </param>
166-
/// <param name="serializerOptions">
167-
/// The JSON serialization options governing argument serialization. If <see langword="null"/>, the default serialization options are used.
170+
/// <param name="options">
171+
/// Optional request options including metadata, serialization settings, and progress tracking.
168172
/// </param>
169173
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
170174
/// <returns>
@@ -191,15 +195,14 @@ result.StructuredContent is null &&
191195
public ValueTask<CallToolResult> CallAsync(
192196
IReadOnlyDictionary<string, object?>? arguments = null,
193197
IProgress<ProgressNotificationValue>? progress = null,
194-
JsonSerializerOptions? serializerOptions = null,
198+
RequestOptions? options = null,
195199
CancellationToken cancellationToken = default) =>
196200
_client.CallToolAsync(
197201
ProtocolTool.Name,
198202
arguments,
199203
progress,
200-
serializerOptions is null ? null : new RequestOptions
201-
{
202-
JsonSerializerOptions = serializerOptions
204+
options ?? new RequestOptions() {
205+
JsonSerializerOptions = JsonSerializerOptions
203206
},
204207
cancellationToken);
205208

0 commit comments

Comments
 (0)