forked from microsoft/semantic-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
28 lines (23 loc) · 1.01 KB
/
Program.cs
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
// Copyright (c) Microsoft. All rights reserved.
using MCPServer;
using MCPServer.Prompts;
using MCPServer.Tools;
using Microsoft.SemanticKernel;
// Create a kernel builder and add plugins
IKernelBuilder kernelBuilder = Kernel.CreateBuilder();
kernelBuilder.Plugins.AddFromType<DateTimeUtils>();
kernelBuilder.Plugins.AddFromType<WeatherUtils>();
// Build the kernel
Kernel kernel = kernelBuilder.Build();
// Register prompts
PromptRegistry.RegisterPrompt(PromptDefinition.Create(EmbeddedResource.ReadAsString("getCurrentWeatherForCity.json"), kernel));
var builder = Host.CreateEmptyApplicationBuilder(settings: null);
builder.Services
.AddMcpServer()
.WithStdioServerTransport()
// Add all functions from the kernel plugins to the MCP server as tools
.WithTools(kernel.Plugins)
// Register prompt handlers
.WithListPromptsHandler(PromptRegistry.GetHandlerForListPromptRequestsAsync)
.WithGetPromptHandler(PromptRegistry.GetHandlerForGetPromptRequestsAsync);
await builder.Build().RunAsync();