VOOZH about

URL: https://thenewstack.io/tutorial-set-up-an-mcp-server-with-net-and-github-copilot/

⇱ Tutorial: Set Up an MCP Server With .NET and GitHub Copilot - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2025-05-17 06:00:45
Tutorial: Set Up an MCP Server With .NET and GitHub Copilot
tutorial,
AI / AI Agents / Software Development

Tutorial: Set Up an MCP Server With .NET and GitHub Copilot

We look at how to set up a C# version of an MCP Server using Github Copilot — all within Visual Studio Code.
May 17th, 2025 6:00am by David Eastman
👁 Featued image for: Tutorial: Set Up an MCP Server With .NET and GitHub Copilot
Photo by Chris Barbalis on Unsplash.
There has been an explosion of interest in Model Context Protocol (MCP), which is a good sign that people are trying to build different solutions using Large Language Models (LLMs), but now with their own systems. MCP is the middleman between LLMs and your tools. After doing a short Python example with Claude Code, I thought I’d expand with a C# version using Github Copilot — all within Visual Studio Code. The advantage of using an IDE is that we will get the chance to integrate with other MCP servers without leaving the IDE. Microsoft has covered MCP since April, and my post has its origins in this Dev Blog post. While Microsoft doesn’t usually work at pace, they are good at showing their progress these days. I’m going to assume you have VS Code and have signed into GitHub Copilot.

Inside Track

Since Microsoft is rolling this out, you might already have VS Code powered with “agent mode.” This is clearly where they will focus their agentic solutions. Just turn on Github Copilot chat and look at the bottom of the screen, at the “Ask” dropdown: 👁 Image
If you don’t have Agent mode, you can try searching (in the command palette) for user settings. 👁 Image
And if that doesn’t work, or you don’t want to mess with your IDE, you can get hold of Visual Studio Code Insiders. This is where the latest builds (but probably not the most stable) are hosted. Don’t worry, though, because this is designed to sit next to your stable VS Code. This is quite a neat move, as it allows Microsoft to follow new trends like MCP without sinking their fleet. The only other thing you should do before we start is add “code-insiders” to your command path so that we can find it from the command shell. Just start typing “shell command” in the Command Palette: 👁 Image
Just so you are confident they can run together, I can assure you they look different in the dock: 👁 Image
Code-insiders is the one in green! Now, let’s get what we need for the MCP server.

Setting Up the MCP Server

Starting in the command shell, let’s set up a .NET console project for MCP: 👁 Image
Then let’s go into the project and explicitly add some packages. We should be able to do this in VS Code, too, but we can be more specific here: 👁 Image
Now let’s open up VS Code from the project directory in the command line. Doing this ensures you inherit the context properly: 👁 Image
Then replace the template Program.cs with the code to set up an MCP server:
using Microsoft.Extensions.DependencyInjection; 
using Microsoft.Extensions.Hosting; 
using ModelContextProtocol.Server; 
using System.ComponentModel; 

var builder = Host.CreateApplicationBuilder(args); 
builder.Logging.AddConsole(consoleLogOptions => 
{ 
 // Configure all logs to go to stderr 
 consoleLogOptions.LogToStandardErrorThreshold = LogLevel.Trace; 
}); 
builder.Services
 .AddMcpServer() 
 .WithStdioServerTransport() 
 .WithToolsFromAssembly(); 

await builder.Build().RunAsync();
This is not too different in principle from the Python example from a couple of weeks back. Note the request to search for tools in the running assembly. This is the introspection equivalent that we did in Python. The MCP server effectively acts as a container, and it advertises its available tools. I’ll use the same simple Secretword tool from that Python example. It just returns our secret word:
[McpServerToolType]
public static class SecretwordTool
{
 [McpServerTool, Description("Reveal the secret word.")]
 public static string Secretword(string message) => "ABRACADABRA";
}
Note that the attribute (the term in square brackets that provides a metadata cue about the code below it) marks the method as an MCP tool. Again, we have that curse of MCP: the slight confusion between server and tool. These attribute names don’t really help. Now, click the “select tools” spanner icon in the chat box: 👁 Image
You should see a list of tools. We are now going to register our new tool. Search for MCP settings in the settings tab, via the cog at the bottom left: 👁 Image
Click the “Edit in settings” link and you’ll see the settings JSON file: 👁 Image
The MCP section might be empty, or in this case, have the default time tool. Look closely and you’ll see the “Start” arrow just above the method name within “servers”. Simply add the following (or replace the example) in the JSON file to describe our tool:
{
 "inputs": [],
 "servers": {
 "thenewstackMCP": {
 "type": "stdio",
 "command": "dotnet",
 "args": [
 "run",
 "--project",
 "/Users/eastmad/thenewstack/thenewstackMCP/thenewstackMCP.csproj"
 ]
 }
 }
}
My absolute path is for my MacBook. I described STDIO in my last post on MCP. Save it. Now hit the “start” button that should appear just above: 👁 Image
Going back to our chat box, we can see that the refresh button has spotted our new tool. So click that and the “select tools” button again, and you’ll see this at the end of the list of tools: 👁 Image
Yes, we exist! Yay.

Asking Copilot For the Secret Word

Now we can run Secretword directly through Copilot chat. That is, Copilot now understands semantically that there is a tool called “secretword” that it has access to: 👁 Image
Microsoft is aware that with this level of indirection, a user might now be persuaded to run code without realizing it. For this reason, the system interrupts the conversation to check that this is intended. That blue “Continue” box sets permissions for the session, including whether to allow the tool to run. Once we do so, we get the result from ChatGPT: 👁 Image
After that, we can go on to extend the tools to something more useful.

Conclusion

If we compare this process with the Python example with Claude Code, I don’t think we get a lot of advantages from Visual Code integration yet — because MCP is clearly a bolt-on for now. This is clearly aimed at early developers trying to figure our the MCP workflow and ramifications. I can envisage Microsoft forcing their own solution onto users in time, but this is where we are now. Everyone is at the MCP party.
TRENDING STORIES
David has been a London-based professional software developer with Oracle Corp. and British Telecom, and a consultant helping teams work in a more agile fashion. He wrote a book on UI design and has been writing technical articles ever since....
Read more from David Eastman
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: Simply, Reveal.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.