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
Expand Up @@ -13,7 +13,8 @@


<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.1.0" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.3.1" />
<PackageReference Include="ModelContextProtocol" Version="0.3.0-preview.3" />
</ItemGroup>

<ItemGroup>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ModelContextProtocol" Version="0.1.0-preview.2" />
<PackageReference Include="ModelContextProtocol" Version="0.3.0-preview.3" />
<PackageReference Include="ModelContextProtocol.Core" Version="0.3.0-preview.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@

// map endpoints
app.MapGet("/", () => $"Hello World! {DateTime.Now}");
app.MapMcpSse();

app.Run();
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
@using Microsoft.JSInterop
@using McpSample.BlazorChat
@using McpSample.BlazorChat.Components
@using Microsoft.Extensions.AI
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@


<ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" Version="2.2.0-beta.4" />
<PackageReference Include="Azure.Identity" Version="1.14.0-beta.2" />
<PackageReference Include="Azure.AI.OpenAI" Version="2.2.0-beta.5" />
<PackageReference Include="Azure.Identity" Version="1.14.2" />
<PackageReference Include="Microsoft.Extensions.AI" Version="9.5.0" />
<PackageReference Include="Microsoft.Extensions.AI.AzureAIInference" Version="9.5.0-preview.1.25265.7" />
<PackageReference Include="Microsoft.Extensions.AI.Ollama" Version="9.5.0-preview.1.25265.7" />
<PackageReference Include="ModelContextProtocol" Version="0.1.0-preview.2" />
<PackageReference Include="OpenAI" Version="2.2.0-beta.4" />
<PackageReference Include="ModelContextProtocol" Version="0.3.0-preview.3" />
<PackageReference Include="OpenAI" Version="2.2.0" />
</ItemGroup>


Expand Down
29 changes: 10 additions & 19 deletions 04-PracticalSamples/src/src/McpSample.Chat/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using McpSample.BlazorChat;
using McpSample.BlazorChat.Components;
using Microsoft.Extensions.AI;
using ModelContextProtocol.Client;
using ModelContextProtocol.Configuration;
using ModelContextProtocol.Protocol.Transport;

var builder = WebApplication.CreateBuilder(args);

Expand All @@ -28,23 +27,15 @@
// add MCP client
builder.Services.AddSingleton<IMcpClient>(sp =>
{
McpClientOptions mcpClientOptions = new()
{ ClientInfo = new() { Name = "AspNetCoreSseClient", Version = "1.0.0" } };

HttpClient httpClient = new()
{
BaseAddress = new("https://localhost:7133/sse") //"https +http://aspnetsseserver" + "/sse")
};

McpServerConfig mcpServerConfig = new()
{
Id = "AspNetCoreSse",
Name = "AspNetCoreSse",
TransportType = TransportTypes.Sse,
Location = httpClient.BaseAddress.ToString(),
};

var mcpClient = McpClientFactory.CreateAsync(mcpServerConfig, mcpClientOptions).GetAwaiter().GetResult();
var clientTransport = new SseClientTransport(
new()
{
Name = "AspNetCoreSse Server",
Endpoint = new Uri("https://localhost:7133"), // Remove /sse endpoint since it's deprecated
TransportMode = HttpTransportMode.StreamableHttp // Use new Streamable HTTP transport
});

var mcpClient = McpClientFactory.CreateAsync(clientTransport).GetAwaiter().GetResult();
return mcpClient;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.3.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.1.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.11.2" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.11.2" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.11.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.11.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.11.1" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.7.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.3.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0" />
<PackageReference Include="ModelContextProtocol" Version="0.3.0-preview.3" />
</ItemGroup>
</Project>
Loading