io.github.joelverhagen/Knapcode.SampleMcpServer

السجل الرسمي أدوات المطورين

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

التثبيت

أضف هذا إلى إعدادات MCP في عميلك (Claude Desktop: claude_desktop_config.json، وCursor: ‏.cursor/mcp.json، ويستخدم VS Code وغيره الصيغة نفسها «mcpServers»).

NUGET package Knapcode.SampleMcpServer
Claude Code
claude mcp add knapcode-samplemcpserver -e 'WEATHER_CHOICES=<WEATHER_CHOICES>' -- dnx Knapcode.SampleMcpServer@0.7.0-beta --yes mcp start
إعداد JSON (Claude Desktop وCursor وVS Code)
{
    "mcpServers": {
        "knapcode-samplemcpserver": {
            "command": "dnx",
            "args": [
                "Knapcode.SampleMcpServer@0.7.0-beta",
                "--yes",
                "mcp",
                "start"
            ],
            "env": {
                "WEATHER_CHOICES": "<WEATHER_CHOICES>"
            }
        }
    }
}

متغيرات البيئة

  • WEATHER_CHOICES

التوثيق

مأخوذ من ملف README للمشروع على GitHub ويُحدَّث أسبوعيًا. تفتح الروابط على GitHub.

المحتويات
  1. MCP Server - Knapcode.SampleMcpServer
  2. Checklist before publishing to NuGet.org
  3. Using the MCP Server in VS Code
  4. Developing locally in VS Code

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"
      }
    }
  }
}

الأسئلة الشائعة

ما هو io.github.joelverhagen/Knapcode.SampleMcpServer؟

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

كيف أثبّت io.github.joelverhagen/Knapcode.SampleMcpServer؟

يعمل على جهازك. في Claude Code: claude mcp add knapcode-samplemcpserver -e 'WEATHER_CHOICES=<WEATHER_CHOICES>' -- dnx Knapcode.SampleMcpServer@0.7.0-beta --yes mcp start. وفي العملاء الآخرين، الصق إعداد JSON من هذه الصفحة في إعدادات MCP الخاصة بهم.

هل يحتاج io.github.joelverhagen/Knapcode.SampleMcpServer إلى مفتاح API؟

لا يذكر إدراجه في السجل أي مفتاح أو سر إلزامي. قد تتطلب بعض الميزات حسابًا لدى الخدمة التي يتصل بها.

هل io.github.joelverhagen/Knapcode.SampleMcpServer مفتوح المصدر؟

شيفرته علنية على GitHub، لكن المستودع لا يعلن ترخيصًا قياسيًا.

من يصون io.github.joelverhagen/Knapcode.SampleMcpServer؟

ينشره joelverhagen. يدرجه AI.tn لكنه لا يصونه ولا يوصي به.

من سجل MCP الرسمي. الإدراج ليس توصية: راجع شيفرة الخادم وصلاحياته قبل منحه الوصول إلى بياناتك.