Featured
Y
Your brand here
Get featured
MCP ServerSTDIOOfficialv0.10.0-beta.10

MCP Knapcode.sample MCP Server

Generate random numbers and weather conditions via MCP tools. A reference implementation demonstrating how to build and package C# MCP servers using the official SDK and NuGet.

com.joelverhagen.mcp/Knapcode.SampleMcpServer

Hosted URL

Local install

Transport

STDIO

Auth

No auth required

MCP Knapcode.sample repository at a glance

Live signal from GitHub, refreshed weekly.

Stars

0

Last commit

Jan 20, 2026

License

Language

C#

What the MCP Knapcode.sample MCP server does

How models use it and what it is built for.

Generate random numbers and weather conditions via MCP tools. A reference implementation demonstrating how to build and package C# MCP servers using the official SDK and NuGet.

Connect to MCP Knapcode.sample

Local install — runs as a subprocess.

dnx Knapcode.SampleMcpServer@0.10.0-beta.10

Environment variables

Configuration this server reads at startup.

  • WEATHER_CHOICES

Resources

Where to find authoritative docs and source for MCP Knapcode.sample.

Example prompts for MCP Knapcode.sample

Paste any of these into Agent Studio after connecting MCP Knapcode.sample.

  • Give me 3 random numbers
  • What's the random weather for today
  • Generate a random number between 1 and 100
  • Show me how to configure WEATHER_CHOICES for custom weather options

Documentation from project README

View on GitHub

Excerpted from the project's README — boilerplate sections (license, changelog, contributing) omitted for clarity.

MCP Server - Knapcode.SampleMcpServer

This README was created using the C# MCP server template project. It demonstrates how you can easily create an MCP server using C# and then package it in a NuGet package.

See aka.ms/nuget/mcp/guide for the full guide.

Checklist before publishing to NuGet.org

  • Test the MCP server locally using the steps below.
  • Update the package metadata in the .csproj file, in particular the <PackageId>.
  • Update .mcp/server.json to declare your MCP server's inputs.
  • Pack the project using dotnet pack.

The bin/Release directory will contain the package file (.nupkg), which can be published to NuGet.org.

Using the MCP Server in VS Code

Once the MCP server package is published to NuGet.org, you can use the following VS Code user configuration to download and install the MCP server package. See Use MCP servers in VS Code (Preview) for more information about using MCP servers in VS Code.

{
  "mcp": {
    "servers": {
      "Knapcode.SampleMcpServer": {
        "type": "stdio",
        "command": "dnx",
        "args": [
          "Knapcode.SampleMcpServer@0.4.0-beta",
          "--yes",
          "--",
          "mcp",
          "start"
        ],
        "env": {
          "WEATHER_CHOICES": "sunny,humid,freezing"
        }
      }
    }
  }
}

Now you can ask Copilot Chat for a random number, for example, Give me 3 random numbers. It should prompt you to use the get_random_number tool on the Knapcode.SampleMcpServer MCP server and show you the results.

Developing locally in VS Code

To test this MCP server from source code (locally) without using a built MCP server package, create a .vscode/mcp.json file (a VS Code workspace settings file) in your project directory and add the following configuration:

{
  "servers": {
    "Knapcode.SampleMcpServer": {
      "type": "stdio",
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "<RELATIVE PATH TO PROJECT DIRECTORY>",
        "--",
        "mcp",
        "start"
      ],
      "env": {
        "WEATHER_CHOICES": "sunny,humid,freezing"
      }
    }
  }
}

Alternatively, you can configure your VS Code user settings to use your local project:

{
  "mcp": {
    "servers": {
      "Knapcode.SampleMcpServer": {
        "type": "stdio",
        "command": "dotnet",
        "args": [
          "run",
          "--project",
          "<FULL PATH TO PROJECT DIRECTORY>"
          "--",
          "mcp",
          "start"
        ]
      },
      "env": {
        "WEATHER_CHOICES": "sunny,humid,freezing"
      }
    }
  }
}
View the full README on GitHub

MCP Knapcode.sample MCP server — FAQ

Common questions about connecting and running MCP Knapcode.sample.

  • What tools does this MCP server provide?

    It provides two tools: get_random_number (generates random numbers) and a weather tool (returns random weather conditions). The weather options are configurable via the WEATHER_CHOICES environment variable.

  • How do I customize the weather options?

    Set the WEATHER_CHOICES environment variable in your MCP server configuration. For example, WEATHER_CHOICES=sunny,humid,freezing will make the weather tool randomly return one of those three options.

  • How do I install and use this server in VS Code?

    Add the server to your VS Code MCP configuration with the install command Knapcode.SampleMcpServer@0.10.0-beta.10 and type stdio. The README provides complete JSON configuration examples for both published NuGet packages and local development.

  • Is this server production-ready or just a sample?

    This is a reference implementation and template project designed to demonstrate how to build C# MCP servers. It's intended for learning and as a starting point for your own servers, not for production use.

  • What language is this MCP server written in?

    It's written in C# and uses the official MCP C# SDK. The project is packaged as a NuGet package and can be run via the dotnet runtime or dnx.

Skip the local setup — run MCP in your browser

MCP Playground runs 10,000+ hosted MCP servers — GitHub, Linear, Notion, Stripe, Sentry and more — across Claude, GPT, Gemini, DeepSeek and 40+ AI models. Compare model answers side-by-side, save agent presets, share runs. Zero install.

Open Agent Studio

Related servers

More on MCP Playground