C# SDK
The official C# SDK for Model Context Protocol servers and clients. Maintained in collaboration with Microsoft.
What is C# SDK?
C# SDK is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to official c# sdk for model context protocol servers and clients. maintained in collaboration with microsoft.
The official C# SDK for Model Context Protocol servers and clients. Maintained in collaboration with Microsoft.
This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- The official C# SDK for Model Context Protocol servers and c
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx csharp-sdkConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use C# SDK
The official C# SDK for the Model Context Protocol, developed in collaboration with Microsoft, enables .NET developers to build MCP servers and clients using idiomatic C# patterns with full dependency injection and ASP.NET Core support. The SDK ships as three NuGet packages — ModelContextProtocol.Core for minimal dependencies, ModelContextProtocol for hosting/DI, and ModelContextProtocol.AspNetCore for HTTP-based servers — covering both stdio and HTTP transports, sampling, tool and resource registration, and OAuth-based authorization. .NET teams integrating enterprise applications, microservices, or Azure workloads with AI assistants will benefit from this Microsoft-maintained, production-ready implementation.
Prerequisites
- .NET 8 SDK or later installed (dotnet.microsoft.com/download)
- A .NET project (console app, ASP.NET Core, or class library)
- NuGet package manager (included with the .NET SDK)
- An MCP-compatible client (Claude Desktop, Claude Code, Cursor, etc.) for testing
- Basic familiarity with C# dependency injection patterns
Install the NuGet package
Add the ModelContextProtocol package to your project. Use ModelContextProtocol.Core for minimal dependencies, or ModelContextProtocol for full hosting support.
# Full hosting package (recommended for most projects):
dotnet add package ModelContextProtocol
# For ASP.NET Core HTTP-based servers:
dotnet add package ModelContextProtocol.AspNetCore
# Minimal core package (no hosting, minimal deps):
dotnet add package ModelContextProtocol.CoreCreate a console-based MCP server
Build a simple MCP server using the IHostedMcpServer pattern. Register tools as methods decorated with [McpServerTool] and run the server over stdio.
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using ModelContextProtocol.Server;
var builder = Host.CreateApplicationBuilder(args);
builder.Services
.AddMcpServer()
.WithStdioServerTransport()
.WithTools<MyTools>();
await builder.Build().RunAsync();Define tools with the McpServerTool attribute
Create a class with static methods decorated with [McpServerTool]. The SDK automatically generates the JSON Schema from method signatures and registers the tools with the server.
using ModelContextProtocol.Server;
using System.ComponentModel;
[McpServerToolType]
public static class MyTools
{
[McpServerTool, Description("Add two numbers together")]
public static int Add(int a, int b) => a + b;
[McpServerTool, Description("Get the current UTC time")]
public static string GetTime() => DateTime.UtcNow.ToString("o");
}Build and publish the server binary
Compile the server to a self-contained binary or publish as a .NET executable that your MCP client can launch.
dotnet publish -c Release -r win-x64 --self-contained
# or for Linux:
dotnet publish -c Release -r linux-x64 --self-containedConfigure the server in Claude Desktop
Add the server to your Claude Desktop config file. On macOS this is ~/Library/Application Support/Claude/claude_desktop_config.json.
{
"mcpServers": {
"my-dotnet-server": {
"command": "dotnet",
"args": ["run", "--project", "/path/to/your/McpServer.csproj"],
"env": {
"MY_API_KEY": "your-api-key-here"
}
}
}
}C# SDK Examples
Client configuration (published binary)
Using a published self-contained binary instead of dotnet run — faster startup, no SDK required on the target machine:
{
"mcpServers": {
"my-dotnet-server": {
"command": "/usr/local/bin/my-mcp-server",
"args": [],
"env": {
"MY_SERVICE_URL": "https://api.example.com",
"MY_API_KEY": "your-api-key-here"
}
}
}
}Prompts to try
Example prompts to test a C# MCP server exposing math and utility tools:
- "Use the Add tool to calculate 42 plus 58"
- "What tools are available in the dotnet server?"
- "Get the current UTC time using the server's GetTime tool"
- "List all registered MCP tools and describe what each one does"Troubleshooting C# SDK
dotnet run fails with 'Unable to find package ModelContextProtocol'
Ensure you have a NuGet.config pointing to nuget.org, or run dotnet nuget add source https://api.nuget.org/v3/index.json. Also confirm you are running .NET 8 SDK or later with dotnet --version.
Claude Desktop shows the server as 'failed to start'
Test the server independently by running the command from your shell. Check that the path in 'command' is absolute and correct. If using dotnet run, verify the .csproj path is correct. Look at Claude Desktop logs in ~/Library/Logs/Claude/ on macOS for the actual error output.
Tools are not discovered by the client
Ensure your tool class is decorated with [McpServerToolType] and each tool method has [McpServerTool]. Call .WithTools<MyTools>() when registering services. Tool classes can also be registered with dependency injection if they have constructor dependencies.
Frequently Asked Questions about C# SDK
What is C# SDK?
C# SDK is a Model Context Protocol (MCP) server that official c# sdk for model context protocol servers and clients. maintained in collaboration with microsoft. It connects AI assistants to external tools and data sources through a standardized interface.
How do I install C# SDK?
Follow the installation instructions on the C# SDK GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with C# SDK?
C# SDK works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is C# SDK free to use?
Yes, C# SDK is open source and available under the NOASSERTION license. You can use it freely in both personal and commercial projects.
C# SDK Alternatives — Similar Developer Tools Servers
Looking for alternatives to C# SDK? 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 C# SDK 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 C# SDK?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.