MCPSharp

v1.0.0Developer Toolsstable

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.

aiaifunctionsdotnetdotnet-standardmcp
Share:
369
Stars
0
Downloads
0
Weekly
0/5

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

Build MCP servers in .NET
Create AI-compatible protocols
Integration with LLMs
afrise

Maintainer

LicenseMIT
Languagec#
Versionv1.0.0
UpdatedMay 20, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx mcpsharp

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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)
1

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 MCPSharp
2

Annotate 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";
    }
}
3

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");
4

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");
5

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.

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.

Quick Config Preview

{ "mcpServers": { "mcpsharp": { "command": "npx", "args": ["-y", "mcpsharp"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides