csharp-mcp-server

Scaffold C# MCP servers for .NET 10 with STDIO and Streamable HTTP transports.

Updated Mar 1, 2026
One-click install
npx skills add https://github.com/CloudyWing/ai-dotfiles --skill csharp-mcp-server-cloudywing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: csharp-mcp-server
Source: https://github.com/CloudyWing/ai-dotfiles/tree/main/skills/csharp-mcp-server
Command: npx skills add https://github.com/CloudyWing/ai-dotfiles --skill csharp-mcp-server-cloudywing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide captures best practices and concrete guidance for creating reliable C# MCP (Model Context Protocol) servers so developers can avoid integration pitfalls, incorrect transports, and logging issues that break tool communication.

Core Features & Use Cases

  • Deployment Modes: Explains when to use STDIO console mode for local integrations and when to use Streamable HTTP mode for containerized or networked deployments.
  • Project Structure & Dependencies: Recommends project templates and the required ModelContextProtocol SDK libraries for both STDIO and ASP.NET Core transports.
  • Logging and Stability: Describes how to route logging to stderr in STDIO mode to avoid corrupting JSON-RPC streams and how to implement try-catch guards to prevent tool failures from crashing the server.
  • Tool Exposure Pattern: Advises on XML comments, McpServerTool attributes, and Description annotations to make tool methods discoverable and reliable for LLM-driven tool invocation.
  • Use Case: Create a containerized .NET 10 web service that mounts an /mcp endpoint to expose typed tools for model-driven operations while preserving robust error handling.

Quick Start

Scaffold a .NET 10 project, add the ModelContextProtocol SDK, implement tool classes with McpServerTool attributes and Description annotations, and run in STDIO or HTTP mode with STDIO logging redirected to stderr.

Frequently Asked Questions about csharp-mcp-server

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

FAQPage Schema
How do I build a C# MCP server using the ModelContextProtocol SDK?

To build a C# MCP server, scaffold a .NET 10 project, add the ModelContextProtocol SDK, and implement tool classes using McpServerTool attributes and Description annotations for discoverable, typed tool exposure.

When should I use STDIO versus Streamable HTTP for an MCP server?

Use STDIO transport for local console integrations and Streamable HTTP mode for containerized or networked deployments. STDIO is ideal for direct local tool execution, while HTTP supports scalable web service endpoints.

Why does my STDIO MCP server crash or corrupt JSON-RPC streams with logs?

STDIO MCP server streams corrupt when standard output logging interferes with JSON-RPC communication. Route all logging to stderr instead to preserve the integrity of the tool communication channel.

How do I expose typed tools for model-driven operations in a .NET MCP server?

Expose typed tools by decorating methods with McpServerTool attributes and providing Description annotations. XML comments further ensure tools are discoverable and reliable for LLM-driven invocation.

Do I need .NET 10 to deploy a containerized MCP server with an /mcp endpoint?

Yes, this scaffolding targets .NET 10+ projects to create containerized web services that mount an /mcp endpoint, ensuring proper transport selection and robust defensive error handling.

How do I prevent tool failures from crashing my C# MCP server?

Prevent tool failures from crashing your C# MCP server by implementing try-catch guards around tool execution. This defensive error handling pattern ensures server stability during unexpected tool errors.