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- .NET 8.0 or later installed
- Basic familiarity with C# and console applications
- Understanding of Model Context Protocol (MCP) concepts
How to use csharp-mcp-server-generator
- 1.Run the skill to generate a new C# MCP server project with scaffolded structure
- 2.Review the generated project layout and NuGet package configuration
- 3.Implement custom tools by creating classes with [McpServerToolType] and methods with [McpServerTool] attributes
- 4.Add [Description] attributes to tools and parameters for clarity
- 5.Configure logging and error handling as needed for your use case
- 6.Build the project and run the console application to start the MCP server
- 7.Test with an MCP client by sending tool requests via stdio transport
Use cases
- 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
- 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
.NET 8.0 or later is required for this skill.
Tools are automatically discovered from the assembly using WithToolsFromAssembly(), so any class marked with [McpServerToolType] and methods with [McpServerTool] are registered.
Logging to stderr prevents interference with stdio transport, which is used for MCP protocol communication.
Yes, create new classes with [McpServerToolType] attribute and methods with [McpServerTool] attribute; they will be auto-discovered on next run.
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
- Project Structure: Create a new C# console application with proper directory structure
- NuGet Packages: Include ModelContextProtocol (prerelease) and Microsoft.Extensions.Hosting
- Logging Configuration: Configure all logs to stderr to avoid interfering with stdio transport
- Server Setup: Use the Host builder pattern with proper DI configuration
- Tools: Create at least one useful tool with proper attributes and descriptions
- 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.CreateApplicationBuilderfor 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.
Related skills
More from github/awesome-copilot and the wider catalog.

csharp-mstest
Reference guide for writing modern, idiomatic MSTest 3.x/4.x unit tests in C#.

csharp-nunit
Reference best practices for writing clean, data-driven NUnit tests in C#.

csharp-tunit
Reference guide for writing modern, fast C# unit tests with TUnit, including data-driven testing and xUnit migration tips.

csharp-xunit
XUnit best practices for C# unit testing, including data-driven tests and test organization.

daily-prep
Prepare for tomorrow's meetings and tasks with calendar analysis, conflict detection, and productivity recommendations.

datanalysis-credit-risk
Credit risk data cleaning and variable screening pipeline for pre-loan modeling