.NET MCP Tutorial

v1.0.0Developer Toolsstable

This is a very basic example of how to create MCP servers in .NET

csharpcursordotnetmcpopenai
Share:
8
Stars
0
Downloads
0
Weekly
0/5

What is .NET MCP Tutorial?

.NET MCP Tutorial is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to this is a very basic example of how to create mcp servers in .net

This is a very basic example of how to create MCP servers in .NET

This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • This is a very basic example of how to create MCP servers in

Use Cases

Learn how to create MCP servers in .NET.
mehrandvd

Maintainer

LicenseMIT
Languagec#
Versionv1.0.0
UpdatedMar 27, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx tutorial-mcp-server-dotnet

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use .NET MCP Tutorial

This repository is a minimal, educational MCP server built in .NET 9 / C# that demonstrates the complete pattern for exposing tools to AI clients like Claude or Cursor. It implements a single TimeTool that returns the current time, using the official ModelContextProtocol NuGet package and Microsoft.Extensions.Hosting for a production-grade server lifecycle.

Prerequisites

  • .NET 9 SDK installed (dotnet --version shows 9.x)
  • Node.js 18+ if using npx-based MCP clients
  • Claude Desktop or Cursor IDE for testing
  • Git to clone the repository
1

Clone the repository

Fetch the tutorial project from GitHub.

git clone https://github.com/mehrandvd/tutorial-mcp-server-dotnet.git
cd tutorial-mcp-server-dotnet/src
2

Restore NuGet packages

Restore the two dependencies: ModelContextProtocol (0.1.0-preview.6) and Microsoft.Extensions.Hosting (9.0.3).

dotnet restore Tutorial.McpTimeServer.sln
3

Build the project

Compile the C# source to verify everything is set up correctly before wiring it into an AI client.

dotnet build Tutorial.McpTimeServer.csproj -c Release
4

Run the server locally to test stdio transport

MCP servers communicate over stdio. Run the server directly to confirm it starts without errors. The server will block waiting for MCP input — press Ctrl+C to exit.

dotnet run --project Tutorial.McpTimeServer.csproj
5

Register with Claude Desktop

Add the server to your Claude Desktop config so it launches automatically. Use dotnet run as the command or point to the published binary.

{
  "mcpServers": {
    "dotnet-time-server": {
      "command": "dotnet",
      "args": ["run", "--project", "/absolute/path/to/src/Tutorial.McpTimeServer.csproj"]
    }
  }
}
6

Study the TimeTool pattern to build your own tool

The entire tool is defined by decorating a class with [McpServerToolType] and methods with [McpServerTool]. This is the pattern to replicate for any new capability you want to expose.

[McpServerToolType]
public class TimeTool
{
    [McpServerTool, Description("Gets the current time.")]
    public static string GetCurrentTime() => DateTimeOffset.Now.ToString();
}

.NET MCP Tutorial Examples

Client configuration

Claude Desktop configuration for the .NET MCP tutorial time server using dotnet run.

{
  "mcpServers": {
    "dotnet-time-server": {
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "/Users/you/tutorial-mcp-server-dotnet/src/Tutorial.McpTimeServer.csproj"
      ]
    }
  }
}

Prompts to try

After connecting the server, test the exposed tool with these prompts in Claude.

- "What is the current time?"
- "Use the GetCurrentTime tool and tell me what time it is"
- "What time zone does the server return times in?"

Troubleshooting .NET MCP Tutorial

dotnet: command not found when Claude Desktop tries to start the server

Claude Desktop may not inherit your shell PATH. Provide the full path to dotnet (e.g., /usr/local/share/dotnet/dotnet) in the command field of claude_desktop_config.json.

Build fails with 'The type or namespace ModelContextProtocol could not be found'

Run 'dotnet restore' to download the ModelContextProtocol NuGet package. Confirm your global NuGet source includes nuget.org.

Server starts but Claude shows no tools available

Verify the server uses WithStdioServerTransport() and that the MCP config command/args launch the same binary. Check that no build errors silently prevented the WithTools<TimeTool>() registration.

Frequently Asked Questions about .NET MCP Tutorial

What is .NET MCP Tutorial?

.NET MCP Tutorial is a Model Context Protocol (MCP) server that this is a very basic example of how to create mcp servers in .net It connects AI assistants to external tools and data sources through a standardized interface.

How do I install .NET MCP Tutorial?

Follow the installation instructions on the .NET MCP Tutorial GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with .NET MCP Tutorial?

.NET MCP Tutorial works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is .NET MCP Tutorial free to use?

Yes, .NET MCP Tutorial is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "tutorial-mcp-server-dotnet": { "command": "npx", "args": ["-y", "tutorial-mcp-server-dotnet"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use .NET MCP Tutorial?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides