Samples for quickstart docs (#104)

* Server quickstart for docs

* WIP

* Client quickstart for docs

* Code review feedback

* Fixing anthropic SDK and improving the prompting

* Little cleanup

* Code review feedback
This commit is contained in:
Aaron Powell 2025-03-27 13:30:19 +11:00 • committed by GitHub
commit 5171ccc3c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,19 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using ModelContextProtocol;
using System.Net.Http.Headers;
var builder = Host.CreateEmptyApplicationBuilder(settings: null);
builder.Services.AddMcpServer()
.WithStdioServerTransport()
.WithToolsFromAssembly();
builder.Services.AddSingleton(_ =>
{
var client = new HttpClient() { BaseAddress = new Uri("https://api.weather.gov") };
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("weather-tool", "1.0"));
return client;
});
await builder.Build().RunAsync();