Get the FREE Ultimate OpenClaw Setup Guide →

mcpdotnet

.NET implementation of the Model Context Protocol (MCP)

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio pederhp-mcpdotnet dotnet path/to/server.dll \
  --env Examples="Placeholder for environment-specific values if needed"

How to use

The mcpdotnet server provides a .NET implementation of the Model Context Protocol (MCP). It enables .NET applications to expose tooling, resources, prompts, and other MCP capabilities to clients and LLMs via a server that can be connected over standard MCP transports. This repository demonstrates how to configure a server to expose tools from your application using a stdio transport, so you can run the server as a child process and communicate through standard input/output. The library supports key MCP capabilities (Tool, Resource, Prompt, Sampling, Roots) and includes a Completion utility, along with server instructions, pagination, and notifications. Tools can be registered automatically from your assembly using attributes, or you can register a custom set of tools and handlers to suit your use case. The provided example shows how to start an MCP server with stdio transport and auto-discover tools from the current application, making it straightforward to plug MCP into existing .NET services.

How to install

Prerequisites:\n- .NET 8.0 SDK or newer installed on your system.\n- Basic familiarity with NuGet package management and .NET hosting.\n\nStep-by-step setup:\n1) Create a new .NET project or use an existing one where you want to expose MCP tools.\n2) Install the MCP library package (mcpdotnet) from NuGet:\n\n dotnet add package mcpdotnet\n\n3) Integrate MCP into your server startup, registering the MCP server transport (stdio) and tools. For example, in Program.cs you can configure a hosted MCP server with stdio transport and auto-discovery of tools in the current assembly.\n4) Build your project:\n\n dotnet build\n\n5) Run the resulting executable or publish for your target environment. If you are using stdio transport in a hosting scenario, you may run the server as a child process connected via standard IO.\n6) Connect a client to the server according to MCP transport conventions (stdio in this example) and start listing tools, invoking them, and handling responses.\n\nNotes:\n- The exact server startup code may vary based on your hosting model; the README example demonstrates a minimal setup.\n- Ensure your tools are discovered via the McpTool attributes or registered explicitly if you do not rely on assembly scanning.

Additional notes

Tips and common considerations:\n- When using stdio transport, ensure proper process lifetime management and cancellation handling for clean shutdowns.\n- Enable logging to observe MCP client/server interactions; the library supports various logging backends.\n- If you add new tools in your assembly, ensure the McpTool attribute is applied and that tools are discoverable by the server at startup.\n- If you plan to expose a large number of tools, consider enabling pagination on the ListTools capability to avoid overwhelming clients.\n- For deployment, consider packaging your MCP server as a standalone executable or as part of a hosting service, depending on your infrastructure.\n- The repository has moved to a different official location; refer to the official C# SDK repository for the latest guidance and samples.

Related MCP Servers

Sponsor this space

Reach thousands of developers