Get the FREE Ultimate OpenClaw Setup Guide →

Mcp.Net

A fully featured C# implementation of Anthropic's 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 samfold-mcp.net dotnet run --project Mcp.Net.Examples.SimpleServer/Mcp.Net.Examples.SimpleServer.csproj \
  --env ASPNETCORE_URLS="http://localhost:5000"

How to use

Mcp.Net provides a .NET implementation of the Model Context Protocol (MCP). It lets apps expose tools, resources, and prompts in a standardized way so AI models can discover and call them. The repository includes a ready-to-run example server (Mcp.Net.Examples.SimpleServer) and client libraries for building both servers and clients. To get started you typically run the example server and then connect a client to it to list tools and invoke them. The server demonstrates common MCP patterns such as tools registered via attributes, synchronous and asynchronous tool handlers, and streaming/Content responses. You can also integrate the server into your own applications by referencing Mcp.Net.Server and registering tools with attributes or with the explicit registration API, enabling a quick path from concept to a working MCP-enabled service. When connected, clients can perform actions like arithmetic operations, weather lookups, web interactions, or any domain you expose through tools, with the protocol ensuring consistent input, output, and content structures.

How to install

Prerequisites:

  • Install the .NET SDK (6.x or later) and ensure dotnet is available in your PATH.
  • Optional: Git for cloning the repository.
  1. Clone the repository or download the sample server:
  1. Build and run the sample server to start exploring MCP:
  • cd Mcp.Net.Examples.SimpleServer
  • dotnet run --project Mcp.Net.Examples.SimpleServer/Mcp.Net.Examples.SimpleServer.csproj
  1. Install client/server packages if you plan to build your own server/client:
  • For the server side: dotnet add package Mcp.Net.Server
  • For the client side: dotnet add package Mcp.Net.Client
  1. If you want to run the OAuth-enabled sample, follow the OAuth/PKCE steps shown in the repository readme and ensure you have the necessary credentials available in your environment.

Additional notes

Notes and tips:

  • This MCP server focuses on exposing tools via the Mcp.Net.Server framework. Tools can be registered using attributes or through explicit registration code, and can return plain text or POCOs that are serialized into MCP content.
  • The sample server demonstrates both synchronous and asynchronous tool handlers, as well as a weather example. You can adapt these patterns to your own domain models.
  • The initial sample server runs on http://localhost:5000 with SSE streaming for interactions; adjust ASPNETCORE_URLS as needed.
  • If you see 401 responses during OAuth flows, the sample client implements the challenge/registration/PKCE handshake and will reconnect with a bearer token once authorized.
  • The MCP version in use is 0.9.0 (pre-1.0); some features may still be under development.
  • You can register tools manually or via the McpTool attribute-based approach, and you can query the list of tools from the client to discover capabilities at runtime.

Related MCP Servers

Sponsor this space

Reach thousands of developers