Skip to content

.Net: Some changes to add clarity and align with the Blog Post #11359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions dotnet/samples/Demos/ModelContextProtocolPlugin/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using ModelContextProtocol;
using ModelContextProtocol.Client;
using ModelContextProtocol.Protocol.Types;

var config = new ConfigurationBuilder()
.AddUserSecrets<Program>()
Expand All @@ -20,7 +22,7 @@

// Create an MCPClient for the GitHub server
await using var mcpClient = await McpClientFactory.CreateAsync(
new()
new McpServerConfig()
{
Id = "github",
Name = "GitHub",
Expand All @@ -31,7 +33,14 @@
["arguments"] = "-y @modelcontextprotocol/server-github",
}
},
new() { ClientInfo = new() { Name = "GitHub", Version = "1.0.0" } }).ConfigureAwait(false);
new McpClientOptions()
{
ClientInfo = new Implementation()
{
Name = "GitHub",
Version = "1.0.0"
}
}).ConfigureAwait(false);

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