MCPSharp

MCPSharp is a .NET library for building Model Context Protocol (MCP) servers and clients, enabling seamless creation of AI-compatible tools and integration with Microsoft.Extensions.AI and Semantic Kernel. MCPSharp is a

273
23

MCPSharp

MCPSharp is a .NET library for building Model Context Protocol (MCP) servers and clients, facilitating communication between AI assistants and models. It allows creating MCP-compliant tools and functions, connecting to MCP servers from C#, and exposing .NET methods as MCP endpoints.

Key features include:

  • Integration with Microsoft.Extensions.AI, enabling tools as AIFunctions.
  • Semantic Kernel support via KernelFunctionAttribute.
  • Dynamic tool registration with custom logic.
  • Tool change notifications for clients.
  • Complex object parameter support and improved error handling.

Use cases involve:

  • Creating tools for AI assistants like Anthropic's Claude Desktop.
  • Building MCP-compliant APIs.
  • Exposing .NET code as MCP endpoints.
  • Adding AI capabilities through standardized interfaces.
  • Integrating with Microsoft.Extensions.AI and Semantic Kernel.

The library offers an attribute-based API ([McpTool], [McpResource]), built-in JSON-RPC support, automatic parameter validation, and XML documentation support. Installation is via NuGet.

Repository

AF
afrise

afrise/MCPSharp

Created

February 17, 2025

Updated

March 28, 2025

Language

C#

Category

Developer Tools