C# SDK

v1.0.0Developer Toolsstable

The official C# SDK for Model Context Protocol servers and clients. Maintained in collaboration with Microsoft.

csharpdotnetmcpmcp-clientmcp-server
Share:
4,283
Stars
0
Downloads
0
Weekly
0/5

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

Build MCP servers and clients with official C# SDK.
Integrate .NET applications with Model Context Protocol (Microsoft-maintained).
LicenseNOASSERTION
Languagec#
Versionv1.0.0
UpdatedMay 21, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx csharp-sdk

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

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.Core
2

Create 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();
3

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

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-contained
5

Configure 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.

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": { "csharp-sdk": { "command": "npx", "args": ["-y", "csharp-sdk"] } } }

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

Read the full setup guide →

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.

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