Zum Inhalt springen
Skillpedia
APIs & Server (Backend)40k · #7179

dotnet-mcp-builder

Was er macht

Diese Funktion hilft dir, Programme (Server) in C#/.NET zu bauen, die mit dem Model Context Protocol (MCP) kommunizieren. Sie sorgt dafür, dass du die richtigen Versionen und die aktuellen Einstellungen des Protokolls verwendest.

Wann du ihn nutzt

  • ✓Wenn du einen neuen MCP-Server in .NET startest.
  • ✓Wenn das KI-Modell Fehler macht oder veraltete Einstellungen verwendet.
  • ✓Wenn du deinem MCP-Server neue Funktionen hinzufügst.

Link zum Skill

https://github.com/github/awesome-copilot/blob/main/skills/dotnet-mcp-builder/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/github/awesome-copilot/blob/main/skills/dotnet-mcp-builder/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Wie erstelle ich einen einfachen C#-MCP-Server, der über die Kommandozeile kommuniziert?”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Sie richtet eine .NET-Anwendung ein, die MCP-Nachrichten versteht und beantwortet. Du definierst deine Funktionen als einfache C#-Methoden, und das System übernimmt die Kommunikation.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

Building MCP servers in .NET

This skill helps you write production-quality MCP servers and basic clients in C#/.NET against the official ModelContextProtocol NuGet packages, maintained by Microsoft and the MCP project. It targets the stable 2.x line and the current spec (2026-07-28).

When this skill earns its keep

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

  • Pin a stale preview version that won't compile against current samples.
  • Apply 1.x-era defaults that v2 reversed (HTTP was stateful by default; in 2.x Stateless defaults to true).
  • Recommend capabilities the 2026-07-28 spec deprecates (roots, sampling, MCP-channel logging — now [Obsolete], warning MCP9005).
  • Miss recent spec features (multi-round-trip input_required, discovery-first negotiation, MCP Apps/Tasks extension packages, elicitation URL mode, 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:

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 (elicitation, progress notifications, and the now-deprecated sampling/roots/log 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 (deprecated in 2026-07-28) references/sampling.md
Read the user's project roots (deprecated in 2026-07-28) 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 2.x. If you find yourself writing 0.3-preview or 0.4-preview, stop and check NuGet — preview APIs have breaking differences. 1.x still works but predates the 2026-07-28 spec.
  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.

…

Häufige Fragen

Was ist MCP?

MCP ist ein Protokoll, also ein Regelwerk für die Kommunikation zwischen Programmen, vor allem zwischen KI-Modellen und anderen Anwendungen.

Warum muss ich mich um Versionen kümmern?

Verschiedene Versionen des Protokolls haben unterschiedliche Regeln. Mit der falschen Version kann dein Programm nicht funktionieren oder sich unerwartet verhalten.

Was sind „Tools“ in diesem Zusammenhang?

Tools sind die konkreten Aktionen oder Funktionen, die dein MCP-Programm ausführen kann. Sie werden als Methoden im C#-Code definiert.

Details

Originalbeschreibung des Autors

Build Model Context Protocol (MCP) servers in C#/.NET against the current ModelContextProtocol 2.x NuGet packages. Helps with cases the model gets wrong without guidance — stale versions (0.x preview or 1.x-era defaults), the v2 stateless-by-default HTTP flip, the 2026-07-28 spec deprecations (roots/sampling/logging), MCP Apps and Tasks extension packages, elicitation URL mode, per-session HTTP wi

repo: github/awesome-copilot

Beliebtheit

GitHub-Sterne
40k
Platz im Ranking
#7179
Lizenz
MIT
Aktualisiert
15.10.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills