MCPServerTest

Build MCP server

GitHubスター

0

ユーザー評価

未評価

お気に入り

0

閲覧数

5

フォーク

0

イシュー

0

README
Build your MCP Server using C# SDK

This repo is for educational purposes to explore how to create your own MCP server using C# SDK.

image

Official MSFT blog

Steps to build

This is a simple .NET console application that builds a MCP server with 3 simple methods namely to return echo, reverse, length of the input string. This project is based on the sample explained in Introduction to the C# SDK for Model Context Protocol (MCP)

To build MCP server using c# SDK, follow the below steps

  • Create a .NET console application
  • Add Nuget packages Microsoft.Extensions.Hosting and ModelContextProtocol
  • To expose your method as MCP tool decorate it with attribute [McpServerToolType] and provide clear description so the LLM can decide which tool to invoke
  • Build the project
  • Add mcp.json under .vscode folder to add new server. Add the server with the project location to run the dotnet command
  • Run your server now
  • Open GH Copilot Chat window and run it under Agent mode
  • Once the app is running, you can click on the Tools icon on the GH Copilot chat window.
  • Now you will see the three tools available

image

  • Use the GH copilot chat as the client and ask it to reverse a given string as below. This will invoke the reverse tool from the MCP server and return the result
image