Building an MCP Server/Client in Windows 11
Written by Om-Shree-0709 on .
This article explains how to build a working MCP server and a client on Windows 11 using the .NET C# SDK. We will learn how to set up the server, register tools, configure a client agent to discover and use the server, and explore what happens behind the scenes. This provides a practical basis for developers to enable AI agents to perform real tasks like listing files or accessing system resources on Windows 11 12.
Server and Client Setup
Microsoft provides a template in .NET 10 for creating an MCP server using the dotnet new mcpserver
command. This template gives you a sample tool (get_random_number
) and a working server scaffold 23. You can expand this template by adding your own tool classes to interact with Windows functionality, such as listing files or checking directory contents. On the client side, you use Azure AI Foundry or GitHub Copilot agents configured to connect to your MCP server by specifying fields like server_url
, allowed_tools
, and require_approval
4.
Code / Implementation
Here is how you build a minimal MCP server in C#:
With this setup, the server is ready to register any class marked with MCP tool attributes. It listens over standard input/output and exposes tools like list_files
25.
To configure a client agent in Azure AI Foundry, include:
This configuration ensures the agent discovers the server, only uses approved tools, and requests user permission before calling them 4.
Behind the Scenes
When the server starts, it registers with the MCP registry if available. Tools are loaded with reflection by scanning the assembly for methods annotated with [McpTool]
. The client discovers these tools via registry metadata or by fetching tool definitions directly. When a client agent makes a request, the transport layer (stdio or HTTP) handles the JSON-RPC protocol. On each call, Windows checks user permissions if required, enforces tool isolation, and logs actions. Errors or invalid inputs are reported via RPC responses. The server runs in a minimal sandbox to prevent misuse or unintended system access 23.
My Thoughts
This tutorial illustrates how simple it is for developers to create their own MCP tooling on Windows using C#. The SDK’s template and reflection-based tool discovery streamline development. Requiring user approval for tool execution helps maintain security. However, developers should design tools carefully, minimizing required privileges and validating inputs to avoid security risks. Testing in different environments like WSL or enterprise Windows builds may highlight deployment differences. Overall, this setup gives developers hands-on control over agent tools in a controlled and traceable way.
References
Footnotes
-
Microsoft .NET Blog: build a minimal MCP server quickstart ↩
-
Microsoft DevBlogs: build a model context protocol MCP server in C# ↩ ↩2 ↩3 ↩4
-
DEV Community tutorial: create an MCP server with .NET and C# ↩ ↩2
-
Microsoft Learn: configure Azure AI Foundry agent with MCP tool ↩ ↩2
-
Medium: building your first MCP server with C# SDK step-by-step guide ↩
Written by Om-Shree-0709 (@Om-Shree-0709)