Mpc Csharp Semantickernel

Mpc Csharp Semantickernel

🚀 mpc-csharp-semantickernel

本项目是一个使用微软语义内核(Semantic Kernel)与OpenAI以及官方C# SDK实现模型上下文协议的示例。通过该示例,你可以参考模型上下文协议的具体实现,其官方仓库链接为:https://github.com/modelcontextprotocol/csharp-sdk

🚀 快速开始

先决条件

  • SMTP邮件服务器(用于EmailTools功能)
  • OpenAI API密钥

如何运行示例项目

  1. 使用OpenAI开发者仪表盘获取一个API密钥。
  2. 填充每个项目的appsettings配置信息。
  3. 工具/EmailTool.cs文件中硬编码了一个电子邮件地址字典,用于发送邮件。请更新此字典中的电子邮件地址列表,建议将其改为配置设置。
  4. 运行项目,默认启动地址为http://localhost:5109

配置说明

WebAppMCPPoc项目

{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"OpenAI": {
"ApiKey": "",
"ChatModelId" : "gpt-4o-mini"
}
}

MCPServer项目

{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"EmailSettings": {
"SMTPServer": {
"MailPort": "465",
"MailServer": "",
"Sender": "",
"SenderName": "",
"Password": "",
"Username": ""
}
}
}

发送请求示例

可以使用Postman等工具发送请求。

示例请求: POST https://localhost:7113/chat Body内容:{ "text": "发一封邮件给aFriend,告诉他你是一个AI,并用250字说明你是如何使用C#实现的。"}

将"aFriend"替换为在EmailTool类中的emails字典中已添加的一个名称。

private static readonly Dictionary<string, string> emails = new Dictionary<string, string>
{
{ "example", "mail@example.com" },
{ "aFriend", "friendEmail@gmail.com" }
};

📄 许可证

此项目使用MIT许可证。

  • 0 关注
  • 0 收藏,27 浏览
  • system 提出于 2025-10-03 04:24

相似服务问题

相关AI产品