Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -9,10 +9,10 @@

<ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" Version="2.2.0-beta.4" />
<PackageReference Include="Azure.Identity" Version="1.13.2" />
<PackageReference Include="Azure.Identity" Version="1.14.0" />
<PackageReference Include="Microsoft.Extensions.AI" Version="9.5.0" />
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.4.3-preview.1.25230.7" />
<PackageReference Include="ModelContextProtocol" Version="0.1.0-preview.11" />
<PackageReference Include="ModelContextProtocol" Version="0.1.0-preview.14" />
</ItemGroup>

</Project>
11 changes: 5 additions & 6 deletions docs/ai/quickstarts/snippets/mcp-client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Azure.Identity;
using Microsoft.Extensions.AI;
using ModelContextProtocol.Client;
using ModelContextProtocol.Protocol.Transport;

// Create an IChatClient using Azure OpenAI.
IChatClient client =
Expand All @@ -15,7 +14,7 @@

// Create the MCP client
// Configure it to start and connect to your MCP server.
var mcpClient = await McpClientFactory.CreateAsync(
IMcpClient mcpClient = await McpClientFactory.CreateAsync(
new StdioClientTransport(new()
{
Command = "dotnet run",
Expand All @@ -25,8 +24,8 @@

// List all available tools from the MCP server.
Console.WriteLine("Available tools:");
var tools = await mcpClient.ListToolsAsync();
foreach (var tool in tools)
IList<McpClientTool> tools = await mcpClient.ListToolsAsync();
foreach (McpClientTool tool in tools)
{
Console.WriteLine($"{tool}");
}
Expand All @@ -40,7 +39,7 @@
messages.Add(new(ChatRole.User, Console.ReadLine()));

List<ChatResponseUpdate> updates = [];
await foreach (var update in client
await foreach (ChatResponseUpdate update in client
.GetStreamingResponseAsync(messages, new() { Tools = [.. tools] }))
{
Console.Write(update);
Expand All @@ -49,4 +48,4 @@
Console.WriteLine();

messages.AddMessages(updates);
}
}