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
12 changes: 12 additions & 0 deletions IdentityServer/v7/McpDemo/McpDemo.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var builder = DistributedApplication.CreateBuilder(args);

var idp = builder.AddProject<Projects.McpDemo_IdentityServer>("mcpdemo-identityserver");

var mcpServer = builder.AddProject<Projects.McpDemo_McpServer>("mcpdemo-mcpserver")
.WaitFor(idp);

builder.AddProject<Projects.McpDemo_Client>("mcpdemo-client")
.WaitFor(idp)
.WaitFor(mcpServer);

builder.Build().Run();
20 changes: 20 additions & 0 deletions IdentityServer/v7/McpDemo/McpDemo.AppHost/McpDemo.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Aspire.AppHost.Sdk/13.2.2">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\McpDemo.Client\McpDemo.Client.csproj" />
<ProjectReference Include="..\McpDemo.IdentityServer\McpDemo.IdentityServer.csproj" />
<ProjectReference Include="..\McpDemo.McpServer\McpDemo.McpServer.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17049;http://localhost:15292",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21176",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23177",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22125"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15292",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19221",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18150",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20035"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions IdentityServer/v7/McpDemo/McpDemo.AppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,11 @@
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.IdentityModel.Tokens;
using Serilog;
using Serilog.Filters;

namespace McpDemo.IdentityServer;

