MCP ExplorerExplorer

Mpc Csharp Semantickernel

@mrazvanalexon 9 months ago
4 MIT
FreeCommunity
AI Systems
Example of usage of Microsoft Semantic Kernel with OpenAI and MCP Server

Overview

What is Mpc Csharp Semantickernel

mpc-csharp-semantickernel is an example project demonstrating the use of Microsoft Semantic Kernel in conjunction with OpenAI and the official C# SDK for the Model Context Protocol.

Use cases

Use cases include sending automated emails based on user input, creating chatbots that can communicate via email, and developing applications that leverage AI for generating content.

How to use

To use mpc-csharp-semantickernel, obtain an OpenAI ApiKey from your developer dashboard, configure the appsettings for each project, update the email addresses in Tools/EmailTool.cs, and run the project on the default URL http://localhost:5109.

Key features

Key features include integration with OpenAI’s API, email sending capabilities via SMTP, and a sample implementation of the Model Context Protocol using C#.

Where to use

mpc-csharp-semantickernel can be used in applications requiring natural language processing, automated email communication, and integration with AI models for various tasks.

Content

$${\color{red}This \space repository \space will \space not \space be \space maintained. \space It’s \space just \space a \space quick \space sample.}$$

mpc-csharp-semantickernel

An example usage of Microsoft Semantic Kernel with OpenAI and the The official C# SDK for the Model Context Protocol which can be found at https://github.com/modelcontextprotocol/csharp-sdk

Prerequisites

A SMTP Email Server (for the EmailTools)
An OpenAI ApiKey

How to run the sample

  1. Use your OpenAI Developer Dashboard to get an ApiKey.
  2. Fill out the appsettings for each separate project.
  3. The email addresses that you can send emails to are hardcoded as a dictionary inside Tools/EmailTool.cs. Update the dictionary with your email list. Feel free to make this a setting.
  4. Run the project. The default launchSettings are set to http://localhost:5109

Appsettings

WebAppMCPPoc Project

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

MCPServer Project

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "EmailSettings": {
    "SMTPServer": {
      "MailPort": "465",
      "MailServer": "<yourserver.com>",
      "Sender": "<[email protected]>",
      "SenderName": "<AIEmailSender>",
      "Password": "<EmailPassword>",
      "Username": "<EmailUsername>"
    }
  }
}

Sending Requests:

You can use a tool like postman to send requests.

Example request:
POST https://localhost:7113/chat
Body: { "text": "send and email toaFriend and tell him that you are an ai in 250 words. Tell him you're using C# to do this.."}

Replace {someone} with a name you have added in the EmailTool emails dictionary.

        private static readonly Dictionary<string, string> emails = new Dictionary<string, string>
        {
            { "example", "[email protected]" },
            { "aFriend", "[email protected]" }
        };

License

This project is licensed under the MIT License.

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers