MCPSharp  by afrise

.NET library for Model Context Protocol (MCP) server/client creation

Created 7 months ago
326 stars

Top 83.5% on SourcePulse

GitHubView on GitHub
Project Summary

MCPSharp is a .NET library for building Model Context Protocol (MCP) servers and clients, enabling seamless integration between AI models and .NET applications. It simplifies exposing .NET methods as AI-discoverable tools and connecting to existing MCP services, targeting developers who want to add AI capabilities to their applications or create MCP-compliant tools.

How It Works

MCPSharp leverages a .NET attribute-based system ([McpTool], [McpParameter]) to define and expose methods as MCP endpoints. It handles the underlying JSON-RPC communication and parameter validation automatically. The library also supports dynamic tool registration and integrates with Microsoft.Extensions.AI and Semantic Kernel, allowing for flexible tool management and interoperability.

Quick Start & Requirements

Highlighted Details

  • Integrates with Microsoft.Extensions.AI for AIFunctions and Semantic Kernel for KernelFunctionAttribute.
  • Supports dynamic tool registration with custom implementation logic.
  • Provides tool change notifications to clients when tools are added or updated.
  • Handles complex object parameters and offers improved error handling with detailed stack traces.
  • Automatically extracts tool descriptions from XML comments.

Maintenance & Community

  • The project welcomes contributions via Pull Requests.
  • No specific community channels (Discord/Slack) or roadmap links are provided in the README.

Licensing & Compatibility

  • Licensed under the MIT License.
  • Permissive license suitable for commercial use and integration with closed-source applications.

Limitations & Caveats

The README indicates that [McpFunction] is deprecated in favor of [McpTool], and MCPServer.RegisterTool<T>() is deprecated in favor of MCPServer.Register<T>(). While the old methods still work, migration is recommended for consistency.

Health Check
Last Commit

3 days ago

Responsiveness

1 day

Pull Requests (30d)
16
Issues (30d)
0
Star History
8 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.