Add MCP Apps extension support (typed metadata, attribute, and helpers) (#1484)
This commit is contained in:
parent
de75c7d0df
commit
f93df7e172
1 changed files with 1896 additions and 1 deletions
34
samples/WeatherAppServer/Program.cs
Normal file
34
samples/WeatherAppServer/Program.cs
Normal file
|
|
@ -0,0 +1,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();
|
||||
Loading…
Reference in a new issue