Use strong-typing of params in most remaining McpClientExtensions methods (#224)

This commit is contained in:
Stephen Toub 2025-04-07 11:30:42 -04:00 • committed by GitHub
commit 03dc90aa33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@
using Microsoft.Extensions.DependencyInjection;
using ModelContextProtocol.Protocol.Types;
using ModelContextProtocol.Utils;
using ModelContextProtocol.Utils.Json;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Text.Json;
@ -207,8 +208,8 @@ internal sealed class AIFunctionMcpServerPrompt : McpServerPrompt
cancellationToken.ThrowIfCancellationRequested();
// TODO: Once we shift to the real AIFunctionFactory, the request should be passed via AIFunctionArguments.Context.
Dictionary<string, object?> arguments = request.Params?.Arguments is IDictionary<string, object?> existingArgs ?
new(existingArgs) :
Dictionary<string, object?> arguments = request.Params?.Arguments is { } paramArgs ?
paramArgs.ToDictionary(entry => entry.Key, entry => entry.Value.AsObject()) :
[];
arguments[RequestContextKey] = request;