22 lines
710 B
C#
22 lines
710 B
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using QuickstartWeatherServer.Tools;
|
|
using System.Net.Http.Headers;
|
|
|
|
var builder = Host.CreateApplicationBuilder(args);
|
|
|
|
builder.Services.AddMcpServer()
|
|
.WithStdioServerTransport()
|
|
.WithTools<WeatherTools>();
|
|
|
|
builder.Logging.AddConsole(options =>
|
|
{
|
|
options.LogToStandardErrorThreshold = LogLevel.Trace;
|
|
});
|
|
|
|
using var httpClient = new HttpClient { BaseAddress = new Uri("https://api.weather.gov") };
|
|
httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("weather-tool", "1.0"));
|
|
builder.Services.AddSingleton(httpClient);
|
|
|
|
await builder.Build().RunAsync();
|