
Knapcode.SampleMcpServer
io.github.joelverhagenPublished by GitHub account joelverhagenv0.7.0-betaUpdated Oct 24, 2026
A sample MCP server using the MCP C# SDK. Generates random numbers and random weather.
Overview
A sample MCP server built with the C# SDK that lets an assistant generate random numbers and random weather values.
- What you can do
- Generate random numbers on request, such as several values at once, through the get_random_number tool named in the README. Produce random weather results, with the set of possible weather choices supplied through the WEATHER_CHOICES environment variable. Serve as a reference example of packaging an MCP server in C# as a NuGet package.
- When to use it
- Useful for trying out MCP in VS Code or another client, or as a starting template when building your own C# MCP server. It is a demonstration, not a source of real weather or other production data.
- Requirements
- Runs locally over stdio. The published package is started with the dnx command, so the .NET tooling is needed; running from source uses dotnet run. The WEATHER_CHOICES environment variable sets the weather options. No authentication is declared.
Installation
In SourceWeft
- Open Knapcode.SampleMcpServer in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
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.jsonto declare your MCP server's inputs.- See configuring inputs for more details.
- 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.
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:
Alternatively, you can configure your VS Code user settings to use your local project:
Source: README.md at commit 1b6a316
Tools
0Version history
1- v0.7.0-betaLatestSep 16, 2026
Score
40% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts
Declare a license in the repository or the registry entry.