diff --git a/dotnet/Directory.Packages.props b/dotnet/Directory.Packages.props
index 1f481741f41c..1170bfd58525 100644
--- a/dotnet/Directory.Packages.props
+++ b/dotnet/Directory.Packages.props
@@ -81,7 +81,7 @@
-
+
diff --git a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/AgentAvailableAsMCPToolSample.cs b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/AgentAvailableAsMCPToolSample.cs
index 8e4c6556694a..59972506adcb 100644
--- a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/AgentAvailableAsMCPToolSample.cs
+++ b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/AgentAvailableAsMCPToolSample.cs
@@ -33,7 +33,7 @@ public static async Task RunAsync()
Console.WriteLine($"Running the {nameof(AgentAvailableAsMCPToolSample)} sample.");
// Create an MCP client
- await using IMcpClient mcpClient = await CreateMcpClientAsync();
+ McpClient mcpClient = await CreateMcpClientAsync();
// Retrieve and display the list provided by the MCP server
IList tools = await mcpClient.ListToolsAsync();
diff --git a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/AzureAIAgentWithMCPToolsSample.cs b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/AzureAIAgentWithMCPToolsSample.cs
index 7fd1e1c7fb14..c4c3a9da93d7 100644
--- a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/AzureAIAgentWithMCPToolsSample.cs
+++ b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/AzureAIAgentWithMCPToolsSample.cs
@@ -37,7 +37,7 @@ public static async Task RunAsync()
Console.WriteLine($"Running the {nameof(AzureAIAgentWithMCPToolsSample)} sample.");
// Create an MCP client
- await using IMcpClient mcpClient = await CreateMcpClientAsync();
+ McpClient mcpClient = await CreateMcpClientAsync();
// Retrieve and display the list provided by the MCP server
IList tools = await mcpClient.ListToolsAsync();
diff --git a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/BaseSample.cs b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/BaseSample.cs
index d7a3058cbb64..d2ee542ef8b7 100644
--- a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/BaseSample.cs
+++ b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/BaseSample.cs
@@ -21,14 +21,14 @@ internal abstract class BaseSample
/// Optional kernel instance to use for the MCP client.
/// Optional handler for MCP sampling requests.
/// An instance of .
- protected static Task CreateMcpClientAsync(
+ protected static Task CreateMcpClientAsync(
Kernel? kernel = null,
Func, CancellationToken, Task>? samplingRequestHandler = null)
{
KernelFunction? skSamplingHandler = null;
// Create and return the MCP client
- return McpClientFactory.CreateAsync(
+ return McpClient.CreateAsync(
clientTransport: new StdioClientTransport(new StdioClientTransportOptions
{
Name = "MCPServer",
@@ -36,12 +36,9 @@ protected static Task CreateMcpClientAsync(
}),
clientOptions: samplingRequestHandler != null ? new McpClientOptions()
{
- Capabilities = new ClientCapabilities
+ Handlers = new()
{
- Sampling = new SamplingCapability
- {
- SamplingHandler = InvokeHandlerAsync
- },
+ SamplingHandler = InvokeHandlerAsync,
},
} : null
);
diff --git a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/ChatCompletionAgentWithMCPToolsSample.cs b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/ChatCompletionAgentWithMCPToolsSample.cs
index 9e7743106137..28b29808d1cf 100644
--- a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/ChatCompletionAgentWithMCPToolsSample.cs
+++ b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/ChatCompletionAgentWithMCPToolsSample.cs
@@ -34,7 +34,7 @@ public static async Task RunAsync()
Console.WriteLine($"Running the {nameof(ChatCompletionAgentWithMCPToolsSample)} sample.");
// Create an MCP client
- await using IMcpClient mcpClient = await CreateMcpClientAsync();
+ McpClient mcpClient = await CreateMcpClientAsync();
// Retrieve and display the list provided by the MCP server
IList tools = await mcpClient.ListToolsAsync();
diff --git a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPPromptSample.cs b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPPromptSample.cs
index 4b349299734f..44fa4bb99703 100644
--- a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPPromptSample.cs
+++ b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPPromptSample.cs
@@ -29,7 +29,7 @@ public static async Task RunAsync()
Console.WriteLine($"Running the {nameof(MCPPromptSample)} sample.");
// Create an MCP client
- await using IMcpClient mcpClient = await CreateMcpClientAsync();
+ McpClient mcpClient = await CreateMcpClientAsync();
// Retrieve and display the list of prompts provided by the MCP server
IList prompts = await mcpClient.ListPromptsAsync();
diff --git a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPResourceTemplatesSample.cs b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPResourceTemplatesSample.cs
index 375801c851fd..30f6bb0832eb 100644
--- a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPResourceTemplatesSample.cs
+++ b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPResourceTemplatesSample.cs
@@ -29,7 +29,7 @@ public static async Task RunAsync()
Console.WriteLine($"Running the {nameof(MCPResourceTemplatesSample)} sample.");
// Create an MCP client
- await using IMcpClient mcpClient = await CreateMcpClientAsync();
+ McpClient mcpClient = await CreateMcpClientAsync();
// Retrieve list of resource templates provided by the MCP server and display them
IList resourceTemplates = await mcpClient.ListResourceTemplatesAsync();
@@ -48,7 +48,7 @@ public static async Task RunAsync()
string prompt = "What is the Semantic Kernel?";
// Retrieve relevant to the prompt records via MCP resource template
- ReadResourceResult resource = await mcpClient.ReadResourceAsync($"vectorStore://records/{prompt}");
+ ReadResourceResult resource = await mcpClient.ReadResourceAsync(new Uri($"vectorStore://records/{prompt}"));
// Add the resource content/records to the chat history and prompt the AI model to explain what SK is
ChatHistory chatHistory = [];
diff --git a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPResourcesSample.cs b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPResourcesSample.cs
index 5dac5012e22a..9877d23cd73e 100644
--- a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPResourcesSample.cs
+++ b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPResourcesSample.cs
@@ -29,7 +29,7 @@ public static async Task RunAsync()
Console.WriteLine($"Running the {nameof(MCPResourcesSample)} sample.");
// Create an MCP client
- await using IMcpClient mcpClient = await CreateMcpClientAsync();
+ McpClient mcpClient = await CreateMcpClientAsync();
// Retrieve list of resources provided by the MCP server and display them
IList resources = await mcpClient.ListResourcesAsync();
@@ -46,7 +46,7 @@ public static async Task RunAsync()
};
// Retrieve the `image://cat.jpg` resource from the MCP server
- ReadResourceResult resource = await mcpClient.ReadResourceAsync("image://cat.jpg");
+ ReadResourceResult resource = await mcpClient.ReadResourceAsync(new Uri("image://cat.jpg"));
// Add the resource to the chat history and prompt the AI model to describe the content of the image
ChatHistory chatHistory = [];
diff --git a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPSamplingSample.cs b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPSamplingSample.cs
index c8a5f6f6a823..fc07d0e71820 100644
--- a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPSamplingSample.cs
+++ b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPSamplingSample.cs
@@ -47,7 +47,7 @@ public static async Task RunAsync()
kernel.FunctionInvocationFilters.Add(new HumanInTheLoopFilter());
// Create an MCP client with a custom sampling request handler
- await using IMcpClient mcpClient = await CreateMcpClientAsync(kernel, SamplingRequestHandlerAsync);
+ McpClient mcpClient = await CreateMcpClientAsync(kernel, SamplingRequestHandlerAsync);
// Import MCP tools as Kernel functions so AI model can call them
IList tools = await mcpClient.ListToolsAsync();
diff --git a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPToolsSample.cs b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPToolsSample.cs
index 0d087aa12970..31245c43a3a1 100644
--- a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPToolsSample.cs
+++ b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPClient/Samples/MCPToolsSample.cs
@@ -31,7 +31,7 @@ public static async Task RunAsync()
Console.WriteLine($"Running the {nameof(MCPToolsSample)} sample.");
// Create an MCP client
- await using IMcpClient mcpClient = await CreateMcpClientAsync();
+ McpClient mcpClient = await CreateMcpClientAsync();
// Retrieve and display the list provided by the MCP server
IList tools = await mcpClient.ListToolsAsync();
diff --git a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPServer/Resources/ResourceDefinition.cs b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPServer/Resources/ResourceDefinition.cs
index f0bd509ab0e6..1e04f60db486 100644
--- a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPServer/Resources/ResourceDefinition.cs
+++ b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPServer/Resources/ResourceDefinition.cs
@@ -76,10 +76,7 @@ public static ResourceDefinition CreateBlobResource(string uri, string name, byt
/// The result of the invocation.
public async ValueTask InvokeHandlerAsync(RequestContext context, CancellationToken cancellationToken)
{
- if (this._kernelFunction == null)
- {
- this._kernelFunction = KernelFunctionFactory.CreateFromMethod(this.Handler);
- }
+ this._kernelFunction ??= KernelFunctionFactory.CreateFromMethod(this.Handler);
this.Kernel
??= context.Server.Services?.GetRequiredService()
diff --git a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPServer/Tools/MailboxUtils.cs b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPServer/Tools/MailboxUtils.cs
index fe4ace51335f..bc02cee332bf 100644
--- a/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPServer/Tools/MailboxUtils.cs
+++ b/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPServer/Tools/MailboxUtils.cs
@@ -17,7 +17,7 @@ internal sealed class MailboxUtils
/// mechanism for summarization.
///
[KernelFunction]
- public static async Task SummarizeUnreadEmailsAsync([FromKernelServices] IMcpServer server)
+ public static async Task SummarizeUnreadEmailsAsync([FromKernelServices] McpServer server)
{
if (server.ClientCapabilities?.Sampling is null)
{
diff --git a/dotnet/samples/Demos/ModelContextProtocolPlugin/Program.cs b/dotnet/samples/Demos/ModelContextProtocolPlugin/Program.cs
index fe4c53538fa1..8528c200c9b0 100644
--- a/dotnet/samples/Demos/ModelContextProtocolPlugin/Program.cs
+++ b/dotnet/samples/Demos/ModelContextProtocolPlugin/Program.cs
@@ -20,7 +20,7 @@
}
// Create an MCPClient for the GitHub server
-await using var mcpClient = await McpClientFactory.CreateAsync(new StdioClientTransport(new()
+var mcpClient = await McpClient.CreateAsync(new StdioClientTransport(new()
{
Name = "MCPServer",
Command = "npx",
diff --git a/dotnet/samples/Demos/ModelContextProtocolPluginAuth/Program.cs b/dotnet/samples/Demos/ModelContextProtocolPluginAuth/Program.cs
index 29f6b0c509f8..d1323c5acfce 100644
--- a/dotnet/samples/Demos/ModelContextProtocolPluginAuth/Program.cs
+++ b/dotnet/samples/Demos/ModelContextProtocolPluginAuth/Program.cs
@@ -36,22 +36,22 @@
builder.AddConsole();
});
-// Create SSE client transport for the MCP server
+// Create streamable HTTP client transport for the MCP server
var serverUrl = "http://localhost:7071/";
-var transport = new SseClientTransport(new()
+var transport = new HttpClientTransport(new()
{
Endpoint = new Uri(serverUrl),
Name = "Secure Weather Client",
OAuth = new()
{
- ClientName = "ProtectedMcpClient",
+ ClientId = "ProtectedMcpClient",
RedirectUri = new Uri("http://localhost:1179/callback"),
AuthorizationRedirectDelegate = HandleAuthorizationUrlAsync,
}
}, httpClient, consoleLoggerFactory);
// Create an MCPClient for the protected MCP server
-await using var mcpClient = await McpClientFactory.CreateAsync(transport, loggerFactory: consoleLoggerFactory);
+await using var mcpClient = await McpClient.CreateAsync(transport, loggerFactory: consoleLoggerFactory);
// Retrieve the list of tools available on the GitHub server
var tools = await mcpClient.ListToolsAsync().ConfigureAwait(false);