mpc-csharp-semantickernel - MCP服务,MCP服务器,MCP教程

基本能力

产品定位

mpc-csharp-semantickernel 是一个示例项目,展示了如何使用 Microsoft Semantic Kernel 结合 OpenAI 和 Model Context Protocol 的官方 C# SDK。该项目主要用于演示如何通过 C# 和 OpenAI 实现自动化邮件发送功能。

核心功能

  1. 使用 OpenAI 的 API 生成文本内容。
  2. 通过 SMTP 邮件服务器发送生成的邮件内容。
  3. 支持自定义邮件接收者列表。

适用场景

  1. 自动化邮件发送:例如自动发送通知、提醒或个性化邮件。
  2. 开发示例:作为开发者的参考项目,了解如何集成 OpenAI 和 SMTP 服务。

工具列表

  1. EmailTool.cs:用于管理邮件接收者列表和发送邮件的工具。
  2. 能力:支持自定义邮件接收者列表,通过 SMTP 服务器发送邮件。

常见问题解答

  1. 如何获取 OpenAI API Key?
  2. 通过 OpenAI 开发者仪表板获取 API Key。
  3. 如何配置 SMTP 服务器?
  4. 在 appsettings.json 中配置 SMTP 服务器的详细信息。
  5. 如何添加邮件接收者?
  6. 在 EmailTool.cs 中更新 emails 字典,添加接收者的名称和邮箱地址。

使用教程

使用依赖

  1. SMTP 邮件服务器:用于发送邮件。
  2. OpenAI API Key:用于生成邮件内容。

安装教程

  1. 从 OpenAI 开发者仪表板获取 API Key。
  2. 在 appsettings.json 中配置 OpenAI API Key 和 SMTP 服务器信息。
  3. WebAppMCPPoc Project 配置示例:
    json
    {
    "Logging": {
    "LogLevel": {
    "Default": "Information",
    "Microsoft.AspNetCore": "Warning"
    }
    },
    "OpenAI": {
    "ApiKey": "<yourApiKey>",
    "ChatModelId" : "gpt-4o-mini"
    }
    }
  4. MCPServer Project 配置示例:
    json
    {
    "Logging": {
    "LogLevel": {
    "Default": "Information",
    "Microsoft.AspNetCore": "Warning"
    }
    },
    "AllowedHosts": "*",
    "EmailSettings": {
    "SMTPServer": {
    "MailPort": "465",
    "MailServer": "<yourserver.com>",
    "Sender": "<sender@youremail.com>",
    "SenderName": "<AIEmailSender>",
    "Password": "<EmailPassword>",
    "Username": "<EmailUsername>"
    }
    }
    }
  5. 在 EmailTool.cs 中更新 emails 字典,添加邮件接收者。
  6. 运行项目,默认启动地址为 http://localhost:5109。

调试方式

  1. 使用 Postman 发送请求示例:
  2. 请求方法:POST
  3. 请求地址:https://localhost:7113/chat
  4. 请求体:
    json
    {
    "text": "send and email to aFriend and tell him that you are an ai in 250 words. Tell him you're using C# to do this.."
    }
  5. 检查邮件是否成功发送到指定的接收者邮箱。

点击访问

给TA打赏
共{{data.count}}人
人已打赏
开发效率

Tribal - Knowledge Service - MCP服务,MCP服务器,MCP教程

2025-5-3 10:11:47

开发效率

OPC UA MCP Server - MCP服务,MCP服务器,MCP教程

2025-5-3 10:11:55

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
❯
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索