diff --git a/WeatherMcp.sln b/WeatherMcp.sln new file mode 100644 index 0000000..de14a71 --- /dev/null +++ b/WeatherMcp.sln @@ -0,0 +1,36 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{AB7F16E1-ABF4-4D51-B8E2-C725938E46CC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeatherMcp", "src\WeatherMcp\WeatherMcp.csproj", "{878DD43B-9F18-413B-A21C-8451EC475A8C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FFAC5263-DA7E-4E5B-A2CB-6E4D85F15C25}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeatherMcp.Tests", "tests\WeatherMcp.Tests\WeatherMcp.Tests.csproj", "{45593BB3-6CA9-4837-A198-A04AAEA702A1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {878DD43B-9F18-413B-A21C-8451EC475A8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {878DD43B-9F18-413B-A21C-8451EC475A8C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {878DD43B-9F18-413B-A21C-8451EC475A8C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {878DD43B-9F18-413B-A21C-8451EC475A8C}.Release|Any CPU.Build.0 = Release|Any CPU + {45593BB3-6CA9-4837-A198-A04AAEA702A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {45593BB3-6CA9-4837-A198-A04AAEA702A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {45593BB3-6CA9-4837-A198-A04AAEA702A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {45593BB3-6CA9-4837-A198-A04AAEA702A1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {878DD43B-9F18-413B-A21C-8451EC475A8C} = {AB7F16E1-ABF4-4D51-B8E2-C725938E46CC} + {45593BB3-6CA9-4837-A198-A04AAEA702A1} = {FFAC5263-DA7E-4E5B-A2CB-6E4D85F15C25} + EndGlobalSection +EndGlobal diff --git a/src/WeatherMcp/Program.cs b/src/WeatherMcp/Program.cs new file mode 100644 index 0000000..00ff539 --- /dev/null +++ b/src/WeatherMcp/Program.cs @@ -0,0 +1,44 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +var summaries = new[] +{ + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" +}; + +app.MapGet("/weatherforecast", () => +{ + var forecast = Enumerable.Range(1, 5).Select(index => + new WeatherForecast + ( + DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + Random.Shared.Next(-20, 55), + summaries[Random.Shared.Next(summaries.Length)] + )) + .ToArray(); + return forecast; +}) +.WithName("GetWeatherForecast") +.WithOpenApi(); + +app.Run(); + +record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) +{ + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); +} diff --git a/src/WeatherMcp/Properties/launchSettings.json b/src/WeatherMcp/Properties/launchSettings.json new file mode 100644 index 0000000..02fcb3f --- /dev/null +++ b/src/WeatherMcp/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:3951", + "sslPort": 44386 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5235", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7120;http://localhost:5235", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/WeatherMcp/WeatherMcp.csproj b/src/WeatherMcp/WeatherMcp.csproj new file mode 100644 index 0000000..e0e39e0 --- /dev/null +++ b/src/WeatherMcp/WeatherMcp.csproj @@ -0,0 +1,15 @@ + + + + net8.0 + enable + enable + + + + + + + + + diff --git a/src/WeatherMcp/WeatherMcp.http b/src/WeatherMcp/WeatherMcp.http new file mode 100644 index 0000000..bc3ba48 --- /dev/null +++ b/src/WeatherMcp/WeatherMcp.http @@ -0,0 +1,6 @@ +@WeatherMcp_HostAddress = http://localhost:5235 + +GET {{WeatherMcp_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/src/WeatherMcp/appsettings.Development.json b/src/WeatherMcp/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/src/WeatherMcp/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/WeatherMcp/appsettings.json b/src/WeatherMcp/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/src/WeatherMcp/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/tests/WeatherMcp.Tests/GlobalUsings.cs b/tests/WeatherMcp.Tests/GlobalUsings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/tests/WeatherMcp.Tests/GlobalUsings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/tests/WeatherMcp.Tests/UnitTest1.cs b/tests/WeatherMcp.Tests/UnitTest1.cs new file mode 100644 index 0000000..0817231 --- /dev/null +++ b/tests/WeatherMcp.Tests/UnitTest1.cs @@ -0,0 +1,10 @@ +namespace WeatherMcp.Tests; + +public class UnitTest1 +{ + [Fact] + public void Test1() + { + + } +} \ No newline at end of file diff --git a/tests/WeatherMcp.Tests/WeatherMcp.Tests.csproj b/tests/WeatherMcp.Tests/WeatherMcp.Tests.csproj new file mode 100644 index 0000000..1bf94af --- /dev/null +++ b/tests/WeatherMcp.Tests/WeatherMcp.Tests.csproj @@ -0,0 +1,30 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + +