Add MCP Apps extension support (typed metadata, attribute, and helpers) (#1484)

This commit is contained in:
Copilot 2026-06-17 13:28:47 -07:00 • committed by GitHub
commit f93df7e172
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View 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();