# MCP Csharp

> Orchestrator for building MCP servers with the C# SDK. Guides you through the complete lifecycle - creating, debugging, testing, and publishing MCP servers using .NET. Use this as your main entry point for C# MCP development.

- Skill: `leslierichardson95/mcp-csharp` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add leslierichardson95/mcp-csharp`
- Raw SKILL.md: https://api.skillmd.com/api/skills/leslierichardson95/mcp-csharp/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- License: Complete terms in LICENSE.txt
- Author: leslierichardson95 (https://skillmd.com/u/leslierichardson95)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/leslierichardson95/mcp-csharp

---


# MCP C# Server Development

## Overview

Build Model Context Protocol (MCP) servers using C# and .NET. This skill orchestrates your complete development workflow, from project creation to cloud deployment.

---

# 🎯 Quick Start

## What do you need help with?

| If you want to... | Phase | Action |
|-------------------|-------|--------|
| **Create a new MCP server** | Create | Load [mcp-csharp-create](./mcp-csharp-create/SKILL.md) |
| **Run or debug your server** | Debug | Load [mcp-csharp-debug](./mcp-csharp-debug/SKILL.md) |
| **Write tests or evaluations** | Test | Load [mcp-csharp-test](./mcp-csharp-test/SKILL.md) |
| **Publish to NuGet, Docker, or Azure** | Publish | Load [mcp-csharp-publish](./mcp-csharp-publish/SKILL.md) |

---

# 🚀 Complete Workflow

## Phase 1: Create Your Server

**When**: Starting a new MCP server project

```bash
# Install the template (.NET 10+ required)
dotnet new install Microsoft.McpServer.ProjectTemplates

# Create stdio server (local/CLI)
dotnet new mcpserver -n MyMcpServer

# Or create HTTP server (remote/web)
dotnet new mcpserver -n MyMcpServer --transport http
```

**Then**: Add your tools using `[McpServerToolType]` and `[McpServerTool]` attributes.

**📖 Full guide**: Load [mcp-csharp-create](./mcp-csharp-create/SKILL.md)

---

## Phase 2: Debug Your Server

**When**: Your server is created and you need to run/test it locally

**Key steps**:
1. Configure VS Code (`.vscode/mcp.json`) or Visual Studio
2. Run with `dotnet run`
3. Test with MCP Inspector or GitHub Copilot Agent Mode
4. Set breakpoints and debug

**📖 Full guide**: Load [mcp-csharp-debug](./mcp-csharp-debug/SKILL.md)

---

## Phase 3: Test Your Server

**When**: Your server works and needs automated tests

**Key steps**:
1. Create xUnit test project
2. Write unit tests for individual tools
3. Write integration tests with MCP client
4. Create evaluations to measure LLM effectiveness

**📖 Full guide**: Load [mcp-csharp-test](./mcp-csharp-test/SKILL.md)

---

## Phase 4: Publish Your Server

**When**: Ready to distribute your server

| Transport | Publish To | Users Run With |
|-----------|------------|----------------|
| **stdio** | NuGet.org | `dnx YourPackage@1.0.0` |
| **HTTP** | Docker/Azure | Container URL |

**📖 Full guide**: Load [mcp-csharp-publish](./mcp-csharp-publish/SKILL.md)

---

# 📋 Phase Detection

## I'll help you figure out what phase you're in:

### You're in **Create** phase if:
- You don't have a project yet
- You need to add new tools, prompts, or resources
- You're setting up transport (stdio or HTTP)

### You're in **Debug** phase if:
- Your server won't start
- Tools aren't appearing in Copilot
- You need to step through code
- You're getting protocol errors

### You're in **Test** phase if:
- Server works manually but needs automated tests
- You want to verify tool behavior
- You need to create LLM evaluations

### You're in **Publish** phase if:
- Server is tested and ready for users
- You need to package for NuGet
- You need to containerize with Docker
- You want to deploy to Azure

---

# 🔧 Common Scenarios

## Scenario: "I want to build an MCP server for [Service X]"

1. **Load**: [mcp-csharp-create](./mcp-csharp-create/SKILL.md)
2. Create project with `dotnet new mcpserver -n ServiceXMcpServer`
3. Study the Service X API documentation
4. Implement tools for key API operations
5. Test with MCP Inspector

## Scenario: "My MCP server isn't working"

1. **Load**: [mcp-csharp-debug](./mcp-csharp-debug/SKILL.md)
2. Check common issues:
   - stdio servers logging to stdout (should be stderr)
   - Missing `[McpServerToolType]` attribute
   - Tool not registered with `.WithToolsFromAssembly()`
3. Use MCP Inspector to test protocol
4. Set breakpoints and debug

## Scenario: "I need to deploy my server to production"

1. **Determine transport**:
   - stdio → NuGet publishing
   - HTTP → Docker + Azure
2. **Load**: [mcp-csharp-publish](./mcp-csharp-publish/SKILL.md)
3. Follow the publishing guide for your transport

---

# 📚 Reference

## SDK Packages

| Package | Use Case |
|---------|----------|
| `ModelContextProtocol` | stdio servers with hosting/DI |
| `ModelContextProtocol.AspNetCore` | HTTP servers with ASP.NET Core |
| `ModelContextProtocol.Core` | Low-level client/server APIs |

## Key Patterns

### Tool Registration
```csharp
[McpServerToolType]
public static class MyTools
{
    [McpServerTool, Description("Does something useful")]
    public static string DoSomething(
        [Description("Input parameter")] string input) =>
        $"Result: {input}";
}
```

### Program.cs (stdio)
```csharp
var builder = Host.CreateApplicationBuilder(args);
builder.Logging.AddConsole(o => o.LogToStandardErrorThreshold = LogLevel.Trace);
builder.Services.AddMcpServer()
    .WithStdioServerTransport()
    .WithToolsFromAssembly();
await builder.Build().RunAsync();
```

### Program.cs (HTTP)
```csharp
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMcpServer()
    .WithHttpTransport()
    .WithToolsFromAssembly();
var app = builder.Build();
app.MapMcp();
app.Run();
```

---

# 🔗 Sub-Skills

Load these for detailed guidance on each phase:

| Skill | Description |
|-------|-------------|
| [mcp-csharp-create](./mcp-csharp-create/SKILL.md) | Project scaffolding, tool/prompt/resource implementation |
| [mcp-csharp-debug](./mcp-csharp-debug/SKILL.md) | Running, debugging, MCP Inspector, Copilot testing |
| [mcp-csharp-test](./mcp-csharp-test/SKILL.md) | Unit tests, integration tests, evaluations |
| [mcp-csharp-publish](./mcp-csharp-publish/SKILL.md) | NuGet, Docker, Azure deployment |

---

# 📖 External Resources

- **C# SDK**: `https://raw.githubusercontent.com/modelcontextprotocol/csharp-sdk/main/README.md`
- **Microsoft Template Guide**: `https://learn.microsoft.com/en-us/dotnet/ai/quickstarts/build-mcp-server`
- **MCP Specification**: `https://modelcontextprotocol.io/specification/`

