| name | mcp-csharp-publish |
| description | Use when publishing, packaging, containerizing, deploying, or distributing a C# MCP server through dnx, MCPB, or a remote HTTP host. |
| license | MIT |
| version | 0.2.0 |
C# MCP Server Publishing
Derived from dotnet/skills under MIT; updated for ModelContextProtocol 2.0.0 and MCP 2026-07-28. See ../../THIRD-PARTY-NOTICES.md.
Choose distribution by where the server needs to run:
| Need | Distribution |
|---|
| Cloud API or shared service | Remote stateless HTTP deployment |
| Local filesystem, desktop app, hardware, or localhost access | MCPB bundle |
| Developer-facing .NET command | Pack as a tool for dnx |
.NET tool / dnx
Use PackAsTool=true in the project metadata, package it, and exercise the installed command with dnx from a clean environment. The package must write JSON-RPC only to stdout; diagnostics go to stderr.
<PropertyGroup>
<PackAsTool>true</PackAsTool>
<ToolCommandName>inventory-mcp</ToolCommandName>
</PropertyGroup>
Remote HTTP
Publish the server with an explicit bind address and a separate health route. Modern HTTP is stateless by default; put durable state in an application store keyed by explicit handles, not transport sessions. Protect the MCP endpoint with real authorization and validate bearer-token audience when applicable. Run conformance against the deployed URL before release.
MCPB
Use $build-mcpb when the server must execute on the user's device. Bundle the runtime and server, validate manifest_version: "0.4", define user configuration explicitly, and enforce filesystem/process/network boundaries in the server because MCPB does not sandbox it.
Release gate
dotnet build -c Release
dotnet test -c Release
dotnet pack -c Release
For AOT distribution, also prove dotnet publish -p:PublishAot=true. Publish only after the artifact starts in a clean environment and the relevant stdio, HTTP, or MCPB behavior is exercised.