dotnet-mcp

Build, test, debug, and publish C# MCP servers using the official ModelContextProtocol SDK.

7|3|Updated Sep 23, 2025
One-click install
npx skills add https://github.com/islamu-ngo/Event --skill dotnet-mcp-islamu-ngo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dotnet-mcp
Source: https://github.com/islamu-ngo/Event/tree/main/.agents/skills/dotnet-mcp
Command: npx skills add https://github.com/islamu-ngo/Event --skill dotnet-mcp-islamu-ngo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building a Model Context Protocol server in .NET involves many failure points: choosing the wrong transport, polluting stdout in stdio mode, missing tool attributes, and packaging mistakes. This Skill provides a complete engineering playbook for creating, debugging, testing, and publishing C# MCP servers with Microsoft's official ModelContextProtocol SDK. ## Core Features & Use Cases - Server Scaffolding & Transport Selection: Guides project creation for stdio console hosts versus ASP.NET Core Streamable HTTP hosts, with DI registration and tool contract rules ([McpServerToolType], [McpServerTool], [Description]). - Debugging & Protocol Verification: Enforces Inspector-first verification with npx @modelcontextprotocol/inspector, stdout safety invariants, and IDE client configuration for VS Code, Visual Studio, and Claude Desktop. - Testing & Evaluations: Covers direct tool unit tests, McpClient protocol integration tests asserting ListToolsAsync and CallToolAsync, WebApplicationFactory HTTP tests, and LLM tool evaluation suites. - Publishing & Deployment: Walks through NuGet tool packaging (PackAsTool), chiseled multi-stage Dockerfiles, Azure Container Apps deployment, and MCP Registry publishing via server.json. - Use Case: You need to expose your company's internal API as MCP tools for AI assistants. Use this Skill to scaffold a stdio server, verify it in the MCP Inspector, write protocol integration tests, and publish it as a NuGet tool listed on the MCP Registry. ## Quick Start Ask the AI to scaffold a new C# MCP server with stdio transport using the official ModelContextProtocol SDK and verify it with the MCP Inspector.

Frequently Asked Questions about dotnet-mcp

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an MCP server in C# with the official SDK?▼

Target .NET 10+ and add the ModelContextProtocol package for stdio servers or ModelContextProtocol.AspNetCore for HTTP servers. Register the server with services.AddMcpServer(), choose a transport like WithStdioServerTransport(), and expose tools via classes marked with [McpServerToolType] and methods marked with [McpServerTool].

Should I use stdio or HTTP transport for my MCP server?▼

Use stdio for local command-line tools, desktop assistants, and IDE subprocesses where the client launches the server as a child process. Use Streamable HTTP via MapMcp for remote, multi-client, or containerized deployments such as Azure Container Apps.

Why does my MCP client hang when connecting to my stdio server?▼

The most common cause is application logging written to stdout, which corrupts JSON-RPC protocol framing. Route all console logging to stderr by setting LogToStandardErrorThreshold = LogLevel.Trace, then verify the server with the MCP Inspector before debugging client configuration.

How do I test C# MCP server tools?▼

Test tool logic directly with unit tests that mock HttpMessageHandler or domain services. For protocol verification, write integration tests using McpClient that assert both ListToolsAsync for discovery and CallToolAsync for invocation over a live stdio or HTTP transport.

How do I publish a .NET MCP server to the MCP Registry?▼

First package the server as a NuGet tool using PackAsTool and push it to NuGet.org. Then create a .mcp/server.json with a namespace-qualified name like io.github.username/servername, authenticate with mcp-publisher login github, and run mcp-publisher publish.

Does the C# MCP SDK support Native AOT compilation?▼

Yes, but reflection-based registration via WithToolsFromAssembly() is not compatible with Native AOT. Use explicit generic registration with WithTools<T>() for AOT scenarios to avoid runtime reflection.