# MCPSharp

> MCP Server

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

## Overview

- **Category:** Developer Tools
- **Language:** C#
- **Stars:** 374
- **Forks:** 23
- **Owner:** afrise
- **GitHub:** https://github.com/afrise/MCPSharp
- **Created:** 2025-02-17T17:39:43+00:00
- **Updated:** 2025-03-28T08:52:24+00:00
- **Source:** https://model-context-protocol.com/servers/dotnet-library-model-context-protocol-servers

## Setup

## Setup

1.  **Prerequisites**: Any version of .NET that supports [standard 2.0](https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0)
2.  **Installation**: Run `dotnet add package MCPSharp` in your project.

## Tools

## Available Tools

1.  Create MCP-compliant tools and functions that AI models can discover and use.
2.  Connect directly to existing MCP servers from C# code with an easy to use client.
3.  Expose your .NET methods as MCP endpoints with simple attributes.
4.  Handle MCP protocol details and JSON-RPC communication seamlessly.
5.  Easy-to-use attribute-based API (`[McpTool]`, `[McpResource]`)
6.  Built-in JSON-RPC support with automatic request/response handling.
7.  Automatic parameter validation and type conversion.
8.  Rich documentation support through XML comments.
9.  Near zero configuration required for basic usage.
10. Microsoft.Extensions.AI Integration: Allows tools to be exposed as AIFunctions.
11. Semantic Kernel Support: Add tools using Semantic Kernel's KernelFunctionAttribute.
12. Dynamic Tool Registration: Register tools on-the-fly with custom implementation logic.
13. Tool Change Notifications: Server now notifies clients when tools are added, updated, or removed.
14. Complex Object Parameter Support: Better handling of complex objects in tool parameters.
15. Better Error Handling: Improved error handling with detailed stack traces.
