Knapcode.SampleMcpServer

com.joelverhagen.mcp由 mcp.joelverhagen.com 发布v0.10.0-beta.10更新于 Oct 24, 2026

A sample MCP server using the MCP C# SDK. Generates random numbers and random weather.

已验证STDIO仅桌面开发者工具

概览

AI 生成的概览

一个使用 MCP C# SDK 构建的示例 MCP 服务器,为助手提供随机数和随机天气工具。

可以做什么
  • 按需生成随机数
  • 生成随机天气值,可选值由 WEATHER_CHOICES 设置提供
  • 作为将 C# MCP 服务器打包为 NuGet 包的参考示例
适用场景
主要适合作为演示或模板,用于在 VS Code 中试用 MCP,或了解 C# MCP 服务器如何打包与配置。不适用于真实的天气或数值数据需求。
运行要求
以 NuGet 包形式通过 dnx 命令在本地以 stdio 运行,或使用 dotnet CLI 从源码运行。需通过 WEATHER_CHOICES 环境变量提供天气选项。未声明任何身份验证。
安装前请注意
它明确是示例项目,工具返回的是随机占位数据而非真实信息。除试验用途外,使用前请自行审查该包。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Knapcode.SampleMcpServer,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

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.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.

json
{  "mcp": {    "servers": {      "Knapcode.SampleMcpServer": {        "type": "stdio",        "command": "dnx",        "args": [          "[email protected]",          "--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:

json
{  "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:

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

来源:README.md,提交 1b6a316

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.10.0-beta.10最新Sep 16, 2026

评分

已满足适用检查项的 40%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

    请在仓库或注册中心条目中声明许可证。