csharp-sdk/docs/concepts/httpcontext/samples/Program.cs

29 lines
566 B
C#

using HttpContext.Tools;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddMcpServer()
.WithHttpTransport(options =>
{
options.Stateless = true;
})
.WithTools<ContextTools>();
// <snippet_AddHttpContextAccessor>
builder.Services.AddHttpContextAccessor();
// </snippet_AddHttpContextAccessor>
builder.Logging.AddConsole(options =>
{
options.LogToStandardErrorThreshold = LogLevel.Information;
});
var app = builder.Build();
app.UseHttpsRedirection();
app.MapMcp();
app.Run();