Awesome MCPC#

afrise/MCPSharp

⭐ 376 C# added to this list on 2025-03-09 repository created 2025-02-17

MCPSharp is a .NET library designed to simplify the creation of Model Context Protocol (MCP) servers and clients. MCP is a standardized API protocol used by AI assistants and models to interact with tools and services. MCPSharp enables developers to build MCP-compliant tools and functions that AI models can discover and use, facilitating seamless integration of AI capabilities into applications. The library provides an easy-to-use attribute-based API, allowing developers to expose .NET methods as MCP endpoints with simple attributes like [McpTool] and [McpParameter]. It handles the complexities of the MCP protocol and JSON-RPC communication, including automatic request/response handling, parameter validation, and type conversion. MCPSharp supports integration with Microsoft.Extensions.AI, enabling tools to be exposed as AIFunctions, and also supports Semantic Kernel through KernelFunctionAttribute, allowing for flexible tool registration. It offers dynamic tool registration, letting developers add tools on-the-fly with custom implementation logic. The server can notify clients when tools are added, updated, or removed, enhancing real-time interaction. The library also improves error handling with detailed stack traces and supports complex object parameters. The project is suitable for developers who want to create tools that AI assistants like Anthropic's Claude Desktop can use, build MCP-compliant APIs without dealing with protocol details, expose existing .NET code as MCP endpoints, and add AI capabilities to applications through standardized interfaces. It requires any .NET version supporting standard 2.0 and can be installed via NuGet. MCPSharp includes features like XML documentation support for easy tool description updates, built-in JSON-RPC support, and near zero configuration for basic usage. It is actively maintained with a focus on compatibility and ease of use, making it a valuable tool for integrating AI models and tools using the MCP standard.

https://github.com/afrise/MCPSharp

.net-libraryaiai-assistantsai-capabilitiesai-integrationai-modelsai-toolsaifunctionsanthropic-claude-desktopattribute-based-apiautomatic-parameter-validationc#-clientcomplex-object-parametersdotnetdotnet-standarddynamic-tool-registrationerror-handlingjson-rpcmcpmcp-clientmcp-clientsmcp-endpointsmcp-servermcp-serversmcpsharpmicrosoft-extensions-aimicrosoft.extensions.aimicrosoft.extensions.ai-integrationmit-licensemodel-context-protocolnugetopen-sourcesdksemantic-kernelsemantic-kernel-supportstandardized-apistandardized-api-protocoltool-change-notificationstool-discoverytool-notificationsxml-documentation

Also in C#

modelcontextprotocol/csharp-sdk

Official C# SDK for the Model Context Protocol enabling .NET applications to implement and interact with MCP clients and servers for standardized integration with Large Language Models.