Knapcode.SampleMcpServer

io.github.joelverhagen由 GitHub 帳號 joelverhagen 發布v0.7.0-beta更新於 Oct 24, 2026

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

已驗證STDIO僅桌面開發者工具

概覽

AI 產生的概覽

一個使用 C# SDK 建置的範例 MCP 伺服器,讓助理產生隨機數字和隨機天氣值。

可以做什麼
依請求產生隨機數字,例如一次產生多個值,使用 README 中提到的 get_random_number 工具。產生隨機天氣結果,可選天氣由 WEATHER_CHOICES 環境變數提供。作為將 C# MCP 伺服器封裝成 NuGet 套件的參考範例。
適用情境
適合在 VS Code 或其他用戶端試用 MCP,或作為建置自有 C# MCP 伺服器時的起始範本。它只是示範,不是真實天氣或其他生產資料的來源。
執行需求
透過 stdio 在本機執行。已發佈的套件使用 dnx 命令啟動,因此需要 .NET 工具鏈;從原始碼執行則使用 dotnet run。WEATHER_CHOICES 環境變數用於設定天氣選項。未宣告身分驗證。
安裝前請注意
它只回傳隨機值,因此不要將其天氣輸出當作真實資料。README 中的發佈清單是給自行建立套件的開發者參考,而非最終使用者。

安裝

在 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.7.0-beta最新Sep 16, 2026

評分

已滿足適用檢查項的 40%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

    請在儲存庫或註冊中心條目中宣告授權條款。