PluginBench
Skill
Official
Review
Audit score 70

csharp-mcp-server-generator

github/awesome-copilot

Generate a complete, production-ready MCP server in C# with tools, prompts, and proper configuration.

What is csharp-mcp-server-generator?

This skill generates a fully functional Model Context Protocol (MCP) server in C# using .NET 8.0+. It sets up a console application with proper dependency injection, logging, tool discovery, and error handling—ready to integrate with MCP clients via stdio transport.

  • Creates a new C# console application with proper MCP server structure
  • Configures NuGet dependencies (ModelContextProtocol, Microsoft.Extensions.Hosting) with prerelease support
  • Sets up Host builder pattern with dependency injection and lifecycle management
  • Implements automatic tool discovery using WithToolsFromAssembly()
  • Generates example tools with [McpServerToolType] and [McpServerTool] attributes
  • Configures logging to stderr to preserve stdio transport for MCP protocol

How to install csharp-mcp-server-generator

npx skills add https://github.com/github/awesome-copilot --skill csharp-mcp-server-generator
Prerequisites
  • .NET 8.0 or later installed
  • Basic familiarity with C# and console applications
  • Understanding of Model Context Protocol (MCP) concepts
Claude Code
Cursor
Windsurf
Cline

How to use csharp-mcp-server-generator

  1. 1.Run the skill to generate a new C# MCP server project with scaffolded structure
  2. 2.Review the generated project layout and NuGet package configuration
  3. 3.Implement custom tools by creating classes with [McpServerToolType] and methods with [McpServerTool] attributes
  4. 4.Add [Description] attributes to tools and parameters for clarity
  5. 5.Configure logging and error handling as needed for your use case
  6. 6.Build the project and run the console application to start the MCP server
  7. 7.Test with an MCP client by sending tool requests via stdio transport

Use cases

Good for
  • Building a custom MCP server to expose internal tools and APIs to Claude or other MCP clients
  • Creating file operation tools (read, write, search) accessible via MCP protocol
  • Integrating external API calls or database operations as MCP-compatible tools
  • Setting up a data processing service that transforms or validates information on demand
  • Exposing system operations or command execution through a standardized MCP interface
Who it's for
  • C# developers building MCP-compatible services
  • Teams integrating Claude or other AI agents with .NET backends
  • Developers creating tool servers for AI agent ecosystems
  • Backend engineers exposing internal APIs through standardized protocols

csharp-mcp-server-generator FAQ

What .NET version is required?

.NET 8.0 or later is required for this skill.

How are tools discovered and registered?

Tools are automatically discovered from the assembly using WithToolsFromAssembly(), so any class marked with [McpServerToolType] and methods with [McpServerTool] are registered.

Why is logging configured to stderr?

Logging to stderr prevents interference with stdio transport, which is used for MCP protocol communication.

Can I add custom tools after generation?

Yes, create new classes with [McpServerToolType] attribute and methods with [McpServerTool] attribute; they will be auto-discovered on next run.

What transport mechanism does this use?

The generated server uses stdio transport for MCP protocol communication, making it compatible with standard MCP clients.

Full instructions (SKILL.md)

Source of truth, from github/awesome-copilot.


name: csharp-mcp-server-generator description: 'Generate a complete MCP server project in C# with tools, prompts, and proper configuration'

Generate C# MCP Server

Create a complete Model Context Protocol (MCP) server in C# with the following specifications:

Requirements

  1. Project Structure: Create a new C# console application with proper directory structure
  2. NuGet Packages: Include ModelContextProtocol (prerelease) and Microsoft.Extensions.Hosting
  3. Logging Configuration: Configure all logs to stderr to avoid interfering with stdio transport
  4. Server Setup: Use the Host builder pattern with proper DI configuration
  5. Tools: Create at least one useful tool with proper attributes and descriptions
  6. Error Handling: Include proper error handling and validation

Implementation Details

Basic Project Setup

  • Use .NET 8.0 or later
  • Create a console application
  • Add necessary NuGet packages with --prerelease flag
  • Configure logging to stderr

Server Configuration

  • Use Host.CreateApplicationBuilder for DI and lifecycle management
  • Configure AddMcpServer() with stdio transport
  • Use WithToolsFromAssembly() for automatic tool discovery
  • Ensure the server runs with RunAsync()

Tool Implementation

  • Use [McpServerToolType] attribute on tool classes
  • Use [McpServerTool] attribute on tool methods
  • Add [Description] attributes to tools and parameters
  • Support async operations where appropriate
  • Include proper parameter validation

Code Quality

  • Follow C# naming conventions
  • Include XML documentation comments
  • Use nullable reference types
  • Implement proper error handling with McpProtocolException
  • Use structured logging for debugging

Example Tool Types to Consider

  • File operations (read, write, search)
  • Data processing (transform, validate, analyze)
  • External API integrations (HTTP requests)
  • System operations (execute commands, check status)
  • Database operations (query, update)

Testing Guidance

  • Explain how to run the server
  • Provide example commands to test with MCP clients
  • Include troubleshooting tips

Generate a complete, production-ready MCP server with comprehensive documentation and error handling.