You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Demonstrates how to use the MCP tools and MCP prompt with the Semantic Kernel.
178
+
/// Demonstrates how to use the MCP prompt with the Semantic Kernel.
179
179
/// The code in this method:
180
180
/// 1. Creates an MCP client.
181
-
/// 2. Retrieves the list of tools provided by the MCP server.
182
-
/// 3. Retrieves the list of prompts provided by the MCP server.
183
-
/// 4. Creates a kernel and registers the MCP tools as Kernel functions.
184
-
/// 5. Requests the `GetCurrentWeatherForCity` prompt from the MCP server.
185
-
/// 6. The MCP server renders the prompt using the `Boston` as value for the `city` parameter and the result of the `DateTimeUtils-GetCurrentDateTimeInUtc` server-side invocation added to the prompt as part of prompt rendering.
186
-
/// 7. Converts the MCP server prompt: list of messages where each message is represented by content and role to a chat history.
187
-
/// 8. Sends the chat history to the AI model together with the MCP tools represented as Kernel functions.
188
-
/// 9. The AI model calls WeatherUtils-GetWeatherForCity function with the current date time and the `Boston` arguments extracted from the prompt to get the weather information.
189
-
/// 10. Having received the weather information from the function call, the AI model returns the answer to the prompt.
181
+
/// 2. Retrieves the list of prompts provided by the MCP server.
182
+
/// 3. Gets the current weather for Boston and Sydney using the `GetCurrentWeatherForCity` prompt.
183
+
/// 4. Adds the MCP server prompts to the chat history and prompts the AI model to compare the weather in the two cities and suggest the best place to go for a walk.
184
+
/// 5. After receiving and processing the weather data for both cities and the prompt, the AI model returns an answer.
190
185
/// </summary>
191
-
privatestaticasyncTaskUseMCPToolsAndPromptAsync()
186
+
privatestaticasyncTaskUseMCPPromptAsync()
192
187
{
193
-
Console.WriteLine($"Running the {nameof(UseMCPToolsAndPromptAsync)} sample.");
188
+
Console.WriteLine($"Running the {nameof(UseMCPPromptAsync)} sample.");
// The expected output is: The weather in Boston as of 2025-04-02 16:39:40 is 61°F and rainy.
220
+
// The expected output is: Given these conditions, Sydney would be the better choice for a pleasant walk, as the sunny and warm weather is ideal for outdoor activities.
221
+
// The rain in Boston could make walking less enjoyable and potentially inconvenient.
0 commit comments