MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

Dotnet-Mcp-Builder

Dotnet-Mcp-Builder是一款code方向的AI技能,核心价值是Build Model Context Protocol (MCP) servers in C#/,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

Build Model Context Protocol (MCP) servers in C#/.NET against the current ModelContextProtocol 1.x NuGet packages. Especially helps with cases the model often gets wrong without guidance — stale previ

Last verified on: 2026-05-30
mkdir -p ./skills/dotnet-mcp-builder && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/dotnet-mcp-builder/SKILL.md -o ./skills/dotnet-mcp-builder/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# Building MCP servers in .NET


This skill helps you write production-quality MCP servers and basic clients in C#/.NET against the **official** [`ModelContextProtocol`](https://www.nuget.org/profiles/ModelContextProtocol) NuGet packages, maintained by Microsoft and the MCP project. It targets the **stable 1.x** line and the current spec (2025-11-25).


When this skill earns its keep


The .NET MCP SDK had years of preview packages (`0.x-preview`) before reaching `1.0`. Without help, the model tends to:

- Pin a stale preview version that won't compile against current samples.

- Miss recent spec features (elicitation URL mode, MCP Apps, structured content blocks).

- Get HTTP transport details wrong (stateful/stateless, proxy buffering, OAuth wiring).

- Forget the STDIO stdout/stderr trap.


If the task is one of those, *load the matching reference* and follow it. If it's truly trivial (e.g. "rename this tool method"), you don't need to read everything — the cardinal rules below are the minimum.


Mental model in 30 seconds


A .NET MCP server is an ordinary `Microsoft.Extensions.Hosting` (or `WebApplication`) app that wires an MCP server through DI:


csharp
builder.Services
    .AddMcpServer()
    .WithStdioServerTransport()      // OR .WithHttpTransport(...)
    .WithToolsFromAssembly()         // discover [McpServerToolType] classes
    .WithPrompts<MyPrompts>()        // optional
    .WithResources<MyResources>();   // optional

Primitives are plain C# methods on classes marked with attributes (`[McpServerToolType]` + `[McpServerTool]`, `[McpServerPromptType]` + `[McpServerPrompt]`, `[McpServerResourceType]` + `[McpServerResource]`). Parameters bind from JSON-RPC; the SDK builds the JSON Schema from the signature plus `[Description]` attributes.


Server-to-client features (sampling, elicitation, roots, log/progress notifications) are methods on the injected `IMcpServer`.


Decision tree → which references to load


Always load `references/packages.md` if you're creating a new project or unsure of the current package version.


| Task | Load |

|---|---|

| New STDIO server | `references/transport-stdio.md` |

| New HTTP (Streamable) server | `references/transport-http.md` |

| Add/modify a tool | `references/tool-primitive.md` |

| Add/modify a prompt | `references/prompt-primitive.md` |

| Add/modify a resource | `references/resource-primitive.md` |

| Ask the user a question mid-tool | `references/elicitation.md` |

| Call the client's LLM from a tool | `references/sampling.md` |

| Read the user's project roots | `references/roots.md` |

| Return an interactive UI | `references/mcp-apps.md` |

| Argument completions, log/progress notifications, filters, server instructions | `references/server-features.md` |

| Write a .NET program that **consumes** an MCP server | `references/client.md` |

| MCP Inspector, in-memory tests, mocks, CI | `references/testing.md` |


For multi-primitive tasks, load several at once. For trivial edits in an existing file, you usually don't need any.


Cardinal rules (apply always; these prevent the highest-frequency breakages)


1. **Pin the current stable package, not a preview.** Use `ModelContextProtocol` / `ModelContextProtocol.AspNetCore` / `ModelContextProtocol.Core` at the latest **1.x**. If you find yourself writing `0.3-preview` or `0.4-preview`, stop and check NuGet — preview APIs have breaking differences.

2. **STDIO servers must not write to stdout.** Stdout is the JSON-RPC channel. Configure `LogToStandardErrorThreshold = LogLevel.Trace` before anything else and never `Console.WriteLine` from a tool.

3. **HTTP defaults to stateful.** For horizontally-scaled deployments without server-initiated traffic, set `options.Stateless = true`. Server-to-client features (sampling, elicitation, roots, unsolicited notifications) require stateful HTTP **or** STDIO — `Stateless = true` will break them at runtime.

4. **SSE-only is deprecated.** Use Streamable HTTP. Only enable legacy SSE (`EnableLegacyS

🎯 Best For

  • UI designers
  • Product designers
  • Claude users
  • GitHub Copilot users
  • Software engineers

💡 Use Cases

  • Generating component mockups
  • Creating design system tokens
  • Code quality improvement
  • Best practice enforcement

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply Dotnet-Mcp-Builder to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Does this work with Figma?

Some design skills integrate with Figma plugins. Check the Works With section for supported tools.

Is Dotnet-Mcp-Builder compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for Dotnet-Mcp-Builder?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install Dotnet-Mcp-Builder?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/dotnet-mcp-builder/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Skipping usability testing

AI-generated designs should be validated with real users before development.

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills