Skip to content

Add .NET MCP Server authoring skill#33

Closed
Copilot wants to merge 3 commits into
mainfrom
copilot/add-dotnet-mcp-guidance
Closed

Add .NET MCP Server authoring skill#33
Copilot wants to merge 3 commits into
mainfrom
copilot/add-dotnet-mcp-guidance

Conversation

Copilot AI commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

Developers building MCP (Model Context Protocol) servers for AI agents lack reliable guidance on transport selection, hosting patterns, and SDK usage for the evolving .NET MCP ecosystem.

Changes

  • New skill: skills/dotnet-mcp-server/SKILL.md (473 lines) with references/code-examples.md for detailed examples
  • Transport decision tree: stdio for local CLI tools vs HTTP/SSE for shared services with auth/CORS
  • Framework guidance: .NET 10 LTS recommended (current as of Feb 2026), with .NET 9 STS and .NET 8 LTS tradeoffs
  • Scaffolding templates: Console host with ModelContextProtocol for stdio (with stderr logging), ASP.NET Core with ModelContextProtocol.AspNetCore for HTTP
  • Tool/resource patterns: IMcpTool and IMcpResource implementations with attribute-based method registration
  • HTTP concerns: Authentication middleware, CORS policies, endpoint routing
  • Testing strategy: Unit test tools in isolation, integration test via host instantiation, manual test with JSON-RPC over stdin/HTTP
  • Packaging and deployment: Standalone executables, Native AOT, container deployment with Docker, and deployment considerations

Example

public class CalculatorTool : IMcpTool
{
    [McpToolMethod("add")]
    [Description("Adds two numbers together")]
    public Task<int> AddAsync(
        [Description("First number")] int a,
        [Description("Second number")] int b)
    {
        return Task.FromResult(a + b);
    }
}

Targets Copilot CLI, VS Code, Claude Desktop, and web-based agent consumers.

Key Technical Details

  • stdio logging: Configured to use stderr exclusively (LogToStandardErrorThreshold) to maintain MCP protocol compliance
  • File organization: Main skill under 500 lines with detailed examples in references/ directory per repository conventions
Original prompt

This section details on the original issue you should resolve

<issue_title>Skill: .NET MCP Server Authoring</issue_title>
<issue_description>## Problem

AI agents are increasingly powered by MCP (Model Context Protocol) servers, and .NET is a natural fit for building them. However, developers face a maze of decisions: stdio vs HTTP transport, which target framework to use, how to structure tools and resources, and how to handle authentication for HTTP endpoints. Generic AI guidance is unreliable here — it mixes up transport semantics, suggests incorrect hosting patterns, and doesn't know the current state of the .NET MCP SDK.

What expert .NET knowledge would this encode?

  • Transport selection guidance: When to use stdio (local tools, CLI agents, Copilot CLI) vs HTTP/SSE (shared services, multi-client, cloud-hosted) — with decision tree
  • Target framework selection: .NET 8 LTS vs .NET 9 vs .NET 10 tradeoffs for MCP servers specifically (hosting model differences, AOT compatibility, support lifecycle)
  • Project scaffolding: Correct package references (ModelContextProtocol, Microsoft.Extensions.Hosting), minimal hosting setup for each transport
  • Tool and resource authoring: Proper patterns for defining tools, resources, and prompts using the .NET MCP SDK attributes and conventions
  • HTTP-specific concerns: Authentication, CORS, endpoint routing, and deployment considerations
  • Testing patterns: How to test MCP tools in isolation and integration-test a running server

Skill concept

A guided skill that walks the developer through building a .NET MCP server from scratch. It should:

  1. Ask the right questions first — What will consume this server? (Copilot CLI, VS Code, Claude Desktop, a web app?) How many concurrent clients? Does it need auth?
  2. Guide transport selection — Based on answers, recommend stdio or HTTP (or both via dual hosting)
  3. Guide target framework selection — Based on deployment target, AOT needs, and support requirements
  4. Scaffold the project — Generate the correct project file, hosting setup, and initial tool/resource structure
  5. Validate the result — Ensure the server starts, responds to initialize, and tools are discoverable

Why customers would value this

MCP is the emerging standard for agent extensibility. Developers who want to build tools for Copilot, Claude, or other AI agents need to stand up MCP servers — and .NET developers deserve first-class guidance for doing it idiomatically. The .NET MCP SDK is new and fast-moving; the team knows the correct patterns before they're widely documented.

Scope

  • stdio and HTTP transports
  • Target framework decision guidance
  • Basic tool and resource authoring
  • Does NOT cover: custom transport implementations, MCP client authoring, or proxy/gateway patterns</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: artl93 <9855795+artl93@users.noreply.github.com>
Copilot AI changed the title [WIP] Add expert guidance for .NET MCP server authoring Add .NET MCP Server authoring skill Feb 17, 2026
Copilot AI requested a review from artl93 February 17, 2026 16:58
Comment thread skills/dotnet-mcp-server/SKILL.md Outdated

var builder = Host.CreateApplicationBuilder(args);

builder.Logging.AddConsole();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot - why are we logging to console? Would it be better to log to file pr better to stderr per spec? Spewing to the console creates problems and is non-compliant for stdio servers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 94e9a59. Logging now configured to write to stderr using LogToStandardErrorThreshold = LogLevel.Trace, keeping stdout clear for JSON-RPC messages per MCP stdio transport spec.

}
}
```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot - should we add a step for packaging / deployment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 94e9a59 as Step 8. Covers standalone executables, Native AOT, container deployment with Docker, and deployment considerations. Detailed examples moved to references/code-examples.md.

Comment thread skills/dotnet-mcp-server/SKILL.md Outdated
- Consider if project timeline aligns with .NET 10 release
- Use preview versions only for experimentation

**Decision tree**: Use .NET 8 LTS unless the user has a specific reason to use .NET 9 features or is targeting .NET 10 for long-term projects starting after its release.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot - please prefer .NET 10 - today is Feb 17, 2026, so the information here is quite dated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 94e9a59. Now recommends .NET 10 LTS as current best choice (support through Nov 2027), with .NET 9 STS approaching end of support (May 2026) and .NET 8 LTS as fallback for compatibility constraints.

…d deployment step

Co-authored-by: artl93 <9855795+artl93@users.noreply.github.com>
Copilot AI requested a review from artl93 February 17, 2026 17:43
@leslierichardson95

Copy link
Copy Markdown
Contributor

@artl93 I think this skill looks good. Maybe there's also an opportunity to merge its content with some of the skills I recently created a PR for? #36

@artl93

artl93 commented Feb 19, 2026

Copy link
Copy Markdown
Member

@leslierichardson95 - yours to my eyes (without testing) yours looks more comprehensive. Are you opposed to going with yours? What do you think yours could use?

@leslierichardson95

Copy link
Copy Markdown
Contributor

@leslierichardson95 - yours to my eyes (without testing) yours looks more comprehensive. Are you opposed to going with yours? What do you think yours could use?

@artl93 I'm not opposed to going with mine. At a glance, I think mine could also definitely use some of your content like the following:

  • the docker-compose.yml file example
  • the input specification chart for extra clarity / description
  • the common pitfalls chart
  • additional resources section
  • Authentication details / examples

@artl93

artl93 commented Feb 19, 2026 via email

Copy link
Copy Markdown
Member

@leslierichardson95

Copy link
Copy Markdown
Contributor

Have copilot just grab ‘em (local CLI / VSCode / VS should work great for looking at two PRs and updating an existing one). I’m just on calls the rest of the day.

@artl93 I just updated my PR with some of the content I mentioned above if you wanna take a look :)
#36

@timheuer

Copy link
Copy Markdown
Member

yes let's get one simplified MCP authoring skill between this and #36 please

@artl93 artl93 closed this Feb 20, 2026
@artl93

artl93 commented Feb 20, 2026

Copy link
Copy Markdown
Member

Let's take Leslie's.

@ViktorHofer ViktorHofer deleted the copilot/add-dotnet-mcp-guidance branch March 4, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skill: .NET MCP Server Authoring

5 participants