Get the FREE Ultimate OpenClaw Setup Guide →

tutorial -dotnet

This is a very basic example of how to create MCP servers in .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 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:

  1. Install prerequisites
  1. Clone the repository
  • git clone <repository-url>
  • cd into the project directory
  1. Restore and build
  • dotnet restore
  • dotnet build
  1. 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
  1. 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

Sponsor this space

Reach thousands of developers