internal static class HostingExtensions
{
public static WebApplicationBuilder ConfigureLogging(this WebApplicationBuilder builder)
{
// Write most logs to the console but diagnostic data to a file.
// See https://docs.duendesoftware.com/identityserver/diagnostics/data
builder.Host.UseSerilog((ctx, lc) =>
{
lc.WriteTo.Logger(consoleLogger =>
{
consoleLogger.WriteTo.Console(
outputTemplate:
"[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}",
formatProvider: CultureInfo.InvariantCulture);
if (builder.Environment.IsDevelopment())
{
consoleLogger.Filter.ByExcluding(Matching.FromSource("Duende.IdentityServer.Diagnostics.Summary"));
}
});
if (builder.Environment.IsDevelopment())
{
lc.WriteTo.Logger(fileLogger =>
{
fileLogger
.WriteTo.File("./diagnostics/diagnostic.log", rollingInterval: RollingInterval.Day,
fileSizeLimitBytes: 1024 * 1024 * 10, // 10 MB
rollOnFileSizeLimit: true,
outputTemplate:
"[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}",
formatProvider: CultureInfo.InvariantCulture)
.Filter
.ByIncludingOnly(Matching.FromSource("Duende.IdentityServer.Diagnostics.Summary"));
}).Enrich.FromLogContext().ReadFrom.Configuration(ctx.Configuration);
}
});
return builder;
}

public static WebApplication ConfigureServices(this WebApplicationBuilder builder)
{
Expand All @@ -57,17 +20,6 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde
{
// this will add the default dynamic client registration endpoint to the discovery/metadatada documents
options.Discovery.DynamicClientRegistration.RegistrationEndpointMode = RegistrationEndpointMode.Inferred;

options.Events.RaiseErrorEvents = true;
options.Events.RaiseInformationEvents = true;
options.Events.RaiseFailureEvents = true;
options.Events.RaiseSuccessEvents = true;

// Use a large chunk size for diagnostic logs in development where it will be redirected to a local file
if (builder.Environment.IsDevelopment())
{
options.Diagnostics.ChunkSize = 1024 * 1024 * 10; // 10 MB
}
})
.AddTestUsers(TestUsers.Users)
.AddLicenseSummary();
Expand Down Expand Up @@ -113,7 +65,7 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde

public static WebApplication ConfigurePipeline(this WebApplication app)
{
app.UseSerilogRequestLogging();
app.MapDefaultEndpoints();

if (app.Environment.IsDevelopment())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
<ItemGroup>
<PackageReference Include="Duende.IdentityServer" />
<PackageReference Include="Duende.IdentityServer.Configuration" />
<PackageReference Include="Serilog.AspNetCore" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj" />
</ItemGroup>


Expand Down
17 changes: 3 additions & 14 deletions IdentityServer/v7/McpDemo/McpDemo.IdentityServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@
using System.Text;
using Duende.IdentityServer.Licensing;
using McpDemo.IdentityServer;
using Serilog;

Log.Logger = new LoggerConfiguration()
.WriteTo.Console(formatProvider: CultureInfo.InvariantCulture)
.CreateBootstrapLogger();

Log.Information("Starting up");

try
{
var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();

var app = builder
.ConfigureLogging()
.ConfigureServices()
.ConfigurePipeline();

Expand All @@ -32,12 +26,7 @@
}
catch (Exception ex) when (ex is not HostAbortedException)
{
Log.Fatal(ex, "Unhandled exception");
}
finally
{
Log.Information("Shut down complete");
Log.CloseAndFlush();
throw;
}

static string Summary(LicenseUsageSummary usage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
<PackageReference Include="ModelContextProtocol.AspNetCore" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj" />
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions IdentityServer/v7/McpDemo/McpDemo.McpServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();

var serverUrl = "https://localhost:7141";
var inMemoryOAuthServerUrl = "https://localhost:5001/";

Expand Down Expand Up @@ -53,6 +55,8 @@

var app = builder.Build();

app.MapDefaultEndpoints();

app.UseAuthentication();
app.UseAuthorization();

Expand Down
45 changes: 45 additions & 0 deletions IdentityServer/v7/McpDemo/McpDemo.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,68 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McpDemo.IdentityServer", "M
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McpDemo.Client", "McpDemo.Client\McpDemo.Client.csproj", "{8D81440F-4979-4964-B851-2AE6BF348D01}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McpDemo.AppHost", "McpDemo.AppHost\McpDemo.AppHost.csproj", "{0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|x64.ActiveCfg = Debug|Any CPU
{C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|x64.Build.0 = Debug|Any CPU
{C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|x86.ActiveCfg = Debug|Any CPU
{C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Debug|x86.Build.0 = Debug|Any CPU
{C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|Any CPU.Build.0 = Release|Any CPU
{C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|x64.ActiveCfg = Release|Any CPU
{C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|x64.Build.0 = Release|Any CPU
{C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|x86.ActiveCfg = Release|Any CPU
{C7364D55-7AA4-4B41-B9C1-F849AF17CADE}.Release|x86.Build.0 = Release|Any CPU
{DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|x64.ActiveCfg = Debug|Any CPU
{DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|x64.Build.0 = Debug|Any CPU
{DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|x86.ActiveCfg = Debug|Any CPU
{DFEA935E-28EE-406D-8055-7407106EF1B6}.Debug|x86.Build.0 = Debug|Any CPU
{DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|Any CPU.Build.0 = Release|Any CPU
{DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|x64.ActiveCfg = Release|Any CPU
{DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|x64.Build.0 = Release|Any CPU
{DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|x86.ActiveCfg = Release|Any CPU
{DFEA935E-28EE-406D-8055-7407106EF1B6}.Release|x86.Build.0 = Release|Any CPU
{8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|x64.ActiveCfg = Debug|Any CPU
{8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|x64.Build.0 = Debug|Any CPU
{8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|x86.ActiveCfg = Debug|Any CPU
{8D81440F-4979-4964-B851-2AE6BF348D01}.Debug|x86.Build.0 = Debug|Any CPU
{8D81440F-4979-4964-B851-2AE6BF348D01}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D81440F-4979-4964-B851-2AE6BF348D01}.Release|Any CPU.Build.0 = Release|Any CPU
{8D81440F-4979-4964-B851-2AE6BF348D01}.Release|x64.ActiveCfg = Release|Any CPU
{8D81440F-4979-4964-B851-2AE6BF348D01}.Release|x64.Build.0 = Release|Any CPU
{8D81440F-4979-4964-B851-2AE6BF348D01}.Release|x86.ActiveCfg = Release|Any CPU
{8D81440F-4979-4964-B851-2AE6BF348D01}.Release|x86.Build.0 = Release|Any CPU
{0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Debug|x64.ActiveCfg = Debug|Any CPU
{0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Debug|x64.Build.0 = Debug|Any CPU
{0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Debug|x86.ActiveCfg = Debug|Any CPU
{0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Debug|x86.Build.0 = Debug|Any CPU
{0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Release|Any CPU.Build.0 = Release|Any CPU
{0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Release|x64.ActiveCfg = Release|Any CPU
{0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Release|x64.Build.0 = Release|Any CPU
{0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Release|x86.ActiveCfg = Release|Any CPU
{0AA954E8-17F7-4272-BDDC-043DBFB1DBEC}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
12 changes: 12 additions & 0 deletions IdentityServer/v8/McpDemo/McpDemo.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var builder = DistributedApplication.CreateBuilder(args);

var idp = builder.AddProject<Projects.McpDemo_IdentityServer>("mcpdemo-identityserver");

var mcpServer = builder.AddProject<Projects.McpDemo_McpServer>("mcpdemo-mcpserver")
.WaitFor(idp);

builder.AddProject<Projects.McpDemo_Client>("mcpdemo-client")
.WaitFor(idp)
.WaitFor(mcpServer);

builder.Build().Run();
20 changes: 20 additions & 0 deletions IdentityServer/v8/McpDemo/McpDemo.AppHost/McpDemo.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Aspire.AppHost.Sdk/13.2.2">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\McpDemo.Client\McpDemo.Client.csproj" />
<ProjectReference Include="..\McpDemo.IdentityServer\McpDemo.IdentityServer.csproj" />
<ProjectReference Include="..\McpDemo.McpServer\McpDemo.McpServer.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17048;http://localhost:15291",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21175",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23176",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22124"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15291",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19220",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18149",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20034"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions IdentityServer/v8/McpDemo/McpDemo.AppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
Loading
Loading