diff --git a/Directory.Packages.props b/Directory.Packages.props
index d6762f6c67..8d2b1426ea 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -7,8 +7,8 @@
-
-
+
+
@@ -59,38 +59,38 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
diff --git a/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/BaseToolLoader.cs b/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/BaseToolLoader.cs
index a929df93d8..2693c088f0 100644
--- a/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/BaseToolLoader.cs
+++ b/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/BaseToolLoader.cs
@@ -62,7 +62,7 @@ static BaseToolLoader()
///
protected static JsonElement GetParametersJsonElement(RequestContext request)
{
- IReadOnlyDictionary? args = request.Params?.Arguments;
+ IDictionary? args = request.Params?.Arguments;
if (args != null && args.TryGetValue("parameters", out var parametersElem) && parametersElem.ValueKind == JsonValueKind.Object)
{
return parametersElem;
diff --git a/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/NamespaceToolLoader.cs b/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/NamespaceToolLoader.cs
index 44f206643b..db0bf48427 100644
--- a/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/NamespaceToolLoader.cs
+++ b/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/NamespaceToolLoader.cs
@@ -264,7 +264,7 @@ private async Task InvokeChildToolAsync(
string? intent,
string namespaceName,
string command,
- IReadOnlyDictionary parameters,
+ IDictionary parameters,
CancellationToken cancellationToken)
{
if (request.Params == null)
@@ -458,7 +458,7 @@ private async Task InvokeToolLearn(RequestContext parameters) = await GetCommandAndParametersFromIntentAsync(request, intent, namespaceName, availableTools, cancellationToken);
+ (string? commandName, IDictionary parameters) = await GetCommandAndParametersFromIntentAsync(request, intent, namespaceName, availableTools, cancellationToken);
if (commandName != null)
{
response = await InvokeChildToolAsync(request, intent, namespaceName, commandName, parameters, cancellationToken);
@@ -586,7 +586,7 @@ private static bool IsRawMcpToolInputOption(Option option)
string.Equals(NameNormalization.NormalizeOptionName(alias), RawMcpToolInputOptionName, StringComparison.OrdinalIgnoreCase));
}
- private static IReadOnlyDictionary GetParametersFromArgs(IReadOnlyDictionary? args)
+ private static Dictionary GetParametersFromArgs(IDictionary? args)
{
if (args == null || !args.TryGetValue("parameters", out var paramsElem))
{
@@ -620,10 +620,10 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
{
Progress = 0f,
Message = message,
- }, cancellationToken);
+ }, cancellationToken: cancellationToken);
}
- private async Task<(string? commandName, IReadOnlyDictionary parameters)> GetCommandAndParametersFromIntentAsync(
+ private async Task<(string? commandName, Dictionary parameters)> GetCommandAndParametersFromIntentAsync(
RequestContext request,
string intent,
string namespaceName,
@@ -638,11 +638,12 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
var samplingRequest = new CreateMessageRequestParams
{
+ MaxTokens = 1000,
Messages = [
new SamplingMessage
{
Role = Role.Assistant,
- Content = new TextContentBlock{
+ Content = [new TextContentBlock{
Text = $"""
This is a list of available commands for the {namespaceName} server.
@@ -666,17 +667,17 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
Available Commands:
{availableToolsJson}
"""
- }
+ }]
}
],
};
try
{
var samplingResponse = await request.Server.SampleAsync(samplingRequest, cancellationToken);
- var samplingContent = samplingResponse.Content as TextContentBlock;
+ var samplingContent = samplingResponse.Content is { Count: > 0 } ? samplingResponse.Content[0] as TextContentBlock : null;
var toolCallJson = samplingContent?.Text?.Trim();
string? commandName = null;
- IReadOnlyDictionary parameters = new Dictionary();
+ var parameters = new Dictionary();
if (!string.IsNullOrEmpty(toolCallJson))
{
diff --git a/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/RegistryToolLoader.cs b/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/RegistryToolLoader.cs
index 41a220cdb9..3f7643195b 100644
--- a/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/RegistryToolLoader.cs
+++ b/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/RegistryToolLoader.cs
@@ -147,7 +147,7 @@ public override async ValueTask CallToolHandler(RequestContext
/// The arguments to transform to parameters.
/// A dictionary of parameter names and values compatible with McpClientExtensions.CallToolAsync.
- private static Dictionary TransformArgumentsToDictionary(IReadOnlyDictionary? args)
+ private static Dictionary TransformArgumentsToDictionary(IDictionary? args)
{
if (args == null)
{
diff --git a/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/ServerToolLoader.cs b/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/ServerToolLoader.cs
index a6b22eea91..f73aaf72bc 100644
--- a/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/ServerToolLoader.cs
+++ b/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/ServerToolLoader.cs
@@ -439,7 +439,7 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
{
Progress = 0f,
Message = message,
- }, cancellationToken);
+ }, cancellationToken: cancellationToken);
}
private async Task<(string? commandName, Dictionary parameters)> GetCommandAndParametersFromIntentAsync(
RequestContext request,
@@ -456,11 +456,12 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
var samplingRequest = new CreateMessageRequestParams
{
+ MaxTokens = 1000,
Messages = [
new SamplingMessage
{
Role = Role.Assistant,
- Content = new TextContentBlock{
+ Content = [new TextContentBlock{
Text = $"""
This is a list of available commands for the {tool} server.
@@ -484,14 +485,14 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
Available Commands:
{availableToolsJson}
"""
- }
+ }]
}
],
};
try
{
var samplingResponse = await request.Server.SampleAsync(samplingRequest, cancellationToken);
- var samplingContent = samplingResponse.Content as TextContentBlock;
+ var samplingContent = samplingResponse.Content is { Count: > 0 } ? samplingResponse.Content[0] as TextContentBlock : null;
var toolCallJson = samplingContent?.Text?.Trim();
string? commandName = null;
Dictionary parameters = [];
diff --git a/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/SingleProxyToolLoader.cs b/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/SingleProxyToolLoader.cs
index 577aa5eaaa..85b80db650 100644
--- a/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/SingleProxyToolLoader.cs
+++ b/core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/SingleProxyToolLoader.cs
@@ -357,7 +357,7 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
{
Progress = 0f,
Message = message,
- }, cancellationToken);
+ }, cancellationToken: cancellationToken);
}
private async Task GetToolNameFromIntentAsync(RequestContext request, string intent, string toolsJson, CancellationToken cancellationToken)
@@ -366,11 +366,12 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
var samplingRequest = new CreateMessageRequestParams
{
+ MaxTokens = 1000,
Messages = [
new SamplingMessage
{
Role = Role.Assistant,
- Content = new TextContentBlock{
+ Content = [new TextContentBlock{
Text = $"""
The following is a list of available tools for the Azure server.
@@ -385,14 +386,14 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
Available Tools:
{toolsJson}
"""
- }
+ }]
}
],
};
try
{
var samplingResponse = await request.Server.SampleAsync(samplingRequest, cancellationToken);
- var samplingContent = samplingResponse.Content as TextContentBlock;
+ var samplingContent = samplingResponse.Content is { Count: > 0 } ? samplingResponse.Content[0] as TextContentBlock : null;
var toolName = samplingContent?.Text?.Trim();
if (!string.IsNullOrEmpty(toolName) && toolName != "Unknown")
{
@@ -421,11 +422,12 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
var samplingRequest = new CreateMessageRequestParams
{
+ MaxTokens = 1000,
Messages = [
new SamplingMessage
{
Role = Role.Assistant,
- Content = new TextContentBlock{
+ Content = [new TextContentBlock{
Text = $"""
This is a list of available commands for the {tool} server.
@@ -449,14 +451,14 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
Available Commands:
{toolsJson}
"""
- }
+ }]
}
],
};
try
{
var samplingResponse = await request.Server.SampleAsync(samplingRequest, cancellationToken);
- var samplingContent = samplingResponse.Content as TextContentBlock;
+ var samplingContent = samplingResponse.Content is { Count: > 0 } ? samplingResponse.Content[0] as TextContentBlock : null;
var toolCallJson = samplingContent?.Text?.Trim();
string? commandName = null;
Dictionary parameters = [];
diff --git a/core/Azure.Mcp.Core/src/Commands/CommandExtensions.cs b/core/Azure.Mcp.Core/src/Commands/CommandExtensions.cs
index 12d85af6d9..e0b11a754a 100644
--- a/core/Azure.Mcp.Core/src/Commands/CommandExtensions.cs
+++ b/core/Azure.Mcp.Core/src/Commands/CommandExtensions.cs
@@ -18,7 +18,7 @@ public static class CommandExtensions
/// The command to parse options for
/// Dictionary of argument name/value pairs
/// ParseResult containing the parsed arguments
- public static ParseResult ParseFromDictionary(this Command command, IReadOnlyDictionary? arguments)
+ public static ParseResult ParseFromDictionary(this Command command, IDictionary? arguments)
{
if (arguments == null || arguments.Count == 0)
{
@@ -75,7 +75,7 @@ public static ParseResult ParseFromDictionary(this Command command, IReadOnlyDic
return command.Parse([.. args]);
}
- public static ParseResult ParseFromRawMcpToolInput(this Command command, IReadOnlyDictionary? arguments)
+ public static ParseResult ParseFromRawMcpToolInput(this Command command, IDictionary? arguments)
{
var args = new List();
diff --git a/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.LiveTests/ClientToolTests.cs b/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.LiveTests/ClientToolTests.cs
index 56c4a5853c..aa5d8440c7 100644
--- a/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.LiveTests/ClientToolTests.cs
+++ b/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.LiveTests/ClientToolTests.cs
@@ -104,7 +104,7 @@ public async Task Should_Error_When_Resources_Unsubscribe_Not_Supported()
[Fact]
public async Task Should_Not_Hang_On_Logging_SetLevel_Not_Supported()
{
- await Client.SetLoggingLevel(LoggingLevel.Info, cancellationToken: TestContext.Current.CancellationToken);
+ await Client.SetLoggingLevelAsync(LoggingLevel.Info, cancellationToken: TestContext.Current.CancellationToken);
}
[Fact]
diff --git a/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/Runtime/McpRuntimeTests.cs b/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/Runtime/McpRuntimeTests.cs
index e3154840e1..7eab9bf9f6 100644
--- a/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/Runtime/McpRuntimeTests.cs
+++ b/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/Runtime/McpRuntimeTests.cs
@@ -53,7 +53,7 @@ private static RequestContext CreateListToolsRequest()
};
}
- private static RequestContext CreateCallToolRequest(string toolName = "test-tool", IReadOnlyDictionary? arguments = null)
+ private static RequestContext CreateCallToolRequest(string toolName = "test-tool", IDictionary? arguments = null)
{
return new RequestContext(CreateMockServer(), new() { Method = RequestMethods.ToolsCall })
{
diff --git a/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/BaseToolLoaderTests.cs b/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/BaseToolLoaderTests.cs
index 7f35d37443..327d606edb 100644
--- a/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/BaseToolLoaderTests.cs
+++ b/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/BaseToolLoaderTests.cs
@@ -192,12 +192,13 @@ public async Task CreateClientOptions_SamplingHandler_DelegatesToServerSendReque
var samplingRequest = new CreateMessageRequestParams
{
+ MaxTokens = 1000,
Messages =
[
new SamplingMessage
{
Role = Role.User,
- Content = new TextContentBlock { Text = "Test message" }
+ Content = [new TextContentBlock { Text = "Test message" }]
}
]
};
@@ -208,7 +209,7 @@ public async Task CreateClientOptions_SamplingHandler_DelegatesToServerSendReque
Result = JsonSerializer.SerializeToNode(new CreateMessageResult
{
Role = Role.Assistant,
- Content = new TextContentBlock { Text = "Mock response" },
+ Content = [new TextContentBlock { Text = "Mock response" }],
Model = "test-model"
})
};
diff --git a/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/CompositeToolLoaderTests.cs b/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/CompositeToolLoaderTests.cs
index b3dc84af33..559994b4e7 100644
--- a/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/CompositeToolLoaderTests.cs
+++ b/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/CompositeToolLoaderTests.cs
@@ -28,7 +28,7 @@ private static RequestContext CreateListToolsRequest()
};
}
- private static RequestContext CreateCallToolRequest(string toolName, IReadOnlyDictionary? arguments = null)
+ private static RequestContext CreateCallToolRequest(string toolName, IDictionary? arguments = null)
{
var mockServer = Substitute.For();
return new RequestContext(mockServer, new() { Method = RequestMethods.ToolsCall })
diff --git a/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/RegistryToolLoaderTests.cs b/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/RegistryToolLoaderTests.cs
index 28bb23b770..81e7987459 100644
--- a/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/RegistryToolLoaderTests.cs
+++ b/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/RegistryToolLoaderTests.cs
@@ -36,7 +36,7 @@ private static ModelContextProtocol.Server.RequestContext CreateCallToolRequest(string toolName, IReadOnlyDictionary? arguments = null)
+ private static ModelContextProtocol.Server.RequestContext CreateCallToolRequest(string toolName, IDictionary? arguments = null)
{
var mockServer = Substitute.For();
return new ModelContextProtocol.Server.RequestContext(mockServer, new() { Method = RequestMethods.ToolsCall })
diff --git a/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/ServerToolLoaderTests.cs b/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/ServerToolLoaderTests.cs
index 72d306f550..027ea726cc 100644
--- a/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/ServerToolLoaderTests.cs
+++ b/core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/ServerToolLoaderTests.cs
@@ -36,7 +36,7 @@ private static ModelContextProtocol.Server.RequestContext CreateCallToolRequest(string toolName, IReadOnlyDictionary? arguments = null)
+ private static ModelContextProtocol.Server.RequestContext CreateCallToolRequest(string toolName, IDictionary? arguments = null)
{
var mockServer = Substitute.For();
return new ModelContextProtocol.Server.RequestContext(mockServer, new() { Method = RequestMethods.ToolsCall })