Get the FREE Ultimate OpenClaw Setup Guide →

McpToolkit

Lightweight, fast, NativeAOT compatible MCP (Model Context Protocol) framework for .NET

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio nuskey8-mcptoolkit dotnet path/to/McpToolkit.Server.dll \
  --env ASPNETCORE_ENVIRONMENT="Development"

How to use

MCP Toolkit for .NET provides a lightweight way to build MCP servers using native C# with minimal boilerplate. You create an McpServer instance, register your tools with server.Tools.Add(), and connect a transport (for example, Stdio) to listen for JSON-RPC requests from MCP clients. The toolkit uses Source Generators to generate the boilerplate necessary to expose your methods as MCP tools, allowing you to focus on the business logic. You can add tools at runtime or define them via a class with descriptive metadata, and the generated code will handle argument parsing and result formatting according to the MCP JSON-RPC protocol.

Once your server is running, clients can call your tools by name and pass arguments in a JSON object. The server validates inputs against the generated schema, executes the corresponding delegate, and returns results in the MCP-compatible JSON format. This setup is particularly well-suited for local MCP servers and Native AOT scenarios, where you want a small, dependency-light runtime with minimal overhead.

How to install

Prerequisites:

  • .NET 8.0 or later installed on your machine
  • Basic familiarity with .NET CLI and NuGet packages
  1. Create a new console project (or add to an existing one):
dotnet new console -n McpToolkitServerSample
cd McpToolkitServerSample
  1. Install the MCP Toolkit server package:
dotnet add package McpToolkit.Server
  1. Implement a minimal MCP server as shown in the Quick Start, then run the project:
// Example usage (in Program.cs or equivalent)
using McpToolkit;
using McpToolkit.Server;

await using var server = new McpServer();

server.Tools.Add("add", "Add two numbers together.", (double lhs, double rhs) => lhs + rhs);

await server.ConnectAsync(new StdioServerTransport());
await Task.Delay(Timeout.Infinite);
  1. Build and run:
dotnet build
dotnet run --project McpToolkitServerSample.csproj

Note: MCP Toolkit is alpha and may introduce breaking changes. The project focuses on providing a zero-dependency, NativeAOT-friendly experience for local MCP servers.

Additional notes

Tips and considerations:

  • The project emphasizes Native AOT compatibility and aims to avoid unnecessary runtime dependencies. If you rely on hosting integrations, those are optional and can be added via separate packages.
  • If you plan to publish a standalone tool, consider publishing as a single-file native executable to reduce the deployment surface.
  • Keep in mind that some features (like Streamable HTTP Transport, Authorization, Cancellation, and Progress) are under development and not yet supported.
  • When using Source Generators, you can define tools via lambda expressions or by annotating methods in a class; the generator will produce the necessary parsing and invocation code.
  • For debugging, you can use the Stdio transport to interact with the server from console-based clients.

Related MCP Servers

Sponsor this space

Reach thousands of developers