-
Notifications
You must be signed in to change notification settings - Fork 711
Expand file tree
/
Copy pathProgram.cs
More file actions
34 lines (30 loc) · 1.01 KB
/
Program.cs
File metadata and controls
34 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using Microsoft.Extensions.DependencyInjection;
using ModelContextProtocol.AspNetCore;
using ModelContextProtocol.Extensions.Apps;
using ModelContextProtocol.Protocol;
using ModelContextProtocol.Server;
using System.Net.Http.Headers;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton(_ =>
{
var client = new HttpClient { BaseAddress = new Uri("https://api.weather.gov") };
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("WeatherAppServer", "1.0"));
return client;
});
builder.Services
.AddMcpServer(options =>
{
options.ServerInfo = new Implementation { Name = "weather-app-server", Version = "1.0.0" };
options.Capabilities = new ServerCapabilities
{
Tools = new ToolsCapability(),
Resources = new ResourcesCapability(),
};
})
.WithHttpTransport()
.WithTools<WeatherTools>()
.WithResources<WeatherResources>()
.WithMcpApps();
var app = builder.Build();
app.MapMcp("/mcp");
app.Run();