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:
parent
8be681543d
commit
5171ccc3c3
1 changed files with 223 additions and 1 deletions
19
samples/QuickstartWeatherServer/Program.cs
Normal file
19
samples/QuickstartWeatherServer/Program.cs
Normal 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();
|
||||
Loading…
Reference in a new issue