github/awesome-copilot / skills/dotnet-mcp-builder
dotnet-mcp-builder
VerifiedBuild 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 wiring, OAuth and reverse-proxy deploy specifics, and debugging MapMcp / STDIO / Streamable-HTTP errors. Also covers STDIO and Streamable HTTP transports (SSE is deprecated), tools, prompts, resources, completions, and a basic .NET MCP client. Trigger when the user says or implies any .NET MCP server work: ModelContextProtocol, McpServerTool, MapMcp, WithStdioServerTransport, "MCP server in C#", "MCP tool in dotnet", "expose this as MCP", or names a primitive (prompt/resource/elicitation/MCP App) in a .NET context. Skip for MCP work in other languages.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.4 KB |
| references/client.md | markdown | 6.2 KB |
| references/elicitation.md | markdown | 7.8 KB |
| references/mcp-apps.md | markdown | 9.8 KB |
| references/packages.md | markdown | 5.2 KB |
| references/prompt-primitive.md | markdown | 5.0 KB |
| references/resource-primitive.md | markdown | 6.1 KB |
| references/roots.md | markdown | 4.0 KB |
| references/sampling.md | markdown | 5.4 KB |
| references/server-features.md | markdown | 6.6 KB |
| references/testing.md | markdown | 6.1 KB |
| references/tool-primitive.md | markdown | 8.4 KB |
| references/transport-http.md | markdown | 8.4 KB |
| references/transport-stdio.md | markdown | 5.1 KB |
references/prompt-primitive.md
View on GitHub# Prompts
Prompts are reusable, parameterised message templates that the user (not the LLM) typically picks from a list — think "slash commands" in a chat client. The server defines them; the host renders them as menus.
## Anatomy of a prompt
```csharp
using System.ComponentModel;
using Microsoft.Extensions.AI;
using ModelContextProtocol.Server;
[McpServerPromptType]
public class CodePrompts
{
[McpServerPrompt, Description("Generates a code review prompt.")]
public static IEnumerable<ChatMessage> CodeReview(
[Description("The programming language")] string language,
[Description("The code to review")] string code) =>
[
new(ChatRole.User,
$"Please review the following {language} code:\n\n```{language}\n{code}\n```"),
new(ChatRole.Assistant,
"I'll review the code for correctness, style, and potential improvements.")
];
}
```
Register it:
```csharp
.WithPrompts<CodePrompts>()
// or
.WithPromptsFromAssembly()
```
## Return types
| Return type | Result |
|---|---|
| `ChatMessage` | Single message. |
| `IEnumerable<ChatMessage>` | Conversation seed. |
| `PromptMessage` / `IEnumerable<PromptMessage>` | Lower-level — use when you need full control over content blocks (embedded resources, multiple typed blocks per message). |
| `GetPromptResult` | Full control — set `Messages` and `Description`. |
`ChatMessage`/`ChatRole` come from `Microsoft.Extensions.AI`. They're the high-level shape and what you should use 90% of the time. Drop down to `PromptMessage`/`ContentBlock` only when you need embedded resources or fine-grained content typing.
## Arguments
Every parameter (after the special ones the SDK strips out — `IMcpServer`, `CancellationToken`, etc.) becomes a prompt argument visible to the user when they pick the prompt. Use `[Description]` on each to explain what the user should supply.
To mark an argument optional, give it a default value:
```csharp
[McpServerPrompt, Description("…")]
public static ChatMessage Greeting(
[Description("Their preferred greeting style")] string style = "casual")
=> new(ChatRole.User, $"Greet me in a {style} style.");
```
## Image and file content
For prompts that include images:
```csharp
[McpServerPrompt, Description("Asks the model to analyze an image.")]
public static IEnumerable<ChatMessage> AnalyzeImage(
[Description("Instructions for the analysis")] string instructions)
{
byte[] imageBytes = LoadSampleImage();
return new[]
{
new ChatMessage(ChatRole.User, new AIContent[]
{
new TextContent($"Please analyze this image: {instructions}"),
new DataContent(imageBytes, "image/png")
})
};
}
```
For embedded text resources (e.g. seeding the conversation with a document the user picked):
```csharp
[McpServerPrompt, Description("Reviews a referenced document.")]
public static IEnumerable<PromptMessage> ReviewDocument(
[Description("The document ID to review")] string documentId)
{
string content = LoadDocument(documentId);
return new[]
{
new PromptMessage
{
Role = Role.User,
Content = new TextContentBlock { Text = "Please review the following document:" }
},
new PromptMessage
{
Role = Role.User,
Content = new EmbeddedResourceBlock
{
Resource = new TextResourceContents
{
Uri = $"docs://documents/{documentId}",
MimeType = "text/plain",
Text = content
}
}
}
};
}
```
## Async prompts
Prompts can be async — useful when you need to look up data to build the messages:
```csharp
[McpServerPrompt, Description("Drafts a release-notes prompt.")]
public static async Task<IEnumerable<ChatMessage>> ReleaseNotes(
string repo,
string fromTag,
string toTag,
IGitHubClient github,
CancellationToken ct)
{
var commits = await github.GetCommitsBetweenAsync(repo, fromTag, toTag, ct);
var summary = string.Join("\n", commits.Select(c => $"- {c.Message}"));
return new[]
{
new ChatMessage(ChatRole.User,
$"Draft release notes for {repo} {fromTag}→{toTag} from these commits:\n{summary}")
};
}
```
## Notifying clients of prompt changes
```csharp
await server.SendNotificationAsync(
NotificationMethods.PromptListChangedNotification,
new PromptListChangedNotificationParams(),
cancellationToken);
```
## When to use prompts vs. tools
- **Prompt:** the *user* triggers it from a menu, supplying any required arguments. The output is messages, not data. Good for "/summarize", "/code-review", "/draft-email".
- **Tool:** the *LLM* triggers it (often without explicit user action) to fetch or change data. Good for "get_weather", "create_issue".
If both apply (the user wants a slash command that triggers the same logic the LLM could call), expose both — the same DTO/service can back both.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |