SampleDotnetMcpServer

SampleDotnetMcpServer

A sample .NET MCP server demonstrating tool implementation including random number generation, personalized greetings, and weather information for US zip codes.

Category
Visit Server

README

SampleDotnetMcpServer

This project is a sample implementation of a Model Context Protocol (MCP) server in .NET, designed to demonstrate how to build, run, and publish an MCP server using C# and the ModelContextProtocol SDK.

mcp-name: io.github.timheuer/sampledotnetmcpserver

What is this?

SampleDotnetMcpServer is a reference MCP server for .NET, showing how to:

  • Implement MCP tools in C# (see Tools/RandomNumberTools.cs, Tools/SayHelloName.cs, Tools/WeatherTools.cs)
  • Register tools and configure the MCP server transport (see Program.cs)
  • Package and publish the server as a NuGet package for use in IDEs like VS Code and Visual Studio

The included tools demonstrate various MCP capabilities:

  • get_random_number: Generates random numbers within a specified range
  • say_hello_name and say_goodbye_name: Simple greeting tools
  • get_weather_by_zip_code: Gets current weather information for any US zip code
  • get_weather_forecast: Gets a multi-day weather forecast for any US zip code

Features

  • Implements the MCP protocol using stdio transport
  • Provides multiple sample tools:
    • get_random_number: Returns a random integer in a specified range
    • say_hello_name and say_goodbye_name: Simple greeting tools
    • get_weather_by_zip_code: Gets current weather for any US zip code using wttr.in API
    • get_weather_forecast: Gets multi-day weather forecast for any US zip code
  • Ready to be packed and published as a NuGet MCP server
  • Example configuration files and metadata included

How to use

Run locally

You can run the MCP server directly from source for development and testing:

dotnet run --project .

Or configure your IDE to use the following MCP server definition:

{
  "servers": {
    "SampleDotnetMcpServer": {
      "type": "stdio",
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "<PATH TO PROJECT DIRECTORY>"
      ]
    }
  }
}

Test the MCP server

Once running, you can use Copilot Chat or any MCP client to invoke the available tools:

Weather Tools:

  • Ask: "What's the weather like in 90210?" to get current weather
  • Ask: "Give me a 3-day forecast for 10001" to get a weather forecast
  • Ask: "Check the weather in 60601" to test with Chicago's zip code

Other Tools:

  • Ask: "Give me 3 random numbers" to use the random number generator
  • Ask: "Say hello to John" to use the greeting tools

Publish to NuGet.org

CI handles publishing to NuGet, using NuGet Trusted Publishing for the key and automatic versioning using Nerdbank.GitVersioning.

Use from NuGet.org

After publishing, configure your IDE to use the MCP server from NuGet.org. Example configuration (replace package id and version):

{
  "servers": {
    "SampleDotnetMcpServer": {
      "type": "stdio",
      "command": "dnx",
      "args": [
        "TimHeuer.SampleMcpServer",
        "--version",
        "0.1.0-beta",
        "--yes"
      ]
    }
  }
}

Project structure

  • Program.cs: MCP server entry point and configuration
  • Tools/RandomNumberTools.cs: Example MCP tool for generating random numbers
  • Tools/SayHelloName.cs: Example MCP tools for greetings
  • Tools/WeatherTools.cs: Weather-related MCP tools for checking weather by zip code
  • .mcp/server.json: MCP server metadata and NuGet package info
  • SampleDotnetMcpServer.csproj: Project and NuGet packaging configuration

Learn more


This project is for demonstration and reference purposes only. For feedback or contributions, see the GitHub repository.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured