Skip to content

Commit d9fe226

Browse files
committed
Update ModelContextProtocol to latest
1 parent ec91e11 commit d9fe226

File tree

12 files changed

+53
-48
lines changed

12 files changed

+53
-48
lines changed

Directory.Packages.props

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<PackageVersion Include="Azure.Communication.Sms" Version="1.0.2" />
88
<PackageVersion Include="Azure.Communication.Email" Version="1.0.2" />
99
<PackageVersion Include="Azure.AI.Projects" Version="1.0.0-beta.9" />
10-
<PackageVersion Include="Azure.AI.Agents.Persistent" Version="1.2.0-beta.4" />
11-
<PackageVersion Include="Azure.AI.OpenAI" Version="2.3.0-beta.2" />
10+
<PackageVersion Include="Azure.AI.Agents.Persistent" Version="1.2.0-beta.7" />
11+
<PackageVersion Include="Azure.AI.OpenAI" Version="2.5.0-beta.1" />
1212
<PackageVersion Include="Azure.Bicep.Types" Version="0.6.1" />
1313
<PackageVersion Include="Azure.Core" Version="1.49.0" />
1414
<PackageVersion Include="Azure.Data.AppConfiguration" Version="1.6.1" />
@@ -58,38 +58,38 @@
5858
<PackageVersion Include="Azure.ResourceManager.ResourceGraph" Version="1.1.0" />
5959
<PackageVersion Include="Microsoft.Azure.Kusto.Data" Version="13.0.2" />
6060
<PackageVersion Include="Microsoft.Identity.Client.Broker" Version="4.72.1" />
61-
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="9.10.0" />
62-
<PackageVersion Include="Microsoft.Extensions.AI.Evaluation" Version="9.10.0" />
63-
<PackageVersion Include="Microsoft.Extensions.AI.Evaluation.Quality" Version="9.10.0" />
64-
<PackageVersion Include="Microsoft.Extensions.AI.OpenAI" Version="9.10.0-preview.1.25513.3" />
65-
<PackageVersion Include="ModelContextProtocol" Version="0.4.0-preview.3" />
66-
<PackageVersion Include="ModelContextProtocol.AspNetCore" Version="0.4.0-preview.3" />
67-
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="9.0.9" />
68-
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.9" />
69-
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.9" />
70-
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.9" />
61+
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="10.0.1" />
62+
<PackageVersion Include="Microsoft.Extensions.AI.Evaluation" Version="10.0.0" />
63+
<PackageVersion Include="Microsoft.Extensions.AI.Evaluation.Quality" Version="10.0.0" />
64+
<PackageVersion Include="Microsoft.Extensions.AI.OpenAI" Version="10.0.1-preview.1.25571.5" />
65+
<PackageVersion Include="ModelContextProtocol" Version="0.4.1-preview.1" />
66+
<PackageVersion Include="ModelContextProtocol.AspNetCore" Version="0.4.1-preview.1" />
67+
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="10.0.0" />
68+
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.0" />
69+
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.0" />
70+
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0" />
7171
<PackageVersion Include="Microsoft.Identity.Abstractions" Version="9.5.0" />
7272
<PackageVersion Include="Microsoft.Identity.Web" Version="4.0.1" />
7373
<PackageVersion Include="Microsoft.Identity.Web.Azure" Version="4.0.1" />
7474
<PackageVersion Include="Microsoft.HybridRow" Version="1.1.0-preview3" />
7575
<PackageVersion Include="Microsoft.Azure.Cosmos.Aot" Version="0.1.4-preview.2" />
7676
<PackageVersion Include="Microsoft.Azure.Mcp.AzTypes.Internal.Compact" Version="0.2.802" />
77-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.9" />
78-
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.9" />
77+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
78+
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
7979
<PackageVersion Include="MySqlConnector" Version="2.4.0" />
8080
<PackageVersion Include="Npgsql" Version="9.0.3" />
8181
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
82-
<PackageVersion Include="System.CommandLine" Version="2.0.0-rc.1.25451.107" />
83-
<PackageVersion Include="System.Formats.Asn1" Version="9.0.9" />
82+
<PackageVersion Include="System.CommandLine" Version="2.0.0" />
83+
<PackageVersion Include="System.Formats.Asn1" Version="10.0.0" />
8484
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.14.0" />
85-
<PackageVersion Include="System.Linq.AsyncEnumerable" Version="10.0.0-rc.1.25451.107" />
86-
<PackageVersion Include="System.Net.ServerSentEvents" Version="10.0.0-rc.1.25451.107" />
87-
<PackageVersion Include="System.Numerics.Tensors" Version="9.0.0" />
88-
<PackageVersion Include="System.Text.Json" Version="9.0.9" />
85+
<PackageVersion Include="System.Linq.AsyncEnumerable" Version="10.0.0" />
86+
<PackageVersion Include="System.Net.ServerSentEvents" Version="10.0.0" />
87+
<PackageVersion Include="System.Numerics.Tensors" Version="10.0.0" />
88+
<PackageVersion Include="System.Text.Json" Version="10.0.0" />
8989
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.12.0" />
9090
<PackageVersion Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.3.0" />
9191
<PackageVersion Include="Microsoft.Extensions.Azure" Version="1.11.0" />
92-
<PackageVersion Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.9" />
92+
<PackageVersion Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.0" />
9393
<PackageVersion Include="Azure.Search.Documents" Version="11.7.0-beta.7" />
9494
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
9595
<PackageVersion Include="NSubstitute" Version="5.3.0" />

