dotnet-mcp

Build and consume Model Context Protocol servers and clients in .NET using the official MCP C# SDK.

Updated Mar 31, 2026
One-click install
npx skills add https://github.com/zhenpengLai/myuseskill --skill dotnet-mcp-zhenpenglai
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dotnet-mcp
Source: https://github.com/zhenpengLai/myuseskill/tree/main/dotnet-mcp
Command: npx skills add https://github.com/zhenpengLai/myuseskill --skill dotnet-mcp-zhenpenglai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ModelContextProtocol.Core, ModelContextProtocol, ModelContextProtocol.AspNetCore, and includes references (resource) components.

What problem does it solve? Building interoperable AI tool integrations in .NET requires correctly implementing the Model Context Protocol wire format, transports, and capability negotiation, which is error-prone without guidance on the official MCP C# SDK. ## Core Features & Use Cases - Server and Client Construction: Create MCP servers over stdio or Streamable HTTP and connect .NET clients to existing MCP servers using McpClient.CreateAsync. - Capability-Aware Integration: Expose tools, resources, and prompts with [McpServerTool], [McpServerResource], and [McpServerPrompt] attributes, and check ServerCapabilities before using optional features like subscriptions, sampling, or elicitation. - Use Case: A developer wants their ASP.NET Core service to expose internal build tools to an AI agent host. They add ModelContextProtocol.AspNetCore, call AddMcpServer().WithHttpTransport().WithToolsFromAssembly(), map the endpoint with MapMcp("/mcp"), and the tools become discoverable to any MCP client. ## Quick Start Ask the AI to scaffold a minimal MCP stdio server in .NET with an echo tool using the ModelContextProtocol package and attribute-based tool discovery.

Frequently Asked Questions about dotnet-mcp

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

FAQPage Schema
How do I build an MCP server in .NET?▼

Add the ModelContextProtocol NuGet package, call AddMcpServer() with WithStdioServerTransport() for local servers or WithHttpTransport() plus MapMcp() for ASP.NET Core, then annotate methods with [McpServerTool] and [Description] attributes for discovery.

How do I connect a .NET app to an existing MCP server?▼

Create a StdioClientTransport or HttpClientTransport with the server's command or endpoint, then call McpClient.CreateAsync. Use ListToolsAsync to discover tools, which can be passed directly into IChatClient since McpClientTool inherits from AIFunction.

Should I use stdio or HTTP transport for MCP?▼

Use stdio when the server runs as a local child process for editor or agent integrations. Use Streamable HTTP for remote servers; SSE mode exists only for legacy client compatibility and should not be chosen for new servers.

What is the difference between ModelContextProtocol.Core and ModelContextProtocol.AspNetCore?▼

ModelContextProtocol.Core provides minimal client and low-level server APIs with the smallest dependency set. ModelContextProtocol adds hosting, DI, and stdio support, while AspNetCore includes everything needed to host a remote HTTP MCP server.

Why does my stdio MCP server fail to communicate with the client?▼

Anything written to stdout corrupts the MCP protocol stream. Route all logging to stderr using LogToStandardErrorThreshold, and avoid Console.WriteLine or banner output in stdio servers.

When should I check ServerCapabilities in an MCP client?▼

Check client.ServerCapabilities before using optional features like resource subscriptions, completions, logging, or prompt list-change notifications. Servers only advertise capabilities for registered features, so assuming support breaks against partial implementations.