mcp -template
A minimal, production-ready implementation of a Model Context Protocol (MCP) using the official C# SDK.
claude mcp add --transport stdio estebanjosse-mcp-server-template dotnet run \ --env MCP_LOG_LEVEL="Information (or desired log level)" \ --env MCP_METRICS_ENABLED="true (or true to enable metrics)"
How to use
This MCP server template scaffolds a production-ready MCP server using the official C# SDK. The generated solution includes both HTTP and stdio hosts, along with tests and a layered architecture that cleanly separates presentation, MCP adapter logic, application services, and infrastructure concerns. The template exposes built-in tools, prompts, and resources that speak the MCP protocol, making it straightforward to run, test, and extend the server in real-world scenarios. After generation, you can start the HTTP host to serve MCP-compatible endpoints and use the stdio host for local testing and scripting via the MCP transport layer.
To use the generated server, navigate to your project root and run the hosts as needed. For example, run the HTTP host to expose REST-like endpoints and server-sent events for status, and run the stdio host for a console-based MCP transport. You can also explore the built-in tools like the echo and calc_divide commands, along with prompts such as greeting, and resources like resource://welcome and resource://status. The documentation within the repo (docs folder) covers architecture, capabilities, and operational topics like health checks, metrics, and Docker/GHCR usage.
How to install
Prerequisites
- .NET 10 SDK or later
- Optional: an MCP client (e.g., MCP Inspector) for testing the stdio host
- Install the template
dotnet new install EasyMcp.McpServer.Template
- Create a new MCP server from the template
# Example: HTTP and stdio hosts with tests
dotnet new mcp-server \
--name MyCompany.McpServer \
--http-host \
--stdio-host \
--include-tests \
-o my-server
- Build and run the generated hosts
cd my-server
# HTTP host
dotnet run --project src/MyCompany.McpServer.Host.Http
# Stdio host
dotnet run --project src/MyCompany.McpServer.Host.Stdio
Configuration is managed via appsettings.json files and environment variables (e.g., enabling metrics with MCP_METRICS_ENABLED=true). You can adjust host settings, endpoints, and MCP capabilities through the generated configuration and code.
Additional guidance is available in the repository docs (docs/template.md, docs/architecture.md, docs/capabilities.md, and docs/operations.md) for deeper customization and deployment scenarios.
Additional notes
Tips and common considerations:
- The template generates a layered MCP server with HTTP and stdio hosts; you can enable or disable hosts via the template options.
- Environment variables (e.g., MCP_METRICS_ENABLED, MCP_LOG_LEVEL) control runtime features like metrics and logging detail.
- For production deployments, review docs/operations.md for Docker/GHCR guidance, health checks, and monitoring integrations.
- MCP tools, prompts, and resources are designed to be extended; add new MCP commands, prompts, or resources within the McpServer.Template.* project areas.
- If you customize the generated code, ensure unit tests cover new business rules to maintain MCP-agnostic behavior in the application layer.
- The template is a scaffold; runtime behavior depends on the generated project structure and your configuration, so consult docs for deployment specifics.
Related MCP Servers
mssql
MSSQL Server MCP implementation written in C#
McpDotNet.Extensions.SemanticKernel
Microsoft SemanticKernel integration for the Model Context Protocol (MCP). Enables seamless use of MCP tools as AI functions.
DatabaseMcpServer
MCP server from ttcc666/DatabaseMcpServer
mcp-dataverse
MCP Server for querying Dataverse using SQL
xperience-community
ASP.NET Core MCP server for Xperience by Kentico projects
console-to-http
Example of converting a stdio MCP server to HTTP using ModelContextProtocol.AspNetCore