core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/BaseToolLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static BaseToolLoader()
6262
/// </returns>
6363
protected static JsonElement GetParametersJsonElement(RequestContext<CallToolRequestParams> request)
6464
{
65-
IReadOnlyDictionary<string, JsonElement>? args = request.Params?.Arguments;
65+
IDictionary<string, JsonElement>? args = request.Params?.Arguments;
6666
if (args != null && args.TryGetValue("parameters", out var parametersElem) && parametersElem.ValueKind == JsonValueKind.Object)
6767
{
6868
return parametersElem;

core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/NamespaceToolLoader.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ private async Task<CallToolResult> InvokeChildToolAsync(
264264
string? intent,
265265
string namespaceName,
266266
string command,
267-
IReadOnlyDictionary<string, JsonElement> parameters,
267+
IDictionary<string, JsonElement> parameters,
268268
CancellationToken cancellationToken)
269269
{
270270
if (request.Params == null)
@@ -458,7 +458,7 @@ private async Task<CallToolResult> InvokeToolLearn(RequestContext<CallToolReques
458458
if (SupportsSampling(request.Server) && !string.IsNullOrWhiteSpace(intent))
459459
{
460460
var availableTools = GetChildToolList(request, namespaceName);
461-
(string? commandName, IReadOnlyDictionary<string, JsonElement> parameters) = await GetCommandAndParametersFromIntentAsync(request, intent, namespaceName, availableTools, cancellationToken);
461+
(string? commandName, IDictionary<string, JsonElement> parameters) = await GetCommandAndParametersFromIntentAsync(request, intent, namespaceName, availableTools, cancellationToken);
462462
if (commandName != null)
463463
{
464464
response = await InvokeChildToolAsync(request, intent, namespaceName, commandName, parameters, cancellationToken);
@@ -586,7 +586,7 @@ private static bool IsRawMcpToolInputOption(Option option)
586586
string.Equals(NameNormalization.NormalizeOptionName(alias), RawMcpToolInputOptionName, StringComparison.OrdinalIgnoreCase));
587587
}
588588

589-
private static IReadOnlyDictionary<string, JsonElement> GetParametersFromArgs(IReadOnlyDictionary<string, JsonElement>? args)
589+
private static Dictionary<string, JsonElement> GetParametersFromArgs(IDictionary<string, JsonElement>? args)
590590
{
591591
if (args == null || !args.TryGetValue("parameters", out var paramsElem))
592592
{
@@ -623,7 +623,7 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
623623
}, cancellationToken);
624624
}
625625

626-
private async Task<(string? commandName, IReadOnlyDictionary<string, JsonElement> parameters)> GetCommandAndParametersFromIntentAsync(
626+
private async Task<(string? commandName, Dictionary<string, JsonElement> parameters)> GetCommandAndParametersFromIntentAsync(
627627
RequestContext<CallToolRequestParams> request,
628628
string intent,
629629
string namespaceName,
@@ -638,11 +638,12 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
638638

639639
var samplingRequest = new CreateMessageRequestParams
640640
{
641+
MaxTokens = 1000,
641642
Messages = [
642643
new SamplingMessage
643644
{
644645
Role = Role.Assistant,
645-
Content = new TextContentBlock{
646+
Content = [new TextContentBlock{
646647
Text = $"""
647648
This is a list of available commands for the {namespaceName} server.
648649
@@ -666,17 +667,17 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
666667
Available Commands:
667668
{availableToolsJson}
668669
"""
669-
}
670+
}]
670671
}
671672
],
672673
};
673674
try
674675
{
675676
var samplingResponse = await request.Server.SampleAsync(samplingRequest, cancellationToken);
676-
var samplingContent = samplingResponse.Content as TextContentBlock;
677+
var samplingContent = samplingResponse.Content is { Count: > 0 } ? samplingResponse.Content[0] as TextContentBlock : null;
677678
var toolCallJson = samplingContent?.Text?.Trim();
678679
string? commandName = null;
679-
IReadOnlyDictionary<string, JsonElement> parameters = new Dictionary<string, JsonElement>();
680+
var parameters = new Dictionary<string, JsonElement>();
680681

681682
if (!string.IsNullOrEmpty(toolCallJson))
682683
{

core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/RegistryToolLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public override async ValueTask<CallToolResult> CallToolHandler(RequestContext<C
147147
/// </summary>
148148
/// <param name="args">The arguments to transform to parameters.</param>
149149
/// <returns>A dictionary of parameter names and values compatible with McpClientExtensions.CallToolAsync.</returns>
150-
private static Dictionary<string, object?> TransformArgumentsToDictionary(IReadOnlyDictionary<string, JsonElement>? args)
150+
private static Dictionary<string, object?> TransformArgumentsToDictionary(IDictionary<string, JsonElement>? args)
151151
{
152152
if (args == null)
153153
{

core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/ServerToolLoader.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,12 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
456456

457457
var samplingRequest = new CreateMessageRequestParams
458458
{
459+
MaxTokens = 1000,
459460
Messages = [
460461
new SamplingMessage
461462
{
462463
Role = Role.Assistant,
463-
Content = new TextContentBlock{
464+
Content = [new TextContentBlock{
464465
Text = $"""
465466
This is a list of available commands for the {tool} server.
466467
@@ -484,14 +485,14 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
484485
Available Commands:
485486
{availableToolsJson}
486487
"""
487-
}
488+
}]
488489
}
489490
],
490491
};
491492
try
492493
{
493494
var samplingResponse = await request.Server.SampleAsync(samplingRequest, cancellationToken);
494-
var samplingContent = samplingResponse.Content as TextContentBlock;
495+
var samplingContent = samplingResponse.Content is { Count: > 0 } ? samplingResponse.Content[0] as TextContentBlock : null;
495496
var toolCallJson = samplingContent?.Text?.Trim();
496497
string? commandName = null;
497498
Dictionary<string, object?> parameters = [];

core/Azure.Mcp.Core/src/Areas/Server/Commands/ToolLoading/SingleProxyToolLoader.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,12 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
366366

367367
var samplingRequest = new CreateMessageRequestParams
368368
{
369+
MaxTokens = 1000,
369370
Messages = [
370371
new SamplingMessage
371372
{
372373
Role = Role.Assistant,
373-
Content = new TextContentBlock{
374+
Content = [new TextContentBlock{
374375
Text = $"""
375376
The following is a list of available tools for the Azure server.
376377
@@ -385,14 +386,14 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
385386
Available Tools:
386387
{toolsJson}
387388
"""
388-
}
389+
}]
389390
}
390391
],
391392
};
392393
try
393394
{
394395
var samplingResponse = await request.Server.SampleAsync(samplingRequest, cancellationToken);
395-
var samplingContent = samplingResponse.Content as TextContentBlock;
396+
var samplingContent = samplingResponse.Content is { Count: > 0 } ? samplingResponse.Content[0] as TextContentBlock : null;
396397
var toolName = samplingContent?.Text?.Trim();
397398
if (!string.IsNullOrEmpty(toolName) && toolName != "Unknown")
398399
{
@@ -421,11 +422,12 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
421422

422423
var samplingRequest = new CreateMessageRequestParams
423424
{
425+
MaxTokens = 1000,
424426
Messages = [
425427
new SamplingMessage
426428
{
427429
Role = Role.Assistant,
428-
Content = new TextContentBlock{
430+
Content = [new TextContentBlock{
429431
Text = $"""
430432
This is a list of available commands for the {tool} server.
431433
@@ -449,14 +451,14 @@ await request.Server.NotifyProgressAsync(progressToken.Value,
449451
Available Commands:
450452
{toolsJson}
451453
"""
452-
}
454+
}]
453455
}
454456
],
455457
};
456458
try
457459
{
458460
var samplingResponse = await request.Server.SampleAsync(samplingRequest, cancellationToken);
459-
var samplingContent = samplingResponse.Content as TextContentBlock;
461+
var samplingContent = samplingResponse.Content is { Count: > 0 } ? samplingResponse.Content[0] as TextContentBlock : null;
460462
var toolCallJson = samplingContent?.Text?.Trim();
461463
string? commandName = null;
462464
Dictionary<string, object?> parameters = [];

core/Azure.Mcp.Core/src/Commands/CommandExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static class CommandExtensions
1818
/// <param name="command">The command to parse options for</param>
1919
/// <param name="arguments">Dictionary of argument name/value pairs</param>
2020
/// <returns>ParseResult containing the parsed arguments</returns>
21-
public static ParseResult ParseFromDictionary(this Command command, IReadOnlyDictionary<string, JsonElement>? arguments)
21+
public static ParseResult ParseFromDictionary(this Command command, IDictionary<string, JsonElement>? arguments)
2222
{
2323
if (arguments == null || arguments.Count == 0)
2424
{
@@ -75,7 +75,7 @@ public static ParseResult ParseFromDictionary(this Command command, IReadOnlyDic
7575
return command.Parse([.. args]);
7676
}
7777

78-
public static ParseResult ParseFromRawMcpToolInput(this Command command, IReadOnlyDictionary<string, JsonElement>? arguments)
78+
public static ParseResult ParseFromRawMcpToolInput(this Command command, IDictionary<string, JsonElement>? arguments)
7979
{
8080
var args = new List<string>();
8181

core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/Runtime/McpRuntimeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private static RequestContext<ListToolsRequestParams> CreateListToolsRequest()
5353
};
5454
}
5555

56-
private static RequestContext<CallToolRequestParams> CreateCallToolRequest(string toolName = "test-tool", IReadOnlyDictionary<string, JsonElement>? arguments = null)
56+
private static RequestContext<CallToolRequestParams> CreateCallToolRequest(string toolName = "test-tool", IDictionary<string, JsonElement>? arguments = null)
5757
{
5858
return new RequestContext<CallToolRequestParams>(CreateMockServer(), new() { Method = RequestMethods.ToolsCall })
5959
{

core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/BaseToolLoaderTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,13 @@ public async Task CreateClientOptions_SamplingHandler_DelegatesToServerSendReque
192192

193193
var samplingRequest = new CreateMessageRequestParams
194194
{
195+
MaxTokens = 1000,
195196
Messages =
196197
[
197198
new SamplingMessage
198199
{
199200
Role = Role.User,
200-
Content = new TextContentBlock { Text = "Test message" }
201+
Content = [new TextContentBlock { Text = "Test message" }]
201202
}
202203
]
203204
};
@@ -208,7 +209,7 @@ public async Task CreateClientOptions_SamplingHandler_DelegatesToServerSendReque
208209
Result = JsonSerializer.SerializeToNode(new CreateMessageResult
209210
{
210211
Role = Role.Assistant,
211-
Content = new TextContentBlock { Text = "Mock response" },
212+
Content = [new TextContentBlock { Text = "Mock response" }],
212213
Model = "test-model"
213214
})
214215
};

core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/ToolLoading/CompositeToolLoaderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private static RequestContext<ListToolsRequestParams> CreateListToolsRequest()
2828
};
2929
}
3030

31-
private static RequestContext<CallToolRequestParams> CreateCallToolRequest(string toolName, IReadOnlyDictionary<string, JsonElement>? arguments = null)
31+
private static RequestContext<CallToolRequestParams> CreateCallToolRequest(string toolName, IDictionary<string, JsonElement>? arguments = null)
3232
{
3333
var mockServer = Substitute.For<McpServer>();
3434
return new RequestContext<CallToolRequestParams>(mockServer, new() { Method = RequestMethods.ToolsCall })

0 commit comments

Comments
 (0)