dotnet-mcp-builder

Build Model Context Protocol servers and clients in C# against the ModelContextProtocol 2.x NuGet packages.

38.5k|4.9k|Updated Jun 11, 2025
One-click install
npx skills add https://github.com/github/awesome-copilot --skill dotnet-mcp-builder
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-mcp-builder
Source: https://github.com/github/awesome-copilot/tree/main/skills/dotnet-mcp-builder
Command: npx skills add https://github.com/github/awesome-copilot --skill dotnet-mcp-builder

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

The .NET MCP SDK went through years of preview packages and a v2 release that flipped key defaults, so unguided code generation often pins stale 0.x previews, applies 1.x-era stateful HTTP defaults, or recommends capabilities the 2026-07-28 spec deprecates (roots, sampling, MCP-channel logging). This Skill steers MCP server and client work in C#/.NET toward the current stable 2.x packages and correct transport, primitive, and deployment patterns.

Core Features & Use Cases

  • Transport guidance: Covers STDIO servers (including the stdout/stderr JSON-RPC trap) and Streamable HTTP hosting in ASP.NET Core with MapMcp, stateless-by-default v2 behavior, OAuth, reverse-proxy buffering, and legacy SSE compatibility.
  • Primitive references: Detailed patterns for tools, prompts, resources, elicitation (form and URL modes), MCP Apps interactive UI, completions, progress notifications, filters, and the deprecated sampling/roots paths with migration guidance.
  • Client and testing support: Shows how to build a .NET MCP client over STDIO or HTTP, wire MCP tools into Microsoft.Extensions.AI pipelines, and test servers with MCP Inspector or in-memory transports.
  • Use Case: When asked to "expose this .NET service as an MCP tool" or "build an MCP server in C#", the Skill loads the matching reference (packages, transport, tool primitive) and produces code that compiles against ModelContextProtocol 2.x with correct registration and descriptions.

Quick Start

Ask the assistant to create a new .NET MCP server with a tool, for example: "Build a C# MCP server with STDIO transport that exposes a weather lookup tool using the current ModelContextProtocol package."

Frequently Asked Questions about dotnet-mcp-builder

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build an MCP server in C# with the .NET SDK?

Create a console or web project, add the ModelContextProtocol package (or ModelContextProtocol.AspNetCore for HTTP), then call AddMcpServer() with WithStdioServerTransport() or WithHttpTransport() and WithToolsFromAssembly(). Tools are plain methods on classes marked [McpServerToolType] with [McpServerTool] on each method.

Which NuGet package should I use for a .NET MCP server?

Use ModelContextProtocol for STDIO servers, ModelContextProtocol.AspNetCore for HTTP servers hosted in ASP.NET Core, and ModelContextProtocol.Core for pure clients or low-level hosts. Target the stable 2.x line; the 0.x previews have breaking differences and 1.x predates the 2026-07-28 spec.

Why does my STDIO MCP server fail to connect or produce protocol errors?

The most common cause is something writing to stdout, which corrupts the JSON-RPC channel. Set LogToStandardErrorThreshold = LogLevel.Trace so logging goes to stderr, and never call Console.WriteLine from a tool.

Does the .NET MCP SDK still support SSE transport?

SSE-only transport is deprecated; new servers should use Streamable HTTP via WithHttpTransport and MapMcp. You can enable legacy SSE with EnableLegacySse = true only for old clients that require it, and it forces stateful mode.

Why do I get MCP9005 warnings after upgrading to ModelContextProtocol 2.x?

MCP9005 marks APIs deprecated by the 2026-07-28 spec: roots, sampling, and MCP-channel logging. They still work with down-level clients, but new designs should use the multi-round-trip InputRequiredException pattern and ILogger logging instead.

Can an MCP tool ask the user for input mid-execution on HTTP?

On the current 2026-07-28 protocol, HTTP has no sessions, so ElicitAsync cannot run on Streamable HTTP. Throw InputRequiredException from the tool to trigger a multi-round-trip elicitation, which works in both stateless and stateful modes; ElicitAsync remains available on STDIO and down-level stateful HTTP.