此注册表固定版本所收录的最新上游作者日期。

csharp-mcp-server-generator

已冻结 v1.0.0 收录的最新变更: 没有已验证的上游历史。

Generate a complete MCP server project in C# with tools, prompts, and proper configuration

摘要

用途
创建以 C# 撰写的 Model Context Protocol 服务器项目,使用主机建置器管理相依性注入与 stdio 传输,并提供可自动探索的工具及实务操作说明。
使用时机
当你需要创建 .NET 8 以上的主控台服务器,以提供自订 MCP 工具,并包含设置、验证与运行和测试指引时使用。
输出结果
产出设置为 MCP stdio 传输与 stderr 记录的主控台项目,内含至少一个具属性标记且含验证和错误处理的工具,以及运行与测试说明。
⚠ 已冻结/无上游

此技能没有已验证的上游来源。它冻结于 v1.0.0,不会再收到更新。

npx skills add "lettucebo/Skills#v2.2.0@csharp-mcp-server-generator" --full-depth

⚠ v2.2.0 发布后即可使用

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.

历史

v1.0.0 bootstrap
v1.0.0 license-refresh