io.github.joelverhagen/Knapcode.SampleMcpServer
A sample MCP server using the MCP C# SDK. Generates random numbers and random weather.
Installation
Ajoutez ceci à la configuration MCP de votre client (Claude Desktop : claude_desktop_config.json ; Cursor : .cursor/mcp.json ; VS Code et les autres utilisent la même forme « mcpServers »).
Knapcode.SampleMcpServerclaude mcp add knapcode-samplemcpserver -e 'WEATHER_CHOICES=<WEATHER_CHOICES>' -- dnx Knapcode.SampleMcpServer@0.7.0-beta --yes mcp start
{
"mcpServers": {
"knapcode-samplemcpserver": {
"command": "dnx",
"args": [
"Knapcode.SampleMcpServer@0.7.0-beta",
"--yes",
"mcp",
"start"
],
"env": {
"WEATHER_CHOICES": "<WEATHER_CHOICES>"
}
}
}
}
Variables d'environnement
WEATHER_CHOICES
Documentation
Tirée du README du projet sur GitHub, actualisée chaque semaine. Les liens ouvrent GitHub.
Sommaire
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.
{
"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"
}
}
}
}
Questions fréquentes
Qu'est-ce que io.github.joelverhagen/Knapcode.SampleMcpServer ?
A sample MCP server using the MCP C# SDK. Generates random numbers and random weather.
Comment installer io.github.joelverhagen/Knapcode.SampleMcpServer ?
Il s'exécute sur votre machine. Dans Claude Code : claude mcp add knapcode-samplemcpserver -e 'WEATHER_CHOICES=<WEATHER_CHOICES>' -- dnx Knapcode.SampleMcpServer@0.7.0-beta --yes mcp start. Pour les autres clients, collez la configuration JSON de cette page dans leurs réglages MCP.
Faut-il une clé API pour io.github.joelverhagen/Knapcode.SampleMcpServer ?
Son entrée au registre n'indique aucune clé ni secret obligatoire. Certaines fonctions peuvent tout de même demander un compte auprès du service auquel il se connecte.
io.github.joelverhagen/Knapcode.SampleMcpServer est-il open source ?
Son code est public sur GitHub, mais le dépôt ne déclare pas de licence standard.
Qui maintient io.github.joelverhagen/Knapcode.SampleMcpServer ?
Il est publié par joelverhagen. AI.tn le référence sans le maintenir ni le recommander.
Issu du registre MCP officiel. Être listé n'est pas une recommandation : vérifiez le code et les permissions d'un serveur avant de lui donner accès à vos données.