Build your MCP Server using C# SDK
LocalAbout Build your MCP Server using C# SDK
An educational .NET console project showing how to create an MCP server with the C# SDK. Its three tools echo, reverse, and measure the length of an input string, and the README describes trying them through GitHub Copilot Chat.
Key features
- 01C# SDK server example
- 02Echo, reverse, and length tools
- 03.NET console application
- 04Tool exposure with attributes
- 05VS Code server configuration
Use cases
- 01Learning MCP server creation in C#
- 02Testing string tools through GitHub Copilot Chat
MCP support
The project exposes three string-processing methods as MCP tools. GitHub Copilot Chat in Agent mode can invoke them through the configured server.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEBuild your MCP Server using C# SDK
This repo is for educational purposes to explore how to create your own MCP server using C# SDK.
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
- 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
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.