Skip to content

Commit a940709

Browse files
markwallace-microsoftSergeyMenshykh
authored andcommitted
.Net: Some changes to add clarity and align with the Blog Post (microsoft#11359)
### Motivation and Context 1. Include names of classes being used 2. Remove unneeded serviceId ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 Co-authored-by: SergeyMenshykh <[email protected]>
1 parent 9d3d86c commit a940709

File tree

1 file changed

+11
-3
lines changed
  • dotnet/samples/Demos/ModelContextProtocolPlugin

1 file changed

+11
-3
lines changed

dotnet/samples/Demos/ModelContextProtocolPlugin/Program.cs

+11-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
using Microsoft.Extensions.Logging;
66
using Microsoft.SemanticKernel;
77
using Microsoft.SemanticKernel.Connectors.OpenAI;
8+
using ModelContextProtocol;
89
using ModelContextProtocol.Client;
10+
using ModelContextProtocol.Protocol.Types;
911

1012
var config = new ConfigurationBuilder()
1113
.AddUserSecrets<Program>()
@@ -20,7 +22,7 @@
2022

2123
// Create an MCPClient for the GitHub server
2224
await using var mcpClient = await McpClientFactory.CreateAsync(
23-
new()
25+
new McpServerConfig()
2426
{
2527
Id = "github",
2628
Name = "GitHub",
@@ -31,7 +33,14 @@
3133
["arguments"] = "-y @modelcontextprotocol/server-github",
3234
}
3335
},
34-
new() { ClientInfo = new() { Name = "GitHub", Version = "1.0.0" } }).ConfigureAwait(false);
36+
new McpClientOptions()
37+
{
38+
ClientInfo = new Implementation()
39+
{
40+
Name = "GitHub",
41+
Version = "1.0.0"
42+
}
43+
}).ConfigureAwait(false);
3544

3645
// Retrieve the list of tools available on the GitHub server
3746
var tools = await mcpClient.ListToolsAsync().ConfigureAwait(false);
@@ -45,7 +54,6 @@
4554
builder.Services
4655
.AddLogging(c => c.AddDebug().SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace))
4756
.AddOpenAIChatCompletion(
48-
serviceId: "openai",
4957
modelId: config["OpenAI:ChatModelId"] ?? "gpt-4o-mini",
5058
apiKey: apiKey);
5159
Kernel kernel = builder.Build();

0 commit comments

Comments
 (0)