MCPSharp
MCPSharp is a .NET library that helps you build Model Context Protocol (MCP) servers and clients - the standardized API protocol used by AI assistants and models.
What is MCPSharp?
MCPSharp is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to mcpsharp is a .net library that helps you build model context protocol (mcp) servers and clients - the standardized api protocol used by ai assistants and models.
MCPSharp is a .NET library that helps you build Model Context Protocol (MCP) servers and clients - the standardized API protocol used by AI assistants and models.
This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- MCPSharp is a .NET library that helps you build Model Contex
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx mcpsharpConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use MCPSharp
MCPSharp is a .NET NuGet library that makes it straightforward to build Model Context Protocol servers and clients in C#. Using simple attributes like [McpTool] and [McpResource], .NET developers can expose existing methods as MCP endpoints that AI assistants such as Claude Desktop can discover and invoke — without hand-coding JSON-RPC. MCPSharp also integrates with Microsoft.Extensions.AI and Semantic Kernel, letting you reuse annotated functions across multiple AI frameworks without vendor lock-in.
Prerequisites
- .NET Standard 2.0 compatible runtime (.NET 6, .NET 7, .NET 8, or .NET Framework 4.6.1+)
- An MCP-compatible AI client to test against, such as Claude Desktop
- Basic familiarity with C# and .NET project structure
- NuGet package manager (included with dotnet CLI)
Add the MCPSharp NuGet package
Add MCPSharp to your .NET project using the dotnet CLI. This is the only dependency you need for basic MCP server functionality.
dotnet add package MCPSharpAnnotate your methods with [McpTool]
Mark any public static (or instance) method with the [McpTool] attribute to expose it as an MCP tool. Use [McpParameter] to add descriptions and mark required parameters.
using MCPSharp;
public class WeatherTools
{
[McpTool("get_weather", "Returns current weather for a city")]
public static string GetWeather(
[McpParameter(true, Description = "City name")] string city)
{
return $"Weather for {city}: 22°C, partly cloudy";
}
}Start the MCP server
Call MCPServer.StartAsync with a server name and version. It automatically discovers all [McpTool]-annotated methods in the assembly and serves them over stdio.
using MCPSharp;
await MCPServer.StartAsync("WeatherServer", "1.0.0");Register tools from external assemblies
If your tools are in a separate referenced library, register them explicitly before starting the server.
MCPServer.Register<WeatherTools>();
await MCPServer.StartAsync("MyServer", "1.0.0");Configure Claude Desktop to use your server
Publish your project to an executable, then add it to claude_desktop_config.json so Claude can launch it as an MCP server.
dotnet publish -c Release -o ./publish
# Then add to claude_desktop_config.json:
{
"mcpServers": {
"myWeatherServer": {
"command": "dotnet",
"args": ["/path/to/publish/MyMcpServer.dll"]
}
}
}MCPSharp Examples
Client configuration
Example claude_desktop_config.json entry for a published MCPSharp server. Replace the path with your actual publish output directory.
{
"mcpServers": {
"myDotnetServer": {
"command": "dotnet",
"args": ["/Users/yourname/myapp/publish/MyMcpServer.dll"]
}
}
}Prompts to try
Once your MCPSharp server is running and connected, Claude can call any [McpTool]-annotated method. These prompts assume a server with weather, calculator, and database tools.
- "What is the weather in London right now?"
- "Add 137 and 258 using the calculator tool"
- "List all records from the users table"
- "What tools does this server expose?"
- "Call the get_weather tool with city set to Tokyo"Troubleshooting MCPSharp
Claude Desktop shows no tools from the MCPSharp server
Ensure the server writes to stdout and reads from stdin — MCPSharp uses stdio transport. Avoid any Console.WriteLine calls in your tool methods that output to stdout outside the MCP protocol, as this corrupts the JSON-RPC stream.
Tools in a referenced library are not discovered automatically
Call MCPServer.Register<YourClass>() for each class in external assemblies before calling StartAsync. Automatic discovery only scans the entry assembly.
Dynamic tool registration does not notify the client
Tool change notifications are sent only if the connected client declares support for them. Verify your MCP client version supports the tools/list_changed notification; older clients may need a reconnect to see newly registered tools.
Frequently Asked Questions about MCPSharp
What is MCPSharp?
MCPSharp is a Model Context Protocol (MCP) server that mcpsharp is a .net library that helps you build model context protocol (mcp) servers and clients - the standardized api protocol used by ai assistants and models. It connects AI assistants to external tools and data sources through a standardized interface.
How do I install MCPSharp?
Follow the installation instructions on the MCPSharp GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with MCPSharp?
MCPSharp works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is MCPSharp free to use?
Yes, MCPSharp is open source and available under the MIT license. You can use it freely in both personal and commercial projects.
MCPSharp Alternatives — Similar Developer Tools Servers
Looking for alternatives to MCPSharp? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
★ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
★ 155.8kJava 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发
Gemini CLI
★ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
★ 87.3k⭐ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
★ 86.0kModel Context Protocol Servers
CC Switch
★ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
Browse More Developer Tools MCP Servers
Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up MCPSharp in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use MCPSharp?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.