tutorial -dotnet
This is a very basic example of how to create MCP servers in .NET
claude mcp add --transport stdio mehrandvd-tutorial-mcp-server-dotnet dotnet run --project Server.csproj \ --env MCP_HOST="default 0.0.0.0" \ --env MCP_PORT="default 5000"
How to use
This MCP server for .NET is built with C# and exposes the MCP protocol so clients can connect and interact with it using standard MCP tooling. Once running, the server accepts MCP connections on the configured host and port, allowing clients to negotiate capabilities, request data, and send commands defined by the MCP implementation in this project. Use an MCP client or testing tool to connect to the server's port, then follow the protocol prompts to authenticate (if applicable) and execute available operations. Typical workflows include starting the server, connecting with a client, and sending a sequence of setup messages to initialize capabilities, followed by normal operation commands defined by the MCP server’s endpoints.
To interact with the server, ensure you point your client to the host and port configured via MCP_PORT and MCP_HOST. If the project provides example scripts or utilities, run those to verify a successful handshake and to test common commands. The documentation within the repo (and the linked blog) will describe supported MCP features, such as capability negotiation, request/response patterns, and any domain-specific commands implemented by the tutorial server.
How to install
Prerequisites:
- .NET SDK (recommended latest LTS) installed on your machine
- Git to clone or fetch the repository
- Basic familiarity with the MCP protocol and C# development
Step-by-step:
- Install prerequisites
- Visit https://dotnet.microsoft.com/download and install the .NET SDK for your platform.
- Clone the repository
- git clone <repository-url>
- cd into the project directory
- Restore and build
- dotnet restore
- dotnet build
- Run the server
- dotnet run --project Server.csproj
- Alternatively, use the mcp_config if deploying via a process manager with the command shown in the config
- Verify operation
- Use an MCP client to connect to the server host/port (default host 0.0.0.0, port 5000 unless overridden by MCP_PORT)
- Perform a handshake and issue basic commands to confirm the server responds as expected
Additional notes
Tips and caveats:
- If the server fails to start, check that the port is not in use by another process and that the .NET SDK is properly installed.
- If you customize MCP_PORT or MCP_HOST, ensure any firewalls or container networking allow traffic to that port.
- Review any appsettings.json or environment-specific configuration for overrides to host/port or protocol options.
- For debugging, run the server in a development environment and attach a debugger to the Server.csproj project to inspect protocol handling and command processing.
- If you encounter handshake or capability negotiation issues, ensure the client and server agree on the MCP version and the supported features implemented by the tutorial server.
Related MCP Servers
skunit
skUnit is a testing tool for AI units, such as IChatClient, MCP Servers and agents.
SharpToolsMCP
A suite of MCP tools for AIs to analyze and modify C# solutions with high signal, Roslyn powered context.
mssql
MSSQL Server MCP implementation written in C#
mobile-dev
This is a MCP designed to manage and interact with mobile devices and simulators.
Mcp.Net
A fully featured C# implementation of Anthropic's Model Context Protocol (MCP)
RimSearcher
A Model Context Protocol (MCP) server for fast searching and retrieval of RimWorld source code.