{"id":28639395,"url":"https://github.com/StefH/McpDotNet.Extensions.SemanticKernel","last_synced_at":"2025-06-12T19:40:25.216Z","repository":{"id":284105787,"uuid":"950401000","full_name":"StefH/McpDotNet.Extensions.SemanticKernel","owner":"StefH","description":"Microsoft SemanticKernel integration for the Model Context Protocol (MCP). Enables seamless use of MCP tools as AI functions.","archived":false,"fork":false,"pushed_at":"2025-06-04T10:21:24.000Z","size":97,"stargazers_count":22,"open_issues_count":2,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-04T17:51:12.853Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StefH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-18T05:23:05.000Z","updated_at":"2025-06-04T10:20:30.000Z","dependencies_parsed_at":"2025-03-24T07:42:43.776Z","dependency_job_id":"df1bb433-71b8-4ff6-acdc-792e6e1ef7dd","html_url":"https://github.com/StefH/McpDotNet.Extensions.SemanticKernel","commit_stats":null,"previous_names":["stefh/mcpdotnet.extensions.semantickernel"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/StefH/McpDotNet.Extensions.SemanticKernel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FMcpDotNet.Extensions.SemanticKernel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FMcpDotNet.Extensions.SemanticKernel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FMcpDotNet.Extensions.SemanticKernel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FMcpDotNet.Extensions.SemanticKernel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StefH","download_url":"https://codeload.github.com/StefH/McpDotNet.Extensions.SemanticKernel/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FMcpDotNet.Extensions.SemanticKernel/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259520285,"owners_count":22870415,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-12T19:40:24.563Z","updated_at":"2025-06-12T19:40:25.192Z","avatar_url":"https://github.com/StefH.png","language":"C#","funding_links":[],"categories":["📚 Projects (1974 total)","SDKs"],"sub_categories":["MCP Servers","dotnet sdk"],"readme":"﻿# ModelContextProtocol-SemanticKernel\n[Microsoft SemanticKernel](https://learn.microsoft.com/en-us/semantic-kernel/overview/) integration for the [Model Context Protocol](https://modelcontextprotocol.io) using the [csharp-sdk](https://github.com/modelcontextprotocol/csharp-sdk).\nEnables seamless use of MCP tools as AI functions.\n\n\u003e [!NOTE]\n\u003e This project is in preview; breaking changes can be introduced without prior notice.\n\n## NuGet\n### ModelContextProtocol-SemanticKernel\n[![NuGet Badge](https://img.shields.io/nuget/v/ModelContextProtocol-SemanticKernel)](https://www.nuget.org/packages/ModelContextProtocol-SemanticKernel)\n\n#### McpDotNet (obsolete)\n[![NuGet Badge](https://img.shields.io/nuget/v/McpDotNet.Extensions.SemanticKernel)](https://www.nuget.org/packages/McpDotNet.Extensions.SemanticKernel)\n\n## Overview\n``` mermaid\n---\ntitle: \"Overview\"\n---\n\ngraph LR;\n    SK[Semantic Kernel\u003cbr\u003e'OpenAI'] \n    MCPClient[MCPClient\u003cbr\u003e'Function Calling']\n    MCPServer[Local MCP Server\u003cbr\u003e'server-github'] \n    GitHub[GitHub]\n\n    SK \u003c-- C# --\u003e MCPClient\n    MCPClient \u003c-- MCP Protocol --\u003e MCPServer\n    MCPServer \u003c-- Web API --\u003e GitHub\n```\n\n## ⚙️ Usage\nUse an extension method to register a specific MCP function/tool\n\n### Register single function or tool\n``` csharp\n// 💡Stdio\nawait kernel.Plugins.AddMcpFunctionsFromStdioServerAsync(\"GitHub\", \"npx\", [\"-y\", \"@modelcontextprotocol/server-github\"]);\n\n// 💡SSE\nawait kernel.Plugins.AddMcpFunctionsFromSseServerAsync(\"GitHub\", new Uri(\"http://localhost:12345\"));\n```\n\n### Register MCP Server(s) from Claude Desktop configuration\nIt's also possible to register all Stdio MCP Servers which are registered in Claude Desktop:\n``` csharp\n// 💡Stdio MCP Tools defined in claude_desktop_config.json\nawait kernel.Plugins.AddToolsFromClaudeDesktopConfigAsync(cancellationToken: cts.Token);\n```\n\n\u003cbr\u003e\n\n## 💻 Full Stdio Example\n### Code\n``` csharp\nvar builder = Kernel.CreateBuilder();\nbuilder.Services.AddLogging(c =\u003e c.AddDebug().SetMinimumLevel(LogLevel.Trace));\n\nbuilder.Services.AddOpenAIChatCompletion(\n    serviceId: \"openai\",\n    modelId: \"gpt-4o-mini\",\n    apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")!);\n\nvar kernel = builder.Build();\n\n// 💡 Add this line to enable MCP functions from a Stdio server named \"Everything\"\nawait kernel.Plugins.AddMcpFunctionsFromStdioServerAsync(\"Everything\", \"npx\", [\"-y\", \"@modelcontextprotocol/server-github\"]);\n\nvar executionSettings = new OpenAIPromptExecutionSettings\n{\n    Temperature = 0,\n    FunctionChoiceBehavior = FunctionChoiceBehavior.Auto()\n};\n\nvar prompt = \"Please call the echo tool with the string 'Hello Stef!' and give me the response as-is.\";\nvar result = await kernel.InvokePromptAsync(prompt, new(executionSettings)).ConfigureAwait(false);\nConsole.WriteLine($\"\\n\\n{prompt}\\n{result}\");\n```\n\n### Result\n```\nPlease call the echo tool with the string 'Hello Stef!' and give me the response as-is.\nEcho: Hello Stef!\n```\n\n\u003cbr\u003e\n\n## 💻 Full SSE (Server-Sent Events) Example\n### Code\n``` csharp\nvar builder = Kernel.CreateBuilder();\nbuilder.Services.AddLogging(c =\u003e c.AddDebug().SetMinimumLevel(LogLevel.Trace));\n\nbuilder.Services.AddOpenAIChatCompletion(\n    serviceId: \"openai\",\n    modelId: \"gpt-4o-mini\",\n    apiKey: Environment.GetEnvironmentVariable(\"OPENAI_API_KEY\")!);\n\nvar kernel = builder.Build();\n\n// 💡 Add this line to enable MCP functions from a Sse server named \"Github\"\n// - Note that a server must be running at the specified URL\nawait kernel.Plugins.AddMcpFunctionsFromSseServerAsync(\"GitHub\", \"http://localhost:12345\");\n\nvar executionSettings = new OpenAIPromptExecutionSettings\n{\n    Temperature = 0,\n    FunctionChoiceBehavior = FunctionChoiceBehavior.Auto()\n};\n\nvar prompt = \"Summarize the last 3 commits to the StefH/FluentBuilder repository.\";\nvar result = await kernel.InvokePromptAsync(prompt, new(executionSettings)).ConfigureAwait(false);\nConsole.WriteLine($\"\\n\\n{prompt}\\n{result}\");\n```\n\n### Result\n```\nSummarize the last 3 commits to the StefH/FluentBuilder repository.\nHere are the summaries of the last three commits to the `StefH/FluentBuilder` repository:\n\n1. **Commit [2293880](https://github.com/StefH/FluentBuilder/commit/229388090f50a39f489e30cb535f67f3705cf61f)** (January 30, 2025)\n   - **Author:** Stef Heyenrath\n   - **Message:** Update README.md\n   - **Details:** This commit updates the README.md file. The commit was verified and is valid.\n\n2. **Commit [ae27064](https://github.com/StefH/FluentBuilder/commit/ae2706424c3b75613bf5625091aa2649fb33ecde)** (November 6, 2024)\n   - **Author:** Stef Heyenrath\n   - **Message:** Update README.md\n   - **Details:** This commit also updates the README.md file. The commit was verified and is valid.\n\n3. **Commit [53096a8](https://github.com/StefH/FluentBuilder/commit/53096a8b54a1029532425bc727fdd831e9ed0092)** (October 20, 2024)\n   - **Author:** Stef Heyenrath\n   - **Message:** Update README.md\n   - **Details:** This commit updates the README.md file as well. The commit was verified and is valid.\n\nAll three commits involve updates to the README.md file, reflecting ongoing improvements or changes to the documentation.\n```\n\n\n## 📖 References\n- https://modelcontextprotocol.io\n- https://github.com/PederHP/mcpdotnet\n- https://github.com/modelcontextprotocol/csharp-sdk\n- https://devblogs.microsoft.com/semantic-kernel/integrating-model-context-protocol-tools-with-semantic-kernel-a-step-by-step-guide/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStefH%2FMcpDotNet.Extensions.SemanticKernel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FStefH%2FMcpDotNet.Extensions.SemanticKernel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStefH%2FMcpDotNet.Extensions.SemanticKernel/lists